Commit de8fdfcfac107c2144c067ec77c58f93d253daf0
1 parent
e7bd8a6e
add icon and help_text to HK_App
rename the db_display into hk_display
Showing
1 changed file
with
82 additions
and
5 deletions
Show diff stats
database/model/db_model.anubis
| @@ -102,6 +102,7 @@ public type HK_Help_Text: | @@ -102,6 +102,7 @@ public type HK_Help_Text: | ||
| 102 | help_text_TAG(String), //TAG use with Anubis translation tool /locale/L3.anubis | 102 | help_text_TAG(String), //TAG use with Anubis translation tool /locale/L3.anubis |
| 103 | help_text(String). //pure text to show | 103 | help_text(String). //pure text to show |
| 104 | 104 | ||
| 105 | + | ||
| 105 | public define String | 106 | public define String |
| 106 | /* Return the Anubis source of the type component | 107 | /* Return the Anubis source of the type component |
| 107 | */ | 108 | */ |
| @@ -115,6 +116,36 @@ public define String | @@ -115,6 +116,36 @@ public define String | ||
| 115 | help_text_TAG(tag) then "help_text_TAG(\""+tag+"\")", | 116 | help_text_TAG(tag) then "help_text_TAG(\""+tag+"\")", |
| 116 | help_text(str) then "help_text(\""+str+"\")" | 117 | help_text(str) then "help_text(\""+str+"\")" |
| 117 | }. | 118 | }. |
| 119 | + | ||
| 120 | +public type HK_Icon: | ||
| 121 | + no_icon, | ||
| 122 | + icon16(String name). | ||
| 123 | + | ||
| 124 | +public define String | ||
| 125 | +/* Return the Anubis source of the type component | ||
| 126 | +*/ | ||
| 127 | + to_Anubis_source | ||
| 128 | + ( | ||
| 129 | + HK_Icon icon | ||
| 130 | + )= | ||
| 131 | + if icon is | ||
| 132 | + { | ||
| 133 | + no_icon then "no_icon", | ||
| 134 | + icon16(icn_str) then "icon16(\""+icn_str+"\")" | ||
| 135 | + }. | ||
| 136 | + | ||
| 137 | +public define String | ||
| 138 | +/* Return the Anubis source of the type component | ||
| 139 | +*/ | ||
| 140 | + to_String | ||
| 141 | + ( | ||
| 142 | + HK_Icon icon | ||
| 143 | + )= | ||
| 144 | + if icon is | ||
| 145 | + { | ||
| 146 | + no_icon then "\"\"", | ||
| 147 | + icon16(icn_str) then "\""+icn_str+"_icon\"" | ||
| 148 | + }. | ||
| 118 | 149 | ||
| 119 | Of course, 'NOT NULL' is not an alternative of 'HK_Model_Attr' because it is already coded into the | 150 | Of course, 'NOT NULL' is not an alternative of 'HK_Model_Attr' because it is already coded into the |
| 120 | database type itself (type 'HK_Model_Field' above). | 151 | database type itself (type 'HK_Model_Field' above). |
| @@ -169,7 +200,7 @@ public type HK_Edit_View: | @@ -169,7 +200,7 @@ public type HK_Edit_View: | ||
| 169 | edit_view(String view_name, List(String) columns). | 200 | edit_view(String view_name, List(String) columns). |
| 170 | 201 | ||
| 171 | public type HK_Display: | 202 | public type HK_Display: |
| 172 | - db_display(List(HK_List_View) list_views, | 203 | + hk_display(List(HK_List_View) list_views, |
| 173 | //List(HK_Edit_View) edit_views | 204 | //List(HK_Edit_View) edit_views |
| 174 | List(String)). | 205 | List(String)). |
| 175 | 206 | ||
| @@ -183,10 +214,41 @@ public type HK_Table: | @@ -183,10 +214,41 @@ public type HK_Table: | ||
| 183 | Description of a whole database: | 214 | Description of a whole database: |
| 184 | 215 | ||
| 185 | public type HK_App: | 216 | public type HK_App: |
| 186 | - hk_app( String app_name, | ||
| 187 | - List(HK_Table) hk_tables | ||
| 188 | - ). | ||
| 189 | - | 217 | + hk_app( |
| 218 | + String app_name, | ||
| 219 | + HK_Icon icon, | ||
| 220 | + HK_Help_Text help, | ||
| 221 | + List(HK_Table) hk_tables | ||
| 222 | + ). | ||
| 223 | + | ||
| 224 | + /* Default constructor for HK_App*/ | ||
| 225 | +public define HK_App | ||
| 226 | + hk_app | ||
| 227 | + ( | ||
| 228 | + String app_name, | ||
| 229 | + HK_Help_Text help, | ||
| 230 | + List(HK_Table) hk_tables | ||
| 231 | + )= | ||
| 232 | + hk_app(app_name, no_icon, help, hk_tables). | ||
| 233 | + | ||
| 234 | +public define HK_App | ||
| 235 | + hk_app | ||
| 236 | + ( | ||
| 237 | + String app_name, | ||
| 238 | + HK_Icon icon, | ||
| 239 | + List(HK_Table) hk_tables | ||
| 240 | + )= | ||
| 241 | + hk_app(app_name, icon, no_help_text, hk_tables). | ||
| 242 | + | ||
| 243 | + | ||
| 244 | +public define HK_App | ||
| 245 | + hk_app | ||
| 246 | + ( | ||
| 247 | + String app_name, | ||
| 248 | + List(HK_Table) hk_tables | ||
| 249 | + )= | ||
| 250 | + hk_app(app_name, no_icon, no_help_text, hk_tables). | ||
| 251 | + | ||
| 190 | public type HK_Database: | 252 | public type HK_Database: |
| 191 | hk_database (String name, // name of the database | 253 | hk_database (String name, // name of the database |
| 192 | List(HK_App) apps //list of applications | 254 | List(HK_App) apps //list of applications |
| @@ -268,6 +330,21 @@ define macro Maybe(String) | @@ -268,6 +330,21 @@ define macro Maybe(String) | ||
| 268 | } | 330 | } |
| 269 | }. | 331 | }. |
| 270 | 332 | ||
| 333 | +public define Int | ||
| 334 | + longest_table_name_size | ||
| 335 | + ( | ||
| 336 | + List(HK_App) apps, | ||
| 337 | + Int current_size | ||
| 338 | + )= | ||
| 339 | + if apps is | ||
| 340 | + { | ||
| 341 | + [] then current_size, | ||
| 342 | + [app . t_apps] then | ||
| 343 | + since app is hk_app(_, _, _, tables), | ||
| 344 | + with max_size = max(map((HK_Table table) |-> length(table.name), tables), current_size), | ||
| 345 | + longest_table_name_size(t_apps, max_size) | ||
| 346 | + }. | ||
| 347 | + | ||
| 271 | define Int | 348 | define Int |
| 272 | _max | 349 | _max |
| 273 | ( | 350 | ( |