Add disable option

This commit is contained in:
YNH Webdev
2014-01-02 18:19:59 +01:00
parent d3c66cd7fe
commit ce305d4e54
7 changed files with 212 additions and 94 deletions

View File

@@ -29,6 +29,11 @@ feature
feature --Properties
is_uploaded: BOOLEAN
do
Result := attached id
end
name: STRING
-- File name

View File

@@ -19,9 +19,8 @@ create
feature {NONE} -- Initialization
make (a_removable: BOOLEAN)
make
do
removable := a_removable
make_value_control ("input")
end
@@ -45,35 +44,18 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
create Result.make
Result.put_boolean (attached change_event, "callback_change")
Result.put_boolean (attached upload_done_event, "callback_uploaddone")
if attached file as f then
Result.put_string (f.name, "file_name")
Result.put_string (f.type, "file_type")
Result.put_integer (f.size, "file_size")
Result.put_string (f.id, "file_id")
end
Result.put_boolean (removable, "removable")
Result.put_boolean (disabled, "disabled")
end
feature -- Event handling
set_change_event (e: attached like change_event)
-- Set text change event handle
do
change_event := e
end
set_upload_done_event (e: attached like upload_done_event)
-- Set text change event handle
do
upload_done_event := e
end
set_upload_function (e: attached like upload_function)
-- Set button click event handle
do
upload_function := e
end
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)
local
f_name: detachable STRING
@@ -84,6 +66,8 @@ feature -- Event handling
if Current.control_name.same_string (cname [1]) then
if attached change_event as cevent and event.same_string ("change") then
cevent.call (Void)
elseif attached upload_done_event as udevent and event.same_string ("uploaddone") then
udevent.call (Void)
elseif event.same_string ("uploadfile") and attached {ITERABLE [WSF_UPLOADED_FILE]} event_parameter as files then
if attached file as f then
if attached upload_function as ufunction then
@@ -121,14 +105,51 @@ feature -- Implementation
end
render: STRING
local
attr: STRING
do
Result := render_tag ("", "type=%"file%" ")
attr := "type=%"file%" "
if attached attributes as a then
attr.append (a)
end
if disabled then
attr.append ("disabled=%"disabled%" ")
end
Result := render_tag ("", attr)
end
feature -- Change
set_change_event (e: attached like change_event)
-- Set text change event handle
do
change_event := e
end
set_upload_done_event (e: attached like upload_done_event)
-- Set text change event handle
do
upload_done_event := e
end
set_upload_function (e: attached like upload_function)
-- Set button click event handle
do
upload_function := e
end
set_disabled (b: BOOLEAN)
do
if disabled /= b then
disabled := b
state_changes.replace_with_boolean (disabled, "disabled")
end
end
feature -- Properties
removable: BOOLEAN
-- Defines if a file can be removed once it is uploaded
disabled: BOOLEAN
-- Defines if the a file is selectable and if a file can be removed once it is uploaded
file: detachable WSF_FILE
-- Text to be displayed

View File

@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
make (v: STRING)
-- Initialize with specified name and value
do
make_value_control ( "input")
make_value_control ("input")
type := "text"
text := v
end
@@ -42,6 +42,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
create Result.make
Result.put_string (text, "text")
Result.put_boolean (disabled, "disabled")
Result.put_boolean (attached change_event, "callback_change")
end
@@ -53,9 +54,9 @@ feature --Event handling
change_event := e
end
handle_callback (cname: LIST[STRING]; event: STRING; event_parameter: detachable ANY)
do
if Current.control_name.same_string (cname[1]) and attached change_event as cevent then
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)
do
if Current.control_name.same_string (cname [1]) and attached change_event as cevent then
if event.same_string ("change") then
cevent.call (Void)
end
@@ -65,8 +66,17 @@ feature --Event handling
feature -- Rendering
render: STRING
local
attr: STRING
do
Result := render_tag ("", "type=%"" + type + "%" value=%"" + text + "%"")
attr := "type=%"" + type + "%" value=%"" + text + "%" "
if attached attributes as a then
attr.append (a)
end
if disabled then
attr.append ("disabled=%"disabled%" ")
end
Result := render_tag ("", attr)
end
feature -- Change
@@ -80,6 +90,14 @@ feature -- Change
end
end
set_disabled (b: BOOLEAN)
do
if disabled /= b then
disabled := b
state_changes.replace_with_boolean (disabled, "disabled")
end
end
feature -- Implementation
value: STRING
@@ -89,6 +107,9 @@ feature -- Implementation
feature -- Properties
disabled: BOOLEAN
-- Defines if the input field is editable
text: STRING
-- Text to be displayed

View File

@@ -43,6 +43,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
do
create Result.make
Result.put_string (text, "text")
Result.put_boolean (disabled, "disabled")
Result.put_boolean (attached click_event, "callback_click")
end
@@ -54,9 +55,9 @@ feature --Event handling
click_event := e
end
handle_callback (cname: LIST[STRING]; event: STRING; event_parameter: detachable ANY)
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)
do
if Current.control_name.same_string (cname[1]) and attached click_event as cevent then
if Current.control_name.same_string (cname [1]) and attached click_event as cevent then
cevent.call (Void)
end
end
@@ -65,8 +66,17 @@ feature -- Rendering
render: STRING
-- HTML representation of this control
local
attr: STRING
do
Result := render_tag (text, attributes)
create attr.make_empty
if attached attributes as a then
attr.append (a)
end
if disabled then
attr.append ("disabled=%"disabled%" ")
end
Result := render_tag (text, attr)
end
feature -- Change
@@ -76,12 +86,23 @@ feature -- Change
do
if not t.same_string (text) then
text := t
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
state_changes.replace_with_string (text, "text")
end
end
set_disabled (b: BOOLEAN)
do
if disabled /= b then
disabled := b
state_changes.replace_with_boolean (disabled, "disabled")
end
end
feature -- Properties
disabled: BOOLEAN
-- Defines if the button is editable
text: STRING
-- The text currently displayed on this button