Commit 30d8fbce authored by Jerome Mariette's avatar Jerome Mariette

handle exclude from gui

parent 2fdab0b4
......@@ -120,7 +120,8 @@ class JFlowServer (object):
"action": param.action,
"type": param.get_type(),
"name": param.name,
"display_name": param.display_name}
"display_name": param.display_name,
"group": param.group}
parameters.append(hash_param)
if parameters_per_groups.has_key(param.group):
parameters_per_groups[param.group].append(hash_param)
......
......@@ -64,6 +64,23 @@
errorClass: "help-block error"
});
jQuery.validator.addMethod("exlude", function(value, element, options) {
var validator = this,
selector = options;
var numberFilled = $(selector, element.form).filter(function() {
return validator.elementValue(this);
}).length;
var valid = numberFilled === 1;
if(!$(element).data('being_validated')) {
var fields = $(selector, element.form);
fields.data('being_validated', true);
fields.valid();
fields.data('being_validated', false);
}
return valid;
}, jQuery.format("Please fill only one of these fields."));
!function ($) {
"use strict"; // jshint ;_;
......@@ -180,6 +197,9 @@
}
}
}
if ($this.workflow.parameters[i].group.indexOf("exclude-") != -1) {
rules[$this.workflow.parameters[i].name]["exlude"] = "."+$this.workflow.parameters[i].group;
}
}
$("#workflow_form").validate({ rules: rules });
if ($this.options.displayRunButton) {
......@@ -221,14 +241,14 @@
// it the parameter has not already been settled
' {{if Object.keys(parameters).indexOf(param.name) == -1 }}',
' <div class="control-group">',
' {{if group != "default" && index == 0}}',
' <legend>${group}</legend>',
' {{if group != "default" && group.indexOf("exclude-") != 0 && index == 0}}',
' <legend>${param.group}</legend>',
' {{/if}}',
' <label class="control-label">${param.display_name}</label>',
' <div class="controls">',
// if it's a multiple choice parameter, add a select
' {{if param.choices}}',
' <select id="${param.name}" name="${param.name}" class="input-xlarge">',
' <select id="${param.name}" name="${param.name}" class="${param.group} input-xlarge">',
' {{each(j, choice) param.choices}}',
' {{if choice == param.default}}',
' <option selected>${choice}</option>',
......@@ -240,28 +260,28 @@
// if param is a date
' {{else param.type == "date"}}',
' <div class="input-append date" data-date="${param.default}" data-date-format="dd/mm/yyyy">',
' <input id="${param.name}" name="${param.name}" class="input-xlarge span2" type="text" value="${param.default}">',
' <input id="${param.name}" name="${param.name}" class="${param.group} input-xlarge span2" type="text" value="${param.default}">',
' <button class="btn" type="button"><i class="icon-calendar"></i></button>',
' </div>',
// if param is a boolean
' {{else param.type == "bool"}}',
' <label class="checkbox">',
' {{if param.default == true}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox" checked>',
' <input id="${param.name}" name="${param.name}" class="${param.group}" value="${param.default}" type="checkbox" checked>',
' {{else}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" type="checkbox">',
' <input id="${param.name}" name="${param.name}" class="${param.group}" value="${param.default}" type="checkbox">',
' {{/if}}',
' </label>',
// else a simple text input
' {{else}}',
' <input id="${param.name}" name="${param.name}" value="${param.default}" class="input-xlarge" type="text">',
' <input id="${param.name}" name="${param.name}" value="${param.default}" class="${param.group} input-xlarge" type="text">',
' {{/if}}',
' <span class="help-block">${param.help}</span>',
' </div>',
' </div>',
' {{else}}',
// if the param is already settled, hide it
' <input id="${param.name}" name="${param.name}" value="${parameters[param.name]}" type="hidden">',
' <input id="${param.name}" name="${param.name}" class="${param.group}" value="${parameters[param.name]}" type="hidden">',
' {{/if}}',
' {{/each}}',
' {{/each}}',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment