summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/cbi.lua45
-rw-r--r--libs/web/luasrc/view/cbi/dynlist.htm47
-rw-r--r--libs/web/luasrc/view/cbi/full_valuefooter.htm2
3 files changed, 54 insertions, 40 deletions
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua
index 5fa992dee8..17ca18c941 100644
--- a/libs/web/luasrc/cbi.lua
+++ b/libs/web/luasrc/cbi.lua
@@ -1641,25 +1641,48 @@ function DynamicList.value(self, key, val)
table.insert(self.vallist, tostring(val))
end
-function DynamicList.write(self, ...)
- self.map.proceed = true
- return AbstractValue.write(self, ...)
+function DynamicList.write(self, section, value)
+ if self.cast == "string" and type(value) == "table" then
+ value = table.concat(value, " ")
+ elseif self.cast == "table" and type(value) == "string" then
+ local x, t = { }
+ for x in value:gmatch("%S+") do
+ t[#t+1] = x
+ end
+ value = t
+ end
+
+ return AbstractValue.write(self, section, value)
+end
+
+function DynamicList.cfgvalue(self, section)
+ local value = AbstractValue.cfgvalue(self, section)
+
+ if type(value) == "string" then
+ local x
+ local t = { }
+ for x in value:gmatch("%S+") do
+ t[#t+1] = x
+ end
+ value = t
+ end
+
+ return value
end
function DynamicList.formvalue(self, section)
local value = AbstractValue.formvalue(self, section)
- value = (type(value) == "table") and value or {value}
- local valid = {}
- for i, v in ipairs(value) do
- if v and #v > 0
- and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i)
- and not self.map:formvalue("cbi.rle."..section.."."..self.option.."."..i..".x") then
- table.insert(valid, v)
+ if type(value) == "string" then
+ local x
+ local t = { }
+ for x in value:gmatch("%S+") do
+ t[#t+1] = x
end
+ value = t
end
- return valid
+ return value
end
diff --git a/libs/web/luasrc/view/cbi/dynlist.htm b/libs/web/luasrc/view/cbi/dynlist.htm
index 826e2e698e..9ca7534738 100644
--- a/libs/web/luasrc/view/cbi/dynlist.htm
+++ b/libs/web/luasrc/view/cbi/dynlist.htm
@@ -13,40 +13,31 @@ $Id$
-%>
<%+cbi/valueheader%>
+<div>
<%
local vals = self:cfgvalue(section) or {}
for i=1, #vals + 1 do
local val = vals[i]
%>
- <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> />
- <% if i <= #vals then %>
- <input class="cbi-input-image" type="image" value="<%:Delete%>" name="cbi.rle.<%=section .. "." .. self.option .. "." .. i%>" alt="<%:Delete%>" title="<%:Delete%>" src="<%=resource%>/cbi/remove.gif" />
- <% else %>
- <input class="cbi-input-image" type="image" value="<%:Add%>" name="cbi.ale.<%=section .. "." .. self.option%>" alt="<%:Add%>" title="<%:Add%>" src="<%=resource%>/cbi/add.gif" />
- <% end %>
+ <input class="cbi-input-text" value="<%=pcdata(val)%>" onchange="cbi_d_update(this.id)" type="text"<%= attr("id", cbid .. "." .. i) .. attr("name", cbid) .. ifattr(self.size, "size")%> /><br />
+<% end %>
+</div>
+<script type="text/javascript">
+cbi_dynlist_init('<%=cbid%>');
+<% if self.datatype then -%>
<% if #self.keylist > 0 then -%>
- <script type="text/javascript">
- cbi_combobox_init('<%=cbid .. "." .. i%>', {
- <%-
- for i, k in ipairs(self.keylist) do
- -%>
- <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
- <%-if i<#self.keylist then-%>,<%-end-%>
- <%-
- end
- -%>
- }, '<%- if not self.rmempty and not self.optional then -%>
- <%-:cbi_select-%>
- <%- end -%>', '<%: -- custom -- %>');
- </script>
+ cbi_combobox_init('<%=cbid .. "." .. i%>', {
+ <%- for i, k in ipairs(self.keylist) do -%>
+ <%-=string.format("%q", k) .. ":" .. string.format("%q", self.vallist[i])-%>
+ <%-if i<#self.keylist then-%>,<%-end-%>
+ <%- end -%>
+ }, '<%- if not self.rmempty and not self.optional then -%>
+ <%-:cbi_select-%>
+ <%- end -%>', '<%: -- custom -- %>');
<% end -%>
-<% if i <= #vals then %><br />
-<% end end %>
-<% if self.datatype then -%>
- <script type="text/javascript">
- <% for i=1, #vals + 1 do -%>
- cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
- <%- end %>
- </script>
+ <% for i=1, #vals + 1 do -%>
+ cbi_validate_field('<%=cbid%>.<%=i%>', <%=tostring(self.optional == true or i > #vals)%>, '<%=self.datatype%>');
+ <%- end %>
<% end -%>
+</script>
<%+cbi/valuefooter%>
diff --git a/libs/web/luasrc/view/cbi/full_valuefooter.htm b/libs/web/luasrc/view/cbi/full_valuefooter.htm
index c069b7f92c..18b2f2d76e 100644
--- a/libs/web/luasrc/view/cbi/full_valuefooter.htm
+++ b/libs/web/luasrc/view/cbi/full_valuefooter.htm
@@ -14,7 +14,7 @@ $Id$
-%>
<% if self.description and #self.description > 0 then -%>
- <% if not luci.util.instanceof( self, luci.cbi.Flag ) or self.orientation == "horizontal" then -%>
+ <% if not luci.util.instanceof(self, luci.cbi.DynamicList) and (not luci.util.instanceof(self, luci.cbi.Flag) or self.orientation == "horizontal") then -%>
<br />
<%- end %>
<div class="cbi-value-description">