@@ -43,10 +43,12 @@ feature -- Change
4343 v : EV_VERTICAL_BOX
4444 hb : EV_HORIZONTAL_BOX
4545 lab : EV_LABEL
46- tf : EV_TEXT_FIELD
46+ -- tf: EV_TEXT_FIELD
47+ tf : EV_TEXT
4748 tf_passwd : EV_PASSWORD_FIELD
4849 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 ]
5052 is_creation : BOOLEAN
5153 is_password : BOOLEAN
5254 do
@@ -110,15 +112,23 @@ feature -- Change
110112 else
111113 create but .make_with_text (" Update" )
112114 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+
113118 end
114119
115120 v .extend (create {EV_CELL })
116121 v .extend (but )
122+ if but_delete /= Void then
123+ v .extend (but_delete )
124+ v .disable_item_expand (but_delete )
125+
126+ end
117127 v .disable_item_expand (but )
118128 -- FIXME
119129 end
120130
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 )
122132 local
123133 ctx : HTTP_CLIENT_REQUEST_CONTEXT
124134 l_href : STRING_ 8
@@ -147,6 +157,33 @@ feature -- Change
147157-- dlg.focus_out_actions.extend (agent dlg.destroy_and_exit_if_last)
148158 end
149159
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+
150187invariant
151188 widget_attached : widget /= Void
152189
0 commit comments