summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/web/luasrc')
-rw-r--r--libs/web/luasrc/cbi.lua15
-rw-r--r--libs/web/luasrc/view/cbi/tblsection.htm10
2 files changed, 25 insertions, 0 deletions
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua
index f4bf18d1e7..8bb3488a70 100644
--- a/libs/web/luasrc/cbi.lua
+++ b/libs/web/luasrc/cbi.lua
@@ -50,6 +50,7 @@ AUTO = true
CREATE_PREFIX = "cbi.cts."
REMOVE_PREFIX = "cbi.rts."
+RESORT_PREFIX = "cbi.sts."
-- Loads a CBI map from given file, creating an environment and returns it
function load(cbimap, ...)
@@ -1121,6 +1122,20 @@ function TypedSection.parse(self, novld)
end
end
+ if self.sortable then
+ local stval = RESORT_PREFIX .. self.config .. "." .. self.sectiontype
+ local order = self.map:formvalue(stval)
+ if order and #order > 0 then
+ local sid
+ local num = 0
+ for sid in util.imatch(order) do
+ self.map.uci:reorder(self.config, sid, num)
+ num = num + 1
+ end
+ self.changed = (num > 0)
+ end
+ end
+
if created or self.changed then
self:push_events()
end
diff --git a/libs/web/luasrc/view/cbi/tblsection.htm b/libs/web/luasrc/view/cbi/tblsection.htm
index 7428175838..c79d5a8c87 100644
--- a/libs/web/luasrc/view/cbi/tblsection.htm
+++ b/libs/web/luasrc/view/cbi/tblsection.htm
@@ -35,6 +35,9 @@ end
<% if self.title and #self.title > 0 then -%>
<legend><%=self.title%></legend>
<%- end %>
+ <%- if self.sortable then -%>
+ <input type="hidden" id="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" name="cbi.sts.<%=self.config%>.<%=self.sectiontype%>" value="" />
+ <%- end -%>
<div class="cbi-section-descr"><%=self.description%></div>
<div class="cbi-section-node">
<%- local count = 0 -%>
@@ -91,6 +94,13 @@ end
end
-%>
+ <%- if self.sortable then -%>
+ <td class="cbi-section-table-cell" style="width:50px">
+ <a href="#" onclick="return cbi_row_swap(this, true, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move up%>"><img src="<%=resource%>/cbi/up.gif" alt="<%:Move up%>" /></a>
+ <a href="#" onclick="return cbi_row_swap(this, false, 'cbi.sts.<%=self.config%>.<%=self.sectiontype%>')" title="<%:Move down%>"><img src="<%=resource%>/cbi/down.gif" alt="<%:Move down%>" /></a>
+ </td>
+ <%- end -%>
+
<%- if self.extedit or self.addremove then -%>
<td class="cbi-section-table-cell" style="width:50px">
<%- if self.extedit then -%>