mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-19 05:58:34 +02:00
A parameter can now specifify a visibility rule (based on another field value).
see #170
This commit is contained in:
@@ -21,6 +21,7 @@ parameters.register_admin("MAILBOX_TYPE", type="list", deflt="maildir",
|
||||
values=[("maildir", "maildir"), ("mbox", "mbox")],
|
||||
help=ugettext_lazy("Mailboxes storage format"))
|
||||
parameters.register_admin("MAILDIR_ROOT", type="string", deflt=".maildir",
|
||||
visible_if="MAILBOX_TYPE=maildir",
|
||||
help=ugettext_lazy("Sub-directory (inside the mailbox) where messages are stored when using the maildir format"))
|
||||
parameters.register_admin(
|
||||
"PASSWORD_SCHEME", type="list", deflt="md5crypt",
|
||||
|
||||
@@ -49,15 +49,15 @@ def settings_menu(selection, user):
|
||||
"url" : "extensions/",
|
||||
"label" : _("Extensions"),
|
||||
"img" : ""},
|
||||
{"name" : "info",
|
||||
"class" : "ajaxlink",
|
||||
"url" : "info/",
|
||||
"label" : _("Information")},
|
||||
{"name" : "parameters",
|
||||
"class" : "ajaxlink",
|
||||
"url" : "parameters/",
|
||||
"img" : "",
|
||||
"label" : _("Parameters")},
|
||||
{"name" : "info",
|
||||
"class" : "ajaxlink",
|
||||
"url" : "info/",
|
||||
"label" : _("Information")}
|
||||
]
|
||||
return render_to_string('common/menu.html', {
|
||||
"entries" : entries,
|
||||
@@ -201,10 +201,16 @@ def param(app, definition):
|
||||
value = definition.has_key("value") \
|
||||
and definition["value"] or definition["deflt"]
|
||||
|
||||
result = """<div class='control-group'>
|
||||
extratags = ""
|
||||
if "visible_if" in definition:
|
||||
vfield, vvalue = definition["visible_if"].split("=")
|
||||
extratags = "data-visibility-field='%s.%s' data-visibility-value='%s'" \
|
||||
% (app, vfield, vvalue)
|
||||
|
||||
result = """<div class='control-group'%s>
|
||||
<label class="param-label" for="%s">%s</label>
|
||||
<div class="param-controls">""" \
|
||||
% (name, definition.has_key("label") and _(definition["label"])
|
||||
% (extratags, name, definition.has_key("label") and _(definition["label"])
|
||||
or definition["name"])
|
||||
if definition["type"] in ["string", "int"]:
|
||||
result += """
|
||||
|
||||
@@ -493,8 +493,9 @@ def viewparameters(request, tplname='admin/parameters.html'):
|
||||
"help" : param_def["help"],
|
||||
"default" : param_def["deflt"],
|
||||
"type" : param_def["type"]}
|
||||
if "values" in param_def.keys():
|
||||
newdef["values"] = param_def["values"]
|
||||
for k in ["values", "visible_if"]:
|
||||
if k in param_def.keys():
|
||||
newdef[k] = param_def[k]
|
||||
tmp["params"] += [newdef]
|
||||
gparams += [tmp]
|
||||
|
||||
|
||||
@@ -54,12 +54,15 @@ class Amavis(ModoExtension):
|
||||
help=ugettext_lazy("Mode used to access the PDP server"))
|
||||
parameters.register_admin("AM_PDP_HOST", type="string",
|
||||
deflt="localhost",
|
||||
visible_if="AM_PDP_MODE=inet",
|
||||
help=ugettext_lazy("PDP server address (if inet mode)"))
|
||||
parameters.register_admin("AM_PDP_PORT", type="int",
|
||||
deflt=9998,
|
||||
visible_if="AM_PDP_MODE=inet",
|
||||
help=ugettext_lazy("PDP server port (if inet mode)"))
|
||||
parameters.register_admin("AM_PDP_SOCKET", type="string",
|
||||
deflt="/var/amavis/amavisd.sock",
|
||||
visible_if="AM_PDP_MODE=unix",
|
||||
help=ugettext_lazy("Path to the PDP server socket (if unix mode)"))
|
||||
parameters.register_admin("CHECK_REQUESTS_INTERVAL", type="int",
|
||||
deflt=30,
|
||||
|
||||
@@ -37,7 +37,22 @@ TwocolsNav.prototype = {
|
||||
if (data.onload_cb) {
|
||||
eval(data.onload_cb + '()');
|
||||
}
|
||||
$('#' + this.options.divid + ' select').change($.proxy(this.select_change, this));
|
||||
$(".help").popover().click(function(e) {e.preventDefault();});
|
||||
$('#' + this.options.divid + ' select').change();
|
||||
},
|
||||
|
||||
select_change: function(e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
$('div[data-visibility-field="' + $target.attr("id") + '"]').each(function(idx) {
|
||||
var $this = $(this);
|
||||
if ($this.attr("data-visibility-value") == $target.attr("value")) {
|
||||
$this.show();
|
||||
} else {
|
||||
$this.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
save_cb: function(data) {
|
||||
|
||||
Reference in New Issue
Block a user