Rename validators, Make forms resizable
This commit is contained in:
@@ -6,16 +6,22 @@ note
|
||||
|
||||
class
|
||||
WSF_AGENT_VALIDATOR [G]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALIDATOR [G]
|
||||
rename
|
||||
make as make_validator
|
||||
end
|
||||
|
||||
create
|
||||
make_with_agent
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_with_agent (h:like handler; e: STRING)
|
||||
make (h: like handler; e: STRING)
|
||||
do
|
||||
make (e)
|
||||
make_validator (e)
|
||||
handler := h
|
||||
end
|
||||
|
||||
@@ -23,10 +29,9 @@ feature
|
||||
|
||||
is_valid (input: G): BOOLEAN
|
||||
do
|
||||
|
||||
Result := handler.item ( [input])
|
||||
Result := handler.item ([input])
|
||||
end
|
||||
|
||||
handler: FUNCTION [ANY, TUPLE [G], BOOLEAN]
|
||||
|
||||
handler: FUNCTION[ANY,TUPLE[G],BOOLEAN]
|
||||
end
|
||||
|
||||
@@ -10,13 +10,16 @@ class
|
||||
inherit
|
||||
|
||||
WSF_REGEXP_VALIDATOR
|
||||
rename
|
||||
make as make_regexp_validator
|
||||
end
|
||||
|
||||
create
|
||||
make_decimal_validator
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_decimal_validator (e: STRING)
|
||||
make (e: STRING)
|
||||
-- Initialize with specified error message which will be displayed on validation failure
|
||||
do
|
||||
make_regexp_validator ("^[0-9]+(\.[0-9]*)?$|^\.[0-9]+$", e)
|
||||
|
||||
@@ -10,13 +10,16 @@ class
|
||||
inherit
|
||||
|
||||
WSF_REGEXP_VALIDATOR
|
||||
rename
|
||||
make as make_regexp_validator
|
||||
end
|
||||
|
||||
create
|
||||
make_email_validator
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_email_validator (e: STRING)
|
||||
make (e: STRING)
|
||||
-- Initialize with specified error message which will be displayed on validation failure
|
||||
do
|
||||
make_regexp_validator ("^[a-zA-Z0-9._%%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$", e)
|
||||
|
||||
@@ -5,24 +5,26 @@ note
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_MAX_VALIDATOR [G->FINITE[ANY]]
|
||||
WSF_MAX_VALIDATOR [G -> FINITE [ANY]]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALIDATOR [G]
|
||||
rename
|
||||
make as make_validator
|
||||
redefine
|
||||
state
|
||||
end
|
||||
|
||||
create
|
||||
make_max_validator
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_max_validator (m: INTEGER; e: STRING)
|
||||
make (m: INTEGER; e: STRING)
|
||||
-- Initialize with specified maximum and error message which will be displayed on validation failure
|
||||
do
|
||||
make (e)
|
||||
make_validator (e)
|
||||
max := m
|
||||
end
|
||||
|
||||
|
||||
@@ -5,24 +5,26 @@ note
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_MIN_VALIDATOR [G->FINITE[ANY]]
|
||||
WSF_MIN_VALIDATOR [G -> FINITE [ANY]]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALIDATOR [G]
|
||||
rename
|
||||
make as make_validator
|
||||
redefine
|
||||
state
|
||||
end
|
||||
|
||||
create
|
||||
make_min_validator
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_min_validator (m: INTEGER; e: STRING)
|
||||
make (m: INTEGER; e: STRING)
|
||||
-- Initialize with specified minimum and error message which will be displayed on validation failure
|
||||
do
|
||||
make (e)
|
||||
make_validator (e)
|
||||
min := m
|
||||
end
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@ class
|
||||
inherit
|
||||
|
||||
WSF_REGEXP_VALIDATOR
|
||||
rename
|
||||
make as make_regexp_validator
|
||||
end
|
||||
|
||||
create
|
||||
make_with_message
|
||||
|
||||
@@ -10,19 +10,21 @@ class
|
||||
inherit
|
||||
|
||||
WSF_VALIDATOR [STRING]
|
||||
rename
|
||||
make as make_validator
|
||||
redefine
|
||||
state
|
||||
end
|
||||
|
||||
create
|
||||
make_regexp_validator
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_regexp_validator (r, e: STRING)
|
||||
make (r, e: STRING)
|
||||
-- Initialize with specified regular expression and error message which will be displayed on validation failure
|
||||
do
|
||||
make (e)
|
||||
make_validator (e)
|
||||
regexp_string := r
|
||||
create regexp
|
||||
end
|
||||
|
||||
@@ -9,23 +9,41 @@ class
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_MULTI_CONTROL [WSF_CONTROL]
|
||||
WSF_STATELESS_MULTI_CONTROL [WSF_STATELESS_CONTROL]
|
||||
rename
|
||||
make as make_multi_control
|
||||
redefine
|
||||
add_control
|
||||
end
|
||||
|
||||
WSF_VALIDATABLE
|
||||
|
||||
create
|
||||
make
|
||||
make, make_with_label_width
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Initialize
|
||||
do
|
||||
make_with_label_width (2)
|
||||
end
|
||||
|
||||
make_with_label_width (w: INTEGER)
|
||||
do
|
||||
make_multi_control
|
||||
tag_name := "form"
|
||||
label_width := w
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
add_control (c: WSF_STATELESS_CONTROL)
|
||||
do
|
||||
Precursor (c)
|
||||
if attached {WSF_FORM_ELEMENT_CONTROL[ANY]} c as fec then
|
||||
fec.set_label_width (label_width)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Validation
|
||||
@@ -49,4 +67,8 @@ feature -- Validation
|
||||
is_valid: BOOLEAN
|
||||
-- Tells whether the last validation was valid
|
||||
|
||||
feature
|
||||
|
||||
label_width: INTEGER
|
||||
|
||||
end
|
||||
|
||||
@@ -48,6 +48,13 @@ feature {NONE} -- Initialization
|
||||
error := ""
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_label_width (w: INTEGER)
|
||||
do
|
||||
label_width := w
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
@@ -138,9 +145,9 @@ feature -- Implementation
|
||||
do
|
||||
body := ""
|
||||
if not label.is_empty then
|
||||
body.append ("<label class=%"col-lg-2 control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>")
|
||||
body.append ("<label class=%"col-lg-"+label_width.out+" control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>")
|
||||
end
|
||||
body.append ("<div class=%"col-lg-10%">")
|
||||
body.append ("<div class=%"col-lg-"+(12-label_width).out+"%">")
|
||||
body.append (value_control.render)
|
||||
body.append ("</div>")
|
||||
Result := render_tag (body, "")
|
||||
@@ -200,4 +207,6 @@ feature -- Properties
|
||||
error: STRING
|
||||
-- The error message that is displayed when client side validation fails
|
||||
|
||||
label_width: INTEGER
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user