use of org.apache.syncope.client.console.panels.ListViewPanel.ListViewReload 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