Commit dbebf0f2d57294617cf39bb95d4f998b7e2ff01d

Authored by totoro
1 parent 2fb07b3f

add HK_text_choices definition

Showing 1 changed file with 18 additions and 3 deletions   Show diff stats
types/model/fields.anubis
... ... @@ -70,7 +70,13 @@ public define Maybe(HK_App_Name)
70 70 failure
71 71 .
72 72  
73   -
  73 +public type HK_Text_Choice:
  74 + hk_text_choice(String value, String visible).
  75 +
  76 +public type HK_Text_Choices:
  77 + no_choice,
  78 + text_choices(List(HK_Text_Choice)).
  79 +
74 80 public type HK_Datetime_Field_Attr:
75 81 none, //Nothing special, normal behaviour
76 82 auto_now, //Always update datetime at SQL update
... ... @@ -117,9 +123,17 @@ public type HK_Model_Field:
117 123 datetime_field(HK_Datetime_Field_Attr), // datetime with the precision of the second
118 124 foreign_key (HK_App_Name app_name, String table_name), // foreign key to 'id' in another (or same) table and column_name for choice selector.
119 125 integer_field, // integer of arbitrary size
120   - char_field (Int size), // text of maximal size 'size' (number of characters)
  126 + char_field (HK_Text_Choices choices, Int size), // text of maximal size 'size' (number of characters)
121 127 text_field. // text of variable size
122 128  
  129 +//default initialization
  130 +public define HK_Model_Field
  131 + char_field
  132 + (
  133 + Int size
  134 + )=
  135 + char_field(no_choice, size).
  136 +
123 137 public define HK_Model_Field
124 138 foreign_key
125 139 (
... ... @@ -188,7 +202,8 @@ public define Message
188 202 integer_field then // integer of arbitrary size
189 203 forget(add_string(hk_model_field_message, "type", "integer_field")),
190 204  
191   - char_field (size) then // text of maximal size 'size' (number of characters)
  205 + char_field (choices, size) then // text of maximal size 'size' (number of characters)
  206 + //TODO add choices if need
192 207 forget(add_string(hk_model_field_message, "type", "char_field"));
193 208 forget(add_int32(hk_model_field_message, "size", truncate_to_Word32(size))),
194 209  
... ...