minor changes

This commit is contained in:
Stephan Richter
2020-11-06 20:52:55 +01:00
parent 9fed18a517
commit d3ca0a08ef
11 changed files with 34 additions and 17 deletions

View File

@@ -33,6 +33,15 @@ public class ConditionalAction extends Action {
return actions;
}
private StringBuffer conditions() {
StringBuffer sb = new StringBuffer();
for (int i = 0; i<conditions.size(); i++) {
if (i>0) sb.append(t(" or "));
sb.append(conditions.get(i).toString());
}
return sb;
}
private Tag conditionForm(HashMap<String, String> params) {
Fieldset fieldset = new Fieldset(t("Conditions"));
@@ -53,6 +62,10 @@ public class ConditionalAction extends Action {
Condition.selector().addTo(form);
return new Button(t("Add condition"),form).addTo(form).addTo(fieldset);
}
public boolean equals(ConditionalAction other) {
return (conditions()+":"+actions).equals(other.conditions()+":"+other.actions);
}
@Override
public boolean fire(Context context) throws IOException {
@@ -97,12 +110,7 @@ public class ConditionalAction extends Action {
@Override
public String toString() {
if (conditions.isEmpty()) return t("[Click here to add condition]");
StringBuffer sb = new StringBuffer();
for (int i = 0; i<conditions.size(); i++) {
if (i>0) sb.append(t(" or "));
sb.append(conditions.get(i).toString());
}
return t("if ({}): {}",sb,actions);
return t("if ({}):",conditions());
}
@Override