modules: Redesigned configuration save, apply, save & apply menu options

This commit is contained in:
Steven Barth 2008-07-29 15:33:28 +00:00
parent 43ffb3aacb
commit f8f4fe7523
10 changed files with 25 additions and 23 deletions

View file

@ -4,4 +4,3 @@ cbi_invalid = "Error: Invalid input value"
cbi_addopt = "-- Additional Field --" cbi_addopt = "-- Additional Field --"
cbi_optional = " (optional)" cbi_optional = " (optional)"
cbi_sectempty = "This section contains no values yet" cbi_sectempty = "This section contains no values yet"
cbi_saveapply = "Save & Apply"

View file

@ -77,6 +77,7 @@ reset = "Reset"
revert = "Revert" revert = "Revert"
save = "Save" save = "Save"
saveapply = "Save & Apply"
service = "Service" service = "Service"
services = "Services" services = "Services"
settings = "Settings" settings = "Settings"

View file

@ -3,4 +3,3 @@ cbi_del = "Eintrag entfernen"
cbi_invalid = "Error: Ungültige Eingabe" cbi_invalid = "Error: Ungültige Eingabe"
cbi_addopt = "-- Zusätzliches Feld --" cbi_addopt = "-- Zusätzliches Feld --"
cbi_sectempty = "Diese Sektion enthält noch keine Einträge" cbi_sectempty = "Diese Sektion enthält noch keine Einträge"
cbi_saveapply = "Speichern & Anwenden"

View file

@ -78,6 +78,7 @@ reset = "Zurücksetzen"
revert = "Verwerfen" revert = "Verwerfen"
save = "Speichern" save = "Speichern"
saveapply = "Speichern & Anwenden"
service = "Dienst" service = "Dienst"
services = "Dienste" services = "Dienste"
settings = "Einstellungen" settings = "Einstellungen"

View file

@ -14,7 +14,7 @@ $Id$
-%> -%>
<div> <div>
<input type="submit" name="cbi.apply" value="<%:cbi_saveapply%>" /> <input type="submit" name="cbi.apply" value="<%:saveapply%>" />
<input type="submit" value="<%:save%>" /> <input type="submit" value="<%:save%>" />
<input type="reset" value="<%:reset%>" /> <input type="reset" value="<%:reset%>" />
<script type="text/javascript">cbi_d_init();</script> <script type="text/javascript">cbi_d_init();</script>

View file

@ -17,9 +17,10 @@ function index()
local i18n = luci.i18n.translate local i18n = luci.i18n.translate
entry({"admin", "uci"}, nil, i18n("config")) entry({"admin", "uci"}, nil, i18n("config"))
entry({"admin", "uci", "changes"}, call("action_changes"), i18n("changes")) entry({"admin", "uci", "changes"}, call("action_changes"), i18n("changes"), 40)
entry({"admin", "uci", "revert"}, call("action_revert"), i18n("revert")) entry({"admin", "uci", "revert"}, call("action_revert"), i18n("revert"), 30)
entry({"admin", "uci", "apply"}, call("action_apply"), i18n("apply")) entry({"admin", "uci", "apply"}, call("action_apply"), i18n("apply"), 20)
entry({"admin", "uci", "saveapply"}, call("action_apply"), i18n("saveapply"), 10)
end end
function convert_changes(changes) function convert_changes(changes)
@ -52,6 +53,7 @@ function action_changes()
end end
function action_apply() function action_apply()
local path = luci.dispatcher.context.path
local changes = luci.model.uci.changes() local changes = luci.model.uci.changes()
local output = "" local output = ""
@ -62,9 +64,11 @@ function action_apply()
-- Collect files to be applied and commit changes -- Collect files to be applied and commit changes
for r, tbl in pairs(changes) do for r, tbl in pairs(changes) do
if r then if r then
luci.model.uci.load(r) if path[#path] ~= "apply" then
luci.model.uci.commit(r) luci.model.uci.load(r)
luci.model.uci.unload(r) luci.model.uci.commit(r)
luci.model.uci.unload(r)
end
if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then
run[luci.config.uci_oncommit[r]] = true run[luci.config.uci_oncommit[r]] = true
end end

View file

@ -20,6 +20,9 @@ $Id$
<form class="inline" method="get" action="<%=controller%>/admin/uci/apply"> <form class="inline" method="get" action="<%=controller%>/admin/uci/apply">
<input type="submit" value="<%:apply%>" /> <input type="submit" value="<%:apply%>" />
</form> </form>
<form class="inline" method="get" action="<%=controller%>/admin/uci/saveapply">
<input type="submit" value="<%:saveapply%>" />
</form>
<form class="inline" method="get" action="<%=controller%>/admin/uci/revert"> <form class="inline" method="get" action="<%=controller%>/admin/uci/revert">
<input type="submit" value="<%:revert%>" /> <input type="submit" value="<%:revert%>" />
</form> </form>

View file

@ -18,9 +18,9 @@ function index()
local i18n = luci.i18n.translate local i18n = luci.i18n.translate
entry({"mini", "uci"}, nil, i18n("config")) entry({"mini", "uci"}, nil, i18n("config"))
entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes")) entry({"mini", "uci", "changes"}, call("action_changes"), i18n("changes"), 30)
entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert")) entry({"mini", "uci", "revert"}, call("action_revert"), i18n("revert"), 20)
entry({"mini", "uci", "apply"}, call("action_apply"), i18n("apply")) entry({"mini", "uci", "apply"}, call("action_apply"), i18n("saveapply"), 10)
end end
function convert_changes(changes) function convert_changes(changes)

View file

@ -146,15 +146,13 @@ end
end end
%> %>
<div><%:config%> <div><%:config%>
<ul>
<% if ucic > 0 then %> <% if ucic > 0 then %>
<li><a href="<%=controller%>/admin/uci/changes"><%:changes%>: <%=ucic%></a></li> <% submenu(category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
<li><a href="<%=controller%>/admin/uci/apply"><%:apply%></a></li>
<li><a href="<%=controller%>/admin/uci/revert"><%:revert%></a></li>
<% else %> <% else %>
<li><%:changes%>: 0</li> <ul>
<li><%:changes%>: 0</li>
</ul>
<% end %> <% end %>
</ul>
</div> </div>
<% end %> <% end %>
</div> </div>

View file

@ -174,10 +174,7 @@ end
<div> <div>
<% if ucic > 0 then %> <% if ucic > 0 then %>
<a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:unsavedchanges%>: <%=ucic%></a> <a class="warning" href="<%=controller%>/<%=category%>/uci/changes"><%:unsavedchanges%>: <%=ucic%></a>
<ul> <% submenu(category .. "/uci/", tree.nodes[category].nodes["uci"]) -%>
<li><a href="<%=controller%>/<%=category%>/uci/apply"><%:apply%></a></li>
<li><a href="<%=controller%>/<%=category%>/uci/revert"><%:revert%></a></li>
</ul>
<% else %> <% else %>
<a href="#"><%:changes%>: 0</a> <a href="#"><%:changes%>: 0</a>
<% end %> <% end %>