updating actions
This commit is contained in:
@@ -119,7 +119,7 @@ public class Contact extends Tile{
|
||||
@Override
|
||||
public Tile load(JSONObject json) {
|
||||
if (json.has(ADDRESS)) addr(json.getInt(ADDRESS));
|
||||
if (json.has(REALM_ACTIONS)) actions = ActionList.load(json.getJSONArray(REALM_ACTIONS));
|
||||
if (json.has(REALM_ACTIONS)) actions = new ActionList().load(json.getJSONArray(REALM_ACTIONS));
|
||||
return super.load(json);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class Contact extends Tile{
|
||||
button(t("learn"),Map.of(ACTION,ACTION_ANALYZE)).addTo(span);
|
||||
formInputs.add(t("Address"),span);
|
||||
|
||||
postForm.add(actions.properties());
|
||||
postForm.add(actions.list());
|
||||
return super.properties(preForm, formInputs, postForm);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.json.JSONObject;
|
||||
@@ -18,6 +19,7 @@ import de.srsoftware.web4rail.Window;
|
||||
import de.srsoftware.web4rail.tags.Fieldset;
|
||||
import de.srsoftware.web4rail.tags.Input;
|
||||
import de.srsoftware.web4rail.tags.Radio;
|
||||
import de.srsoftware.web4rail.tags.Select;
|
||||
|
||||
public class Relay extends Tile implements Device{
|
||||
public static final String STATE = "state";
|
||||
@@ -240,4 +242,16 @@ public class Relay extends Tile implements Device{
|
||||
public static Relay get(Id relayId) {
|
||||
return relays.get(relayId);
|
||||
}
|
||||
|
||||
public static Select selector(Relay preselected, Collection<Relay> exclude) {
|
||||
if (isNull(exclude)) exclude = new Vector<Relay>();
|
||||
Select select = new Select(Relay.class.getSimpleName());
|
||||
new Tag("option").attr("value","0").content(t("unset")).addTo(select);
|
||||
for (Relay relay : Relay.list()) {
|
||||
if (exclude.contains(relay)) continue;
|
||||
Tag opt = select.addOption(relay.id, relay);
|
||||
if (relay == preselected) opt.attr("selected", "selected");
|
||||
}
|
||||
return select;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user