Commit 0d7961ea authored by Steffen Michels's avatar Steffen Michels

Merge branch 'export-toLabelText' into 'master'

Export toLabelText to generate label names from e.g. record field names

See merge request !343
parents d8d618ed 9cee52de
Pipeline #31292 passed with stage
in 6 minutes and 40 seconds
......@@ -145,3 +145,6 @@ setActionIcon :: (Map String String) -> LayoutRule
* Format a basic editor as if it was a generic labelled iconized edtior
*/
toFormItem :: LayoutRule
//* Format a string as a label (e.g., `firstName` -> `"First name"`)
toLabelText :: !String -> String
......@@ -367,8 +367,7 @@ where
where
createLabelText attr = textAttr text
where
text = formatDefaultLabel label +++ (if (enterOrUpdate && not optional) "*" "") +++ ":"
formatted = formatDefaultLabel label
text = toLabelText label +++ (if (enterOrUpdate && not optional) "*" "") +++ ":"
enterOrUpdate = maybe False (\(JSONString m) -> isMember m ["enter","update"]) ('DM'.get "mode" attr)
optional = maybe False (\(JSONBool b) -> b) ('DM'.get "optional" attr)
label = maybe "-" (\(JSONString s) -> s) ('DM'.get "label" attr)
......@@ -391,15 +390,15 @@ where
iconCls = maybe "icon-info" (\(JSONString t) -> "icon-" +++ t) ('DM'.get HINT_TYPE_ATTRIBUTE attr)
tooltip = maybe "-" (\(JSONString s) -> s) ('DM'.get HINT_ATTRIBUTE attr)
formatDefaultLabel label = {c \\ c <- [toUpper lname : addspace lnames]}
where
[lname:lnames] = fromString label
addspace [] = []
addspace [c:cs]
| c == '_' = [' ':addspace cs]
| isUpper c = [' ',toLower c:addspace cs]
| otherwise = [c:addspace cs]
removeLabelAttribute = layoutSubUIs (SelectAND SelectChildren (SelectByHasAttribute "label"))
(delUIAttributes (SelectKeys ["label"]))
toLabelText :: !String -> String
toLabelText label = {c \\ c <- [toUpper lname : addspace lnames]}
where
[lname:lnames] = fromString label
addspace [] = []
addspace [c:cs]
| c == '_' = [' ':addspace cs]
| isUpper c = [' ',toLower c:addspace cs]
| otherwise = [c:addspace cs]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment