Skip to content

Commit

Permalink
less quirky patternmatch
Browse files Browse the repository at this point in the history
  • Loading branch information
nezbite committed Aug 27, 2020
1 parent 614f3d9 commit 0ed7773
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions IHP/IDE/Data/View/EditRow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ instance View EditRowView ViewContext where
where
id = (cs (fromMaybe "" (get #fieldValue (fromJust (headMay fields)))))
renderField id DynamicField { .. } | fieldName == "id" = [hsx|<td><span data-fieldname={fieldName}><a class="no-link border rounded p-1" href={EditRowValueAction tableName (cs fieldName) id}>{renderId (sqlValueToText fieldValue)}</a></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "t" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked="checked" /></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "f" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id}/></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked={sqlValueToText fieldValue == "t"} /></span></td>|]
renderField id DynamicField { .. } = [hsx|<td><span data-fieldname={fieldName}><a class="no-link" href={EditRowValueAction tableName (cs fieldName) id}>{sqlValueToText fieldValue}</a></span></td>|]


Expand Down
3 changes: 1 addition & 2 deletions IHP/IDE/Data/View/NewRow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ instance View NewRowView ViewContext where
where
id = (cs (fromMaybe "" (get #fieldValue (fromJust (headMay fields)))))
renderField id DynamicField { .. } | fieldName == "id" = [hsx|<td><span data-fieldname={fieldName}><a class="no-link border rounded p-1" href={EditRowValueAction tableName (cs fieldName) id}>{renderId (sqlValueToText fieldValue)}</a></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "t" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked="checked" /></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "f" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id}/></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked={sqlValueToText fieldValue == "t"} /></span></td>|]
renderField id DynamicField { .. } = [hsx|<td><span data-fieldname={fieldName}><a class="no-link" href={EditRowValueAction tableName (cs fieldName) id}>{sqlValueToText fieldValue}</a></span></td>|]

modalContent = [hsx|
Expand Down
3 changes: 1 addition & 2 deletions IHP/IDE/Data/View/ShowTableRows.hs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ instance View ShowTableRowsView ViewContext where
contextMenuId = "context-menu-column-" <> tshow id
id = (cs (fromMaybe "" (get #fieldValue (fromJust (headMay fields)))))
renderField id DynamicField { .. } | fieldName == "id" = [hsx|<td><span data-fieldname={fieldName}><a class="no-link border rounded p-1" href={EditRowValueAction tableName (cs fieldName) id}>{renderId (sqlValueToText fieldValue)}</a></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "t" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked="checked" /></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) && sqlValueToText fieldValue == "f" = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id}/></span></td>|]
renderField id DynamicField { .. } | isBoolField fieldName tableCols && not (isNothing fieldValue) = [hsx|<td><span data-fieldname={fieldName}><input type="checkbox" onclick={onClick tableName fieldName id} checked={sqlValueToText fieldValue == "t"} /></span></td>|]
renderField id DynamicField { .. } = [hsx|<td><span data-fieldname={fieldName}><a class="no-link" href={EditRowValueAction tableName (cs fieldName) id}>{sqlValueToText fieldValue}</a></span></td>|]

columnNames = map (get #fieldName) (fromMaybe [] (head rows))
Expand Down

0 comments on commit 0ed7773

Please sign in to comment.