Search in sources :

Example 1 with UiPermissionVariant

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;
    });
}
Also used : UiPermissionVariant(com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant) UiPermissionTarget(com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)

Example 2 with UiPermissionVariant

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;
    });
}
Also used : UiPermissionVariant(com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant) Label(com.haulmont.cuba.gui.components.Label)

Example 3 with UiPermissionVariant

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);
            }
        }
    }
}
Also used : UiPermissionVariant(com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant) Permission(com.haulmont.cuba.security.entity.Permission) UiPermissionTarget(com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)

Aggregations

UiPermissionVariant (com.haulmont.cuba.gui.app.security.entity.UiPermissionVariant)3 UiPermissionTarget (com.haulmont.cuba.gui.app.security.entity.UiPermissionTarget)2 Label (com.haulmont.cuba.gui.components.Label)1 Permission (com.haulmont.cuba.security.entity.Permission)1