package foundation.capacity.role;
|
|
import foundation.data.entity.Entity;
|
import foundation.json.IJSONProvider;
|
import foundation.json.IJSONWriter;
|
import foundation.page.Button;
|
|
public class RoleButton implements IJSONProvider {
|
|
private Button button;
|
private boolean visible;
|
private boolean active;
|
|
public RoleButton(Button button) {
|
this.button = button;
|
}
|
|
public void load(Entity entity) {
|
visible = entity.getBoolean("is_visible", false);
|
active = entity.getBoolean("is_active", false);
|
}
|
|
public String getId() {
|
return button.getId();
|
}
|
|
public String getName() {
|
return button.getCode();
|
}
|
|
public boolean isVisible() {
|
return visible;
|
}
|
|
public boolean isActive() {
|
return active;
|
}
|
|
@Override
|
public void writeJSON(IJSONWriter writer) {
|
writer.beginObject();
|
|
button.writeJSONBody(writer);
|
writer.write("visible", visible && button.isActive());
|
writer.write("active", active && button.isActive());
|
|
writer.endObject();
|
}
|
|
}
|