Added more comments and assertions to all classes; clean up
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}."
|
||||
description: "[
|
||||
A control that can be used for autocompletion. A customizable
|
||||
template can be passed to this class in a WSF_AUTOCOMPLETION
|
||||
instance.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -23,18 +27,18 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (c: WSF_AUTOCOMPLETION)
|
||||
-- Initialize with specified name and autocompletion
|
||||
-- Initialize with specified autocompletion
|
||||
do
|
||||
make_with_agent ( agent c.autocompletion)
|
||||
make_with_agent (agent c.autocompletion)
|
||||
if attached c.template as t then
|
||||
template := t
|
||||
end
|
||||
end
|
||||
|
||||
make_with_agent (c: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY])
|
||||
-- Initialize with specified name and autocompletion function
|
||||
-- Initialize with autocompletion function
|
||||
do
|
||||
make_input ( "")
|
||||
make_input ("")
|
||||
create_json_list := c
|
||||
template := "{{=value}}"
|
||||
end
|
||||
@@ -49,10 +53,10 @@ feature -- State
|
||||
|
||||
feature -- Callback
|
||||
|
||||
handle_callback (cname: LIST[STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
do
|
||||
Precursor {WSF_INPUT_CONTROL} (cname, event, event_parameter)
|
||||
if cname[1].same_string (control_name) and event.same_string ("autocomplete") then
|
||||
if cname [1].same_string (control_name) and event.same_string ("autocomplete") then
|
||||
state_changes.put (create_json_list.item ([text]), "suggestions")
|
||||
end
|
||||
end
|
||||
@@ -60,7 +64,9 @@ feature -- Callback
|
||||
feature -- Properties
|
||||
|
||||
create_json_list: FUNCTION [ANY, TUPLE [STRING_32], JSON_ARRAY]
|
||||
-- The function which is called to give a list of suggestions to a given user input
|
||||
|
||||
template: STRING_32
|
||||
-- The template
|
||||
|
||||
end
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_CONTROL}."
|
||||
description: "[
|
||||
Representation of an HTML checkbox.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -11,7 +13,9 @@ inherit
|
||||
|
||||
WSF_VALUE_CONTROL [BOOLEAN]
|
||||
rename
|
||||
make as make_value_control
|
||||
make as make_value_control,
|
||||
value as checked,
|
||||
set_value as set_checked
|
||||
end
|
||||
|
||||
create
|
||||
@@ -19,12 +23,14 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (l, c: STRING_32)
|
||||
-- Initialize with specified control name,
|
||||
make (l, value: STRING_32)
|
||||
-- Initialize with specified label and value
|
||||
require
|
||||
value_not_empty: not value.is_empty
|
||||
do
|
||||
make_value_control ("input")
|
||||
label := l
|
||||
checked_value := c
|
||||
checked_value := value
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -76,12 +82,8 @@ feature -- Implementation
|
||||
Result := render_tag_with_tagname ("div", render_tag_with_tagname ("label", render_tag ("", attrs) + " " + label, "", ""), "", "checkbox")
|
||||
end
|
||||
|
||||
value: BOOLEAN
|
||||
do
|
||||
Result := checked
|
||||
end
|
||||
|
||||
set_value (v: BOOLEAN)
|
||||
set_checked (v: BOOLEAN)
|
||||
-- Set if the checkbox is checked
|
||||
do
|
||||
checked := v
|
||||
end
|
||||
@@ -95,7 +97,7 @@ feature -- Properties
|
||||
-- The checked value of the checkbox control
|
||||
|
||||
checked_value: STRING_32
|
||||
-- String checked value
|
||||
-- The value of this checkbox
|
||||
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Function to be executed on change
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CHECKBOX_LIST_CONTROL}."
|
||||
description: "[
|
||||
Representation of a list of HTML checkboxes.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -37,23 +39,26 @@ feature {NONE} -- Initializaton
|
||||
feature -- Implementation
|
||||
|
||||
value: LIST [STRING_32]
|
||||
-- Returns the values of all selected checkboxes in this list
|
||||
do
|
||||
create {ARRAYED_LIST [STRING_32]} Result.make (0)
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if c.item.value then
|
||||
if c.item.checked then
|
||||
Result.extend (c.item.checked_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_value (v: LIST [STRING_32])
|
||||
-- Sets the checked state of each of the checkboxes in this list according to whether the value
|
||||
-- of a checkbox occurs in the specified list or not
|
||||
do
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
c.item.set_value (v.has (c.item.checked_value))
|
||||
c.item.set_checked (v.has (c.item.checked_value))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CODEVIEW_CONTROL}."
|
||||
description:"[
|
||||
This class is only used because the code viewer has a specific
|
||||
mapping in javascript. The Eiffel class does not provide
|
||||
special functionality itself.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FILE_CONTROL}."
|
||||
description: "[
|
||||
A control that represents a file upload.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -20,11 +22,13 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize
|
||||
do
|
||||
make_value_control ("input")
|
||||
end
|
||||
|
||||
make_with_image_preview
|
||||
-- Initialize with image_preview set to true
|
||||
do
|
||||
make
|
||||
image_preview := True
|
||||
@@ -102,6 +106,7 @@ feature -- Event handling
|
||||
feature -- Upload
|
||||
|
||||
start_upload
|
||||
-- Add start upload command to action list which then executes the javascript function to start upload on client side
|
||||
local
|
||||
upload: WSF_JSON_OBJECT
|
||||
do
|
||||
@@ -137,39 +142,56 @@ feature -- Change
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
ensure
|
||||
change_event_set: change_event = e
|
||||
end
|
||||
|
||||
set_upload_done_event (e: attached like upload_done_event)
|
||||
-- Set text change event handle
|
||||
do
|
||||
upload_done_event := e
|
||||
ensure
|
||||
upload_done_event_set: upload_done_event = e
|
||||
end
|
||||
|
||||
set_upload_function (e: attached like upload_function)
|
||||
-- Set button click event handle
|
||||
do
|
||||
upload_function := e
|
||||
ensure
|
||||
upload_function_set: upload_function = e
|
||||
end
|
||||
|
||||
set_disabled (b: BOOLEAN)
|
||||
-- Set the disabled state of this file control
|
||||
do
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
state_changes_registered: old disabled /= disabled implies state_changes.has_key ("disabled")
|
||||
end
|
||||
|
||||
set_value (v: detachable WSF_FILE_DEFINITION)
|
||||
-- Set the file definition of this file control
|
||||
do
|
||||
file := v
|
||||
ensure then
|
||||
file_set: file = v
|
||||
end
|
||||
|
||||
set_image_preview (b: BOOLEAN)
|
||||
-- Set if the image should be previewed in the control
|
||||
do
|
||||
if image_preview /= b then
|
||||
image_preview := b
|
||||
state_changes.replace_with_boolean (image_preview, "image_preview")
|
||||
end
|
||||
ensure
|
||||
image_preview_set: image_preview = b
|
||||
state_changes_registered: old image_preview /= image_preview implies state_changes.has_key ("image_preview")
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FILE_DEFINITION}."
|
||||
description: "[
|
||||
A container to encapsulate file information which is used by
|
||||
WSF_FILE_CONTROL, such as name or type of the file.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -20,9 +23,10 @@ feature {NONE}
|
||||
id := a_id
|
||||
end
|
||||
|
||||
feature
|
||||
feature -- Change
|
||||
|
||||
set_id (a_id: detachable STRING_32)
|
||||
-- Set the id of this abstract file.
|
||||
do
|
||||
id := a_id
|
||||
end
|
||||
@@ -30,6 +34,7 @@ feature
|
||||
feature --Properties
|
||||
|
||||
is_uploaded: BOOLEAN
|
||||
-- Whether the file denoted by this abstract file has been uploaded.
|
||||
do
|
||||
Result := attached id
|
||||
end
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
description: "[
|
||||
The basic <input> HTML element is represented by this control.
|
||||
All controls that are used to gather some input from the user
|
||||
basically can inherit from this class.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -25,6 +29,8 @@ feature {NONE} -- Initialization
|
||||
make_value_control ("input")
|
||||
type := "text"
|
||||
text := v
|
||||
ensure
|
||||
text_set: text = v
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
@@ -52,6 +58,8 @@ feature --Event handling
|
||||
-- Set text change event handle
|
||||
do
|
||||
change_event := e
|
||||
ensure
|
||||
change_event_set: change_event = e
|
||||
end
|
||||
|
||||
handle_callback (cname: LIST [STRING_32]; event: STRING_32; event_parameter: detachable ANY)
|
||||
@@ -88,31 +96,45 @@ feature -- Change
|
||||
text := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json (text), "text")
|
||||
end
|
||||
ensure
|
||||
text_same_string_as_t: text.same_string (t)
|
||||
state_changes_registered: old text /= text implies state_changes.has_key ("text")
|
||||
end
|
||||
|
||||
set_disabled (b: BOOLEAN)
|
||||
-- Set the disabled state of this control
|
||||
do
|
||||
if disabled /= b then
|
||||
disabled := b
|
||||
state_changes.replace_with_boolean (disabled, "disabled")
|
||||
end
|
||||
ensure
|
||||
disabled_set: disabled = b
|
||||
state_changes_registered: old b /= b implies state_changes.has_key ("disabled")
|
||||
end
|
||||
|
||||
set_type (t: STRING_32)
|
||||
-- Set the type of this input control (HTML 'type' attribute)
|
||||
do
|
||||
type := t
|
||||
ensure
|
||||
type_set: type = t
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
value: STRING_32
|
||||
-- The value of this input control
|
||||
do
|
||||
Result := text
|
||||
end
|
||||
|
||||
set_value (v: STRING_32)
|
||||
-- Set the value of this input control
|
||||
do
|
||||
text := v
|
||||
ensure then
|
||||
value_set: text = v
|
||||
end
|
||||
|
||||
feature -- Properties
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PASSWORD_CONTROL}."
|
||||
description: "[
|
||||
This control represents an HTML input control with the 'type'
|
||||
attribute set to 'password'.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
note
|
||||
description: "Summary description for {WSF_TEXT_CONTROL}."
|
||||
description: "[
|
||||
This control represents a textarea (the HTML 'textarea' tag).
|
||||
It basically just inherits the functionality of an input
|
||||
control.
|
||||
]"
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
Reference in New Issue
Block a user