@@ -43,10 +43,12 @@ feature -- Change
43
43
v : EV_VERTICAL_BOX
44
44
hb : EV_HORIZONTAL_BOX
45
45
lab : EV_LABEL
46
- tf : EV_TEXT_FIELD
46
+ -- tf: EV_TEXT_FIELD
47
+ tf : EV_TEXT
47
48
tf_passwd : EV_PASSWORD_FIELD
48
49
but : EV_BUTTON
49
- table : HASH_TABLE [EV_TEXT_FIELD , STRING_ 32 ]
50
+ but_delete : detachable EV_BUTTON
51
+ table : HASH_TABLE [EV_TEXT_COMPONENT , STRING_ 32 ]
50
52
is_creation : BOOLEAN
51
53
is_password : BOOLEAN
52
54
do
@@ -110,15 +112,23 @@ feature -- Change
110
112
else
111
113
create but .make_with_text (" Update" )
112
114
but .select_actions .extend (agent on_post (coll , tpl , table , False ))
115
+ create but_delete .make_with_text (" Delete" )
116
+ but_delete .select_actions .extend (agent on_delete (coll , tpl , table ))
117
+
113
118
end
114
119
115
120
v .extend (create {EV_CELL })
116
121
v .extend (but )
122
+ if but_delete /= Void then
123
+ v .extend (but_delete )
124
+ v .disable_item_expand (but_delete )
125
+
126
+ end
117
127
v .disable_item_expand (but )
118
128
-- FIXME
119
129
end
120
130
121
- on_post (coll : CJ_COLLECTION ; tpl : CJ_TEMPLATE ; table : HASH_TABLE [EV_TEXT_FIELD , STRING_ 32 ]; is_creation : BOOLEAN )
131
+ on_post (coll : CJ_COLLECTION ; tpl : CJ_TEMPLATE ; table : HASH_TABLE [EV_TEXT_COMPONENT , STRING_ 32 ]; is_creation : BOOLEAN )
122
132
local
123
133
ctx : HTTP_CLIENT_REQUEST_CONTEXT
124
134
l_href : STRING_ 8
@@ -147,6 +157,33 @@ feature -- Change
147
157
-- dlg.focus_out_actions.extend (agent dlg.destroy_and_exit_if_last)
148
158
end
149
159
160
+ on_delete (coll : CJ_COLLECTION ; tpl : CJ_TEMPLATE ; table : HASH_TABLE [EV_TEXT_COMPONENT , STRING_ 32 ])
161
+ local
162
+ ctx : HTTP_CLIENT_REQUEST_CONTEXT
163
+ l_href : STRING_ 8
164
+ dlg : EV_INFORMATION_DIALOG
165
+ resp : CJ_CLIENT_RESPONSE
166
+ do
167
+ create ctx .make
168
+ across
169
+ tpl .data as c
170
+ loop
171
+ if attached table .item (c .item .name ) as tf then
172
+ c .item .set_value (tf .text )
173
+ end
174
+ end
175
+ if attached coll .items as l_items and then attached l_items .first as first_item then
176
+ l_href := first_item .href
177
+ resp := cj_client .delete (l_href , Void )
178
+ else
179
+ l_href := coll .href
180
+ resp := cj_client .delete (l_href , Void )
181
+ end
182
+ create dlg .make_with_text (" Result" )
183
+ dlg .set_text (resp .http_response )
184
+ dlg .show
185
+ end
186
+
150
187
invariant
151
188
widget_attached : widget /= Void
152
189
0 commit comments