RAPPEL : Opération de maintenance > ForgeMIA indisponible le 20 Janvier entre 7h et 12h

Commit fc6390a5 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

ActivatedIf rule => DisabledIf rule

parent ad071bc6
......@@ -154,10 +154,10 @@
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- Production version
<!-- Production version-->
<script src='js/jflow.min.js' type='text/javascript'></script>
<!-- development version-->
<!-- development version
<script src='js/jquery.tmpl.min.js' type='text/javascript'></script>
<script src='js/jquery.validate.js' type='text/javascript'></script>
<script src="js/jquery.ui.widget.js"></script>
......@@ -178,7 +178,7 @@
<script src='js/jflow-wfform-rules.js' type='text/javascript'></script>
<script src='js/jflow-wfform.js' type='text/javascript'></script>
<script src='js/jflow-wfstatus.js' type='text/javascript'></script>
<script src="js/bootstrap-datepicker.js"></script>
<script src="js/bootstrap-datepicker.js"></script>-->
<script type='text/javascript'>
......
......@@ -311,8 +311,8 @@ class MyWorkflow (Workflow):
<em>Syntax: RequiredIf?(ANY|ALL)[param_1=value1,param_2!=value2,...] (all conditions or any condition)</em><br/>
Special values: * for any value of the parameter (not empty), None for not given (or empty)<br/>
Example: RequiredIf?ANY[adapter_1!="AATGC",adapter_2=*,gtf_file=None]</li>
<li><strong>ActivateIf:</strong> parameter is enabled only if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>ActivateIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
<li><strong>DisabledIf:</strong> parameter is disabled if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>DisabledIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
</ul>
</td>
</tr>
......@@ -480,8 +480,8 @@ class MyWorkflow (Workflow):
<em>Syntax: RequiredIf?(ANY|ALL)[param_1=value1,param_2!=value2,...] (all conditions or any condition)</em><br/>
Special values: * for any value of the parameter (not empty), None for not given (or empty)<br/>
Example: RequiredIf?ANY[adapter_1!="AATGC",adapter_2=*,gtf_file=None]</li>
<li><strong>ActivateIf:</strong> parameter is enabled only if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>ActivateIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
<li><strong>DisabledIf:</strong> parameter is disabled if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>DisabledIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
</ul>
</td>
</tr>
......@@ -631,8 +631,8 @@ class MyWorkflow(Workflow):
<em>Syntax: RequiredIf?(ANY|ALL)[param_1=value1,param_2!=value2,...] (all conditions or any condition)</em><br/>
Special values: * for any value of the parameter (not empty), None for not given (or empty)<br/>
Example: RequiredIf?ANY[adapter_1!="AATGC",adapter_2=*,gtf_file=None]</li>
<li><strong>ActivateIf:</strong> parameter is enabled only if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>ActivateIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
<li><strong>DisabledIf:</strong> parameter is disabled if other parameters have some values.<br/>
<em>Syntax (like RequiredIf rule):<br/></br:>DisabledIf?(ANY|ALL)[param_1=value1,param_2=value2,...]</em> (all conditions or any condition)</li>
</ul>
</td>
</tr>
......
......@@ -98,6 +98,7 @@ class ConditionalRule(SimpleRule):
# Test condition is raised:
self.condition_raised = False
self.condition_raised_name = ""
all_raised = True
for condition in self.conditions:
c_match = re.match(r"([\w>]+)(!)?=(.+)", condition)
......@@ -106,14 +107,13 @@ class ConditionalRule(SimpleRule):
name_arg = self.parameter_name
test_val = c_match.group(3)
is_equal = c_match.group(2) is None
#TODO: considère-t-on que si on a un !valeur, si le paramètre en question pas définit => condition is raised ?
#MA REPONSE : si on a !=* oui (et c'est déjà codé), sinon non
if name_arg in self.user_args:
if (not is_equal and str(self.user_args[name_arg]) != str(test_val[1:])) or (is_equal and
str(self.user_args[name_arg]) == str(test_val)) or (is_equal and test_val == "*" and
len(str(self.user_args[name_arg])) > 0):
if which == "ANY":
self.condition_raised = True
self.condition_raised_name = condition
break
elif which == "ALL":
all_raised = False
......@@ -121,12 +121,14 @@ class ConditionalRule(SimpleRule):
elif is_equal and test_val == "None":
if which == "ANY":
self.condition_raised = True
self.condition_raised_name = condition
break
elif which == "ALL":
all_raised = False
if which == "ALL" and all_raised:
self.condition_raised = True
self.condition_raised_name = " & ".join(conditions)
@abstractmethod
def check(self):
......@@ -146,7 +148,7 @@ class Exclude(LinkRule):
def check(self):
for exclude in self.targets_args:
if exclude in self.user_args and self.user_args[exclude] is not None: # The target is found
self.error("arguments " + self.parameter_name + " and " + exclude + " are mutually excluded")
self.error("Parameters " + self.parameter_name + " and " + exclude + " are mutually excluded")
class ToBeRequired(LinkRule):
......@@ -158,7 +160,7 @@ class ToBeRequired(LinkRule):
for require in self.targets_args:
if require not in self.user_args or (require in self.user_args and self.user_args[require] is None): # The
# target is not found
self.error("the argument " + self.parameter_name + " require argument " + require +
self.error("Parameter " + self.parameter_name + " require parameter " + require +
" to be defined")
......@@ -170,19 +172,19 @@ class RequiredIf(ConditionalRule):
def check(self):
if self.condition_raised:
if self.parameter_name not in self.user_args or not self.user_args[self.parameter_name]:
self.error("Argument " + self.parameter_name + " is required, due to it's required rule")
self.error("Parameter " + self.parameter_name + " is required because: " + self.condition_raised_name)
class ActivatedIf(ConditionalRule):
class DisabledIf(ConditionalRule):
"""
The parameter is enabled only if other parameters have, or have not, some values
"""
def check(self):
if not self.condition_raised and self.parameter_name in self.user_args and \
if self.condition_raised and self.parameter_name in self.user_args and \
self.user_args[self.parameter_name] is not None and \
str(self.user_args[self.parameter_name]) != str(self.wf_instance.__dict__[self.parameter_name].default):
self.error("Argument " + self.parameter_name + " is not available, due to it's activate rule")
self.error("Parameter " + self.parameter_name + " is not available, because: " + self.condition_raised_name)
class FilesUnique(SimpleRule):
......
......@@ -224,7 +224,7 @@
var ruleExclude = /Exclude=(.+)/;
var ruleToBeRequired = /ToBeRequired=(.+)/;
var ruleRequiredIf = /RequiredIf\?(ANY|ALL)\[(.+)\]/;
var ruleActivatedIf = /ActivatedIf\?(ANY|ALL)\[(.+)\]/;
var ruleDisabledIf = /DisabledIf\?(ANY|ALL)\[(.+)\]/;
var match;
/**
......@@ -319,18 +319,18 @@
}
}
var __check_activated = function() {
var __check_disabled = function() {
var condition_raised = _check_condition_raised(conditions_params, which);
if (condition_raised) {
param_input.closest("div.form-group").removeClass("hidden-exclude").show();
param_input.removeClass("hidden-exclude");
}
else {
param_input.closest("div.form-group").addClass("hidden-exclude").hide();
param_input.addClass("hidden-exclude");
}
else {
param_input.closest("div.form-group").removeClass("hidden-exclude").show();
param_input.removeClass("hidden-exclude");
}
if (param_input.closest("fieldset").find(".param-field").not(".hidden-exclude").length == 0) {
param_input.closest("fieldset").hide();
}
......@@ -403,14 +403,14 @@
__required_targets(param_input, targets);
}
//Check rule ActivatedIf
else if (match = rule.match(ruleActivatedIf)) {
//Check rule DisabledIf
else if (match = rule.match(ruleDisabledIf)) {
which = match[1]
conditions = match[2].split(",");
conditions_params = __get_conditions_params();
param_input = $("#" + parameter_name);
_add_event(__check_activated, Object.keys(conditions_params), $this);
__check_activated();
_add_event(__check_disabled, Object.keys(conditions_params), $this);
__check_disabled();
}
//Check rule RequiredIf
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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