Extended autocompletion with customized templates

This commit is contained in:
Severin Münger
2013-09-12 17:15:05 +02:00
parent 27023283e7
commit 162735b328
12 changed files with 260 additions and 66 deletions

View File

@@ -13,4 +13,6 @@ feature
deferred
end
template: detachable STRING
end

View File

@@ -16,7 +16,7 @@ create
feature {NONE}
make (l: LIST [STRING])
make (l: ITERABLE [STRING])
do
list := l
end
@@ -41,6 +41,6 @@ feature -- Implementation
feature
list: LIST [STRING]
list: ITERABLE [STRING]
end

View File

@@ -11,7 +11,8 @@ inherit
WSF_INPUT_CONTROL
redefine
handle_callback
handle_callback,
state
end
create
@@ -22,12 +23,24 @@ feature {NONE} -- Creation
make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
do
make_autocomplete_with_agent (n, agent c.autocompletion)
if attached c.template as t then
template := t
end
end
make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
do
make_input (n, "")
create_json_list := c
template := "{{=value}}"
end
feature -- State
state: JSON_OBJECT
do
Result := Precursor {WSF_INPUT_CONTROL}
Result.put (create {JSON_STRING}.make_json (template), create {JSON_STRING}.make_json ("template"))
end
feature -- Callback
@@ -44,4 +57,6 @@ feature -- Autocomplete
create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
template: STRING
end

View File

@@ -77,7 +77,8 @@ feature
create states.make
control.read_state (states)
data := "<html><head>"
data.append ("<link href=%"//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css%" rel=%"stylesheet%">")
data.append ("<link href=%"/bootstrap.min.css%" rel=%"stylesheet%">")
data.append ("<link href=%"/widget.css%" rel=%"stylesheet%">")
data.append ("</head><body>")
data.append (control.render)
data.append ("<script type=%"text/javascript%">window.states=")