lib/cbi: Added support for multiple CBI maps per model
authorSteven Barth <redacted>
Tue, 15 Jul 2008 13:17:28 +0000 (13:17 +0000)
committerSteven Barth <redacted>
Tue, 15 Jul 2008 13:17:28 +0000 (13:17 +0000)
libs/cbi/luasrc/cbi.lua
libs/web/luasrc/dispatcher.lua
modules/admin-mini/luasrc/controller/mini/index.lua [moved from modules/admin-mini/luasrc/controller/index.lua with 100% similarity]

index 6e08455655f12e09f6c79dc100985775c083f6bd..7370a04c46a0858468b7e7f6d85fbb66d2582415 100644 (file)
@@ -57,14 +57,16 @@ function load(cbimap)
        luci.util.extfenv(func, "translate", luci.i18n.translate)
        luci.util.extfenv(func, "translatef", luci.i18n.translatef)
 
-       local map = func()
+       local maps = {func()}
 
-       if not instanceof(map, Map) then
-               error("CBI map returns no valid map object!")
-               return nil
+       for i, map in ipairs(maps) do
+               if not instanceof(map, Map) then
+                       error("CBI map returns no valid map object!")
+                       return nil
+               end
        end
 
-       return map
+       return maps
 end
 
 -- Node pseudo abstract class
index 689d060d528273a5227c69362b09e46f76b58ca5..735e2a7150c6e6bb28255217882e989ef0d15056 100644 (file)
@@ -381,20 +381,24 @@ function cbi(model)
        require("luci.template")
 
        return function()
-               local stat, res = luci.util.copcall(luci.cbi.load, model)
+               local stat, maps = luci.util.copcall(luci.cbi.load, model)
                if not stat then
-                       error500(res)
+                       error500(maps)
                        return true
                end
 
-               local stat, err = luci.util.copcall(res.parse, res)
-               if not stat then
-                       error500(err)
-                       return true
+               for i, res in ipairs(maps) do
+                       local stat, err = luci.util.copcall(res.parse, res)
+                       if not stat then
+                               error500(err)
+                               return true
+                       end
                end
 
                luci.template.render("cbi/header")
-               res:render()
+               for i, res in ipairs(maps) do
+                       res:render()
+               end
                luci.template.render("cbi/footer")
        end
 end
git clone https://git.99rst.org/PROJECT