summaryrefslogtreecommitdiffhomepage
path: root/libs/web/luasrc/cbi.lua
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2011-01-20 00:01:55 +0000
committerJo-Philipp Wich <jow@openwrt.org>2011-01-20 00:01:55 +0000
commit80e1900b03b2a5315c791f9240f9d7641ae67562 (patch)
tree15a05c8a7cfc6f251cf58589f4aa243260979807 /libs/web/luasrc/cbi.lua
parentc176c70d5bfec1061f894c31dd6f2fd826c2d8cf (diff)
libs/web: implement sortable rows for uci reordering
Diffstat (limited to 'libs/web/luasrc/cbi.lua')
-rw-r--r--libs/web/luasrc/cbi.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/libs/web/luasrc/cbi.lua b/libs/web/luasrc/cbi.lua
index f4bf18d1e..8bb3488a7 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