Integrated summary bar preset buttons into main edit form as restore buttons

This commit is contained in:
str4d
2012-07-08 22:11:05 +00:00
parent fb629404c6
commit bb39d9ddcf
3 changed files with 14 additions and 28 deletions

View File

@ -38,18 +38,14 @@ public class ConfigSummaryHandler extends FormHandler {
addFormError(_("Refresh interval must be a number")); addFormError(_("Refresh interval must be a number"));
return; return;
} }
} else if ("1".equals(group)) { } else if (_action.equals(_("Restore full default"))) {
if (_action.equals(_("Use full preset"))) { _context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_FULL);
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.PRESET_FULL); addFormNotice(_("Full summary bar default restored.") + " " +
addFormNotice(_("Full summary bar preset selected.") + " " + _("Summary bar will refresh shortly."));
_("Summary bar will refresh shortly.")); } else if (_action.equals(_("Restore minimal default"))) {
} else if (_action.equals(_("Use reduced preset"))) { _context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.DEFAULT_MINIMAL);
_context.router().saveConfig(SummaryHelper.PROP_SUMMARYBAR + "default", SummaryHelper.PRESET_SHORT); addFormNotice(_("Minimal summary bar default restored.") + " " +
addFormNotice(_("Reduced summary bar preset selected.") + " " + _("Summary bar will refresh shortly."));
_("Summary bar will refresh shortly."));
} else {
addFormError(_("Unsupported"));
}
} else if (adding || deleting || saving) { } else if (adding || deleting || saving) {
Map<Integer, String> sections = new TreeMap<Integer, String>(); Map<Integer, String> sections = new TreeMap<Integer, String>();
for (Object o : _settings.keySet()) { for (Object o : _settings.keySet()) {

View File

@ -42,7 +42,7 @@ public class SummaryHelper extends HelperBase {
private static final char S = ','; private static final char S = ',';
static final String PROP_SUMMARYBAR = "routerconsole.summaryBar."; static final String PROP_SUMMARYBAR = "routerconsole.summaryBar.";
static final String PRESET_FULL = static final String DEFAULT_FULL =
"HelpAndFAQ" + S + "HelpAndFAQ" + S +
"I2PServices" + S + "I2PServices" + S +
"I2PInternals" + S + "I2PInternals" + S +
@ -59,7 +59,7 @@ public class SummaryHelper extends HelperBase {
"Destinations" + S + "Destinations" + S +
""; "";
static final String PRESET_SHORT = static final String DEFAULT_MINIMAL =
"ShortGeneral" + S + "ShortGeneral" + S +
"NewsHeadings" + S + "NewsHeadings" + S +
"UpdateStatus" + S + "UpdateStatus" + S +
@ -749,11 +749,11 @@ public class SummaryHelper extends HelperBase {
public List<String> getSummaryBarSections(String page) { public List<String> getSummaryBarSections(String page) {
String config = ""; String config = "";
if ("home".equals(page)) if ("home".equals(page))
config = _context.getProperty(PROP_SUMMARYBAR + page, PRESET_SHORT); config = _context.getProperty(PROP_SUMMARYBAR + page, DEFAULT_MINIMAL);
else else
config = _context.getProperty(PROP_SUMMARYBAR + page, null); config = _context.getProperty(PROP_SUMMARYBAR + page, null);
if (config == null) if (config == null)
config = _context.getProperty(PROP_SUMMARYBAR + "default", PRESET_FULL); config = _context.getProperty(PROP_SUMMARYBAR + "default", DEFAULT_FULL);
return Arrays.asList(config.split("" + S)); return Arrays.asList(config.split("" + S));
} }

View File

@ -46,18 +46,6 @@ input.default {
<input type="submit" name="action" class="accept" value="<%=intl._("Save")%>" > <input type="submit" name="action" class="accept" value="<%=intl._("Save")%>" >
</form> </form>
<h3><%=intl._("Use preset layout")%></h3>
<p><%=intl._("Several preset layouts for the summary bar are available.")%>
<%=intl._("Note that choosing one of the presets will cause the current summary bar configuration to be lost.")%></p>
<hr><div class="formaction">
<form action="" method="POST">
<input type="hidden" name="nonce" value="<%=pageNonce%>" >
<input type="hidden" name="group" value="1">
<input type="submit" class="reload" name="action" value="<%=intl._("Use full preset")%>" >
<input type="submit" class="reload" name="action" value="<%=intl._("Use reduced preset")%>" >
</form>
</div>
<h3><%=intl._("Customise Summary Bar")%></h3> <h3><%=intl._("Customise Summary Bar")%></h3>
<form action="" method="POST"> <form action="" method="POST">
<input type="hidden" name="nonce" value="<%=pageNonce%>" > <input type="hidden" name="nonce" value="<%=pageNonce%>" >
@ -65,6 +53,8 @@ input.default {
<jsp:getProperty name="summaryhelper" property="configTable" /> <jsp:getProperty name="summaryhelper" property="configTable" />
<div class="formaction"> <div class="formaction">
<input type="submit" name="action" class="default" value="<%=intl._("Add item")%>" > <input type="submit" name="action" class="default" value="<%=intl._("Add item")%>" >
<input type="submit" class="reload" name="action" value="<%=intl._("Restore full default")%>" >
<input type="submit" class="reload" name="action" value="<%=intl._("Restore minimal default")%>" >
<input type="submit" name="action" class="delete" value="<%=intl._("Delete selected")%>" > <input type="submit" name="action" class="delete" value="<%=intl._("Delete selected")%>" >
<input type="reset" class="cancel" value="<%=intl._("Cancel")%>" > <input type="reset" class="cancel" value="<%=intl._("Cancel")%>" >
<input type="submit" name="action" class="reload" value="<%=intl._("Save order")%>" > <input type="submit" name="action" class="reload" value="<%=intl._("Save order")%>" >