use of org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel in project syncope by apache.
the class AjaxFallbackDataTable method newRowItem.
@Override
protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) {
final OddEvenItem<T> item = new OddEvenItem<>(id, index, model);
if (togglePanel != null) {
final ActionsPanel<T> actions = getActions(model);
if (actions != null && !actions.isEmpty()) {
item.add(new AttributeModifier("style", "cursor: pointer;"));
item.add(new AjaxEventBehavior(Constants.ON_CLICK) {
private static final long serialVersionUID = 1L;
@Override
protected String findIndicatorId() {
return StringUtils.EMPTY;
}
@Override
protected void onEvent(final AjaxRequestTarget target) {
final String lastFocussedElementId = target.getLastFocusedElementId();
if (lastFocussedElementId == null) {
togglePanel.toggleWithContent(target, getActions(model), model.getObject());
} else {
final AjaxDataTablePanel<?, ?> parent = findParent(AjaxDataTablePanel.class);
final Model<Boolean> isCheck = Model.<Boolean>of(Boolean.FALSE);
parent.visitChildren(CheckGroupSelector.class, (selector, ivisit) -> {
if (selector.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) {
isCheck.setObject(Boolean.TRUE);
ivisit.stop();
}
});
if (!isCheck.getObject()) {
parent.visitChildren(Check.class, (check, ivisit) -> {
if (check.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) {
isCheck.setObject(Boolean.TRUE);
ivisit.stop();
}
});
}
if (!isCheck.getObject()) {
togglePanel.toggleWithContent(target, getActions(model), model.getObject());
}
}
}
});
}
}
return item;
}
use of org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel in project syncope by apache.
the class Realm method buildTabList.
private List<ITab> buildTabList(final PageReference pageRef) {
List<ITab> tabs = new ArrayList<>();
tabs.add(new ITabComponent(new Model<>("DETAILS"), StandardEntitlement.REALM_CREATE, StandardEntitlement.REALM_UPDATE, StandardEntitlement.REALM_DELETE) {
private static final long serialVersionUID = -5861786415855103549L;
@Override
public Panel getPanel(final String panelId) {
final ActionsPanel<RealmTO> actionPanel = new ActionsPanel<>("actions", null);
if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
actionPanel.add(new ActionLink<RealmTO>(realmTO) {
private static final long serialVersionUID = 2802988981431379827L;
@Override
public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
onClickCreate(target);
}
}, ActionLink.ActionType.CREATE, StandardEntitlement.REALM_CREATE).hideLabel();
actionPanel.add(new ActionLink<RealmTO>(realmTO) {
private static final long serialVersionUID = 2802988981431379828L;
@Override
public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
onClickEdit(target, realmTO);
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.REALM_UPDATE).hideLabel();
actionPanel.add(new ActionLink<RealmTO>(realmTO) {
private static final long serialVersionUID = 2802988981431379827L;
@Override
public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
onClickTemplate(target);
}
}, ActionLink.ActionType.TEMPLATE, StandardEntitlement.REALM_UPDATE).hideLabel();
actionPanel.add(new ActionLink<RealmTO>(realmTO) {
private static final long serialVersionUID = 2802988981431379829L;
@Override
public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
onClickDelete(target, realmTO);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.REALM_DELETE, true).hideLabel();
}
RealmDetails panel = new RealmDetails(panelId, realmTO, actionPanel, false);
panel.setContentEnabled(false);
actionPanel.setEnabled(true);
return panel;
}
@Override
public boolean isVisible() {
return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
}
});
final Triple<UserFormLayoutInfo, GroupFormLayoutInfo, Map<String, AnyObjectFormLayoutInfo>> formLayoutInfo = FormLayoutInfoUtils.fetch(anyTypes.stream().map(EntityTO::getKey).collect(Collectors.toList()));
for (final AnyTypeTO anyType : anyTypes) {
tabs.add(new ITabComponent(new Model<>(anyType.getKey()), String.format("%s_SEARCH", anyType.getKey())) {
private static final long serialVersionUID = 1169585538404171118L;
@Override
public WebMarkupContainer getPanel(final String panelId) {
return new AnyPanel(panelId, anyType, realmTO, formLayoutInfo, true, pageRef);
}
@Override
public boolean isVisible() {
return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
}
});
}
return tabs;
}
use of org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel in project syncope by apache.
the class RoleDirectoryPanel method getActions.
@Override
public ActionsPanel<RoleTO> getActions(final IModel<RoleTO> model) {
final ActionsPanel<RoleTO> panel = super.getActions(model);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(new RoleWrapper(new RoleRestClient().read(model.getObject().getKey())), target));
}
}, ActionLink.ActionType.EDIT, StandardEntitlement.ROLE_READ);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final RoleTO clone = SerializationUtils.clone(model.getObject());
clone.setKey(null);
send(RoleDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.NewItemActionEvent<>(new RoleWrapper(clone), target));
}
}, ActionLink.ActionType.CLONE, StandardEntitlement.ROLE_CREATE);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final String query = SyncopeClient.getUserSearchConditionBuilder().and(SyncopeClient.getUserSearchConditionBuilder().inRoles(model.getObject().getKey()), SyncopeClient.getUserSearchConditionBuilder().is("key").notNullValue()).query();
final AnyTypeRestClient typeRestClient = new AnyTypeRestClient();
final AnyTypeClassRestClient classRestClient = new AnyTypeClassRestClient();
final AnyTypeTO anyTypeTO = typeRestClient.read(AnyTypeKind.USER.name());
ModalPanel panel = new AnyPanel(BaseModal.CONTENT_ID, anyTypeTO, null, null, false, pageRef) {
private static final long serialVersionUID = -7514498203393023415L;
@Override
protected Panel getDirectoryPanel(final String id) {
final Panel panel = new UserDirectoryPanel.Builder(classRestClient.list(anyTypeTO.getClasses()), anyTypeTO.getKey(), pageRef).setRealm("/").setFiltered(true).setFiql(query).disableCheckBoxes().addNewItemPanelBuilder(FormLayoutInfoUtils.instantiate(new UserTO(), anyTypeTO.getClasses(), FormLayoutInfoUtils.fetch(typeRestClient.list()).getLeft(), pageRef), false).setWizardInModal(false).build(id);
MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.RENDER, StandardEntitlement.USER_SEARCH);
return panel;
}
};
membersModal.header(new StringResourceModel("role.members", RoleDirectoryPanel.this, model));
membersModal.setContent(panel);
membersModal.show(true);
target.add(membersModal);
}
}, ActionLink.ActionType.MEMBERS, StandardEntitlement.USER_SEARCH);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
final ConsoleLayoutInfo info = new ConsoleLayoutInfo(model.getObject().getKey());
info.setContent(restClient.readConsoleLayoutInfo(model.getObject().getKey()));
utilityModal.header(new ResourceModel("console.layout.info", "JSON Content"));
utilityModal.setContent(new JsonEditorPanel(utilityModal, new PropertyModel<String>(info, "content"), false, pageRef) {
private static final long serialVersionUID = -8927036362466990179L;
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
restClient.setConsoleLayoutInfo(info.getKey(), info.getContent());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
modal.show(false);
modal.close(target);
} catch (Exception e) {
LOG.error("While updating console layout info for role {}", info.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
});
utilityModal.show(true);
target.add(utilityModal);
}
}, ActionLink.ActionType.LAYOUT_EDIT, StandardEntitlement.ROLE_UPDATE);
panel.add(new ActionLink<RoleTO>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final RoleTO ignore) {
try {
restClient.delete(model.getObject().getKey());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", model.getObject().getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ActionLink.ActionType.DELETE, StandardEntitlement.ROLE_DELETE, true);
return panel;
}
use of org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel in project syncope by apache.
the class Relationships method getViewFragment.
private Fragment getViewFragment() {
final Map<String, List<RelationshipTO>> relationships = new HashMap<>();
addRelationship(relationships, getCurrentRelationships().toArray(new RelationshipTO[] {}));
final Fragment viewFragment = new Fragment("relationships", "viewFragment", this);
viewFragment.setOutputMarkupId(true);
viewFragment.add(new Accordion("relationships", relationships.keySet().stream().map(relationship -> {
return new AbstractTab(new ResourceModel("relationship", relationship)) {
private static final long serialVersionUID = 1037272333056449378L;
@Override
public Panel getPanel(final String panelId) {
return new ListViewPanel.Builder<>(RelationshipTO.class, pageRef).setItems(relationships.get(relationship)).includes("otherEndType", "otherEndKey").addAction(new ActionLink<RelationshipTO>() {
private static final long serialVersionUID = -6847033126124401556L;
@Override
public void onClick(final AjaxRequestTarget target, final RelationshipTO modelObject) {
removeRelationships(relationships, modelObject);
send(Relationships.this, Broadcast.DEPTH, new ListViewReload<>(target));
}
}, ActionType.DELETE, AnyEntitlement.UPDATE.getFor(anyTO.getType()), true).build(panelId);
}
};
}).collect(Collectors.toList())) {
private static final long serialVersionUID = 1037272333056449379L;
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
if (relationships.isEmpty()) {
response.render(OnDomReadyHeaderItem.forScript(String.format("$('#emptyPlaceholder').append(\"%s\")", getString("relationships.empty.list"))));
}
}
});
final ActionsPanel<RelationshipTO> panel = new ActionsPanel<>("actions", null);
viewFragment.add(panel);
panel.add(new ActionLink<RelationshipTO>() {
private static final long serialVersionUID = 3257738274365467945L;
@Override
public void onClick(final AjaxRequestTarget target, final RelationshipTO ignore) {
Fragment addFragment = new Fragment("relationships", "addFragment", Relationships.this);
addOrReplace(addFragment);
addFragment.add(new Specification().setRenderBodyOnly(true));
target.add(Relationships.this);
}
}, ActionType.CREATE, AnyEntitlement.UPDATE.getFor(anyTO.getType())).hideLabel();
return viewFragment;
}
Aggregations