refurbishing route.save

This commit is contained in:
Stephan Richter
2020-10-30 10:04:38 +01:00
parent 4441b012fa
commit 38ee7b5e12
11 changed files with 108 additions and 47 deletions

View File

@@ -48,6 +48,10 @@ public abstract class Condition implements Constants {
return t("Unknown action: {}",action);
}
public JSONObject json() {
return new JSONObject().put(TYPE, getClass().getSimpleName());
}
public Tag link(String tagClass,String context) {
String json = new JSONObject(Map.of(REALM,REALM_CONDITION,ID,id,ACTION,ACTION_PROPS,CONTEXT,context)).toString().replace("\"", "'");
return new Tag(tagClass).clazz("link").attr("onclick","request("+json+")").content(toString());

View File

@@ -2,6 +2,8 @@ package de.srsoftware.web4rail.conditions;
import java.util.HashMap;
import org.json.JSONObject;
import de.srsoftware.web4rail.Window;
import de.srsoftware.web4rail.actions.Action.Context;
import de.srsoftware.web4rail.moving.Train;
@@ -20,6 +22,11 @@ public class TrainSelect extends Condition {
return context.train == train;
}
@Override
public JSONObject json() {
return super.json().put(REALM_TRAIN, train.id);
}
@Override
protected Window properties(HashMap<String, String> params) {
Window win = new Window("condition-props", t("Properties of {}",getClass().getSimpleName()));