use of com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant in project cuba by cuba-platform.
the class UiPermissionsFrame method attachCheckBoxListener.
protected void attachCheckBoxListener(CheckBox checkBox, UiPermissionVariant activeVariant) {
checkBox.addValueChangeListener(e -> {
if (itemChanging)
return;
if (uiPermissionsTable.getSelected().isEmpty())
return;
itemChanging = true;
UiPermissionVariant permissionVariant = PermissionUiHelper.getCheckBoxVariant(e.getValue(), activeVariant);
UiPermissionTarget target = uiPermissionsTable.getSingleSelected();
markItemPermission(permissionVariant, target);
uiPermissionTargetsDs.updateItem(target);
itemChanging = false;
});
}
use of com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant in project cuba by cuba-platform.
the class UiPermissionsFrameCompanion method initPermissionsColoredColumns.
@Override
public void initPermissionsColoredColumns(Table<UiPermissionTarget> uiPermissionsTable) {
uiPermissionsTable.addGeneratedColumn("permissionVariant", entity -> {
UiPermissionVariant permissionVariant = entity.getPermissionVariant();
if (permissionVariant == UiPermissionVariant.NOTSET)
return null;
Label label = componentsFactory.createComponent(Label.class);
label.setHtmlEnabled(true);
String labelValue = "<span style=\"role-permission-" + permissionVariant.getColor() + "\">" + messages.getMessage(permissionVariant) + "</span>";
label.setValue(labelValue);
return label;
});
}
use of com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant in project cuba by cuba-platform.
the class UiPermissionsDatasource method loadData.
@Override
protected void loadData(Map<String, Object> params) {
if (permissionDs == null)
return;
if (!data.isEmpty())
return;
clear();
for (Permission p : permissionDs.getItems()) {
String permissionTarget = p.getTarget();
if (StringUtils.isNotEmpty(permissionTarget)) {
int delimeterIndex = permissionTarget.lastIndexOf(Permission.TARGET_PATH_DELIMETER);
if (delimeterIndex >= 0) {
String component = permissionTarget.substring(delimeterIndex + 1);
String screen = permissionTarget.substring(0, delimeterIndex);
UiPermissionVariant permissionVariant = getPermissionVariant(p);
String permissionValue = screen + Permission.TARGET_PATH_DELIMETER + component;
UiPermissionTarget target = new UiPermissionTarget("ui:" + permissionValue, permissionValue, permissionValue);
target.setPermissionVariant(permissionVariant);
target.setComponent(component);
target.setScreen(screen);
includeItem(target);
}
}
}
}
Aggregations