Skip to content

Commit

Permalink
fix for assign new members on governance card panel
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Feb 22, 2023
1 parent 6b46294 commit 6f582db
Show file tree
Hide file tree
Showing 22 changed files with 699 additions and 214 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

Expand Down Expand Up @@ -57,7 +59,7 @@ protected void onInitialize() {
add(parametersPanelFragment);
}

protected Component initObjectListPanel() {
protected PopupObjectListPanel initObjectListPanel() {
PopupObjectListPanel<O> listPanel = new PopupObjectListPanel<>
(ID_OBJECT_LIST_PANEL, getObjectType().getClassDefinition(), true) {

Expand Down Expand Up @@ -118,6 +120,12 @@ protected ObjectQuery getCustomizeContentQuery() {
return customQuery;
}

@Override
protected void customProcessNewRowItem(Item<SelectableBean<O>> item, IModel<SelectableBean<O>> model) {
item.add(AttributeAppender.append(
"class",
() -> item != null && item.getModelObject() != null &&item.getModelObject().isSelected() ? "table-primary" : ""));
}
};
listPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<div wicket:id="tabsPanel"/>

<p align="right">
<a class="btn btn-default btn-sm" wicket:id="cancelButton"/>
<a class="btn btn-default btn-sm" wicket:id="addButton"/>
<a class="btn btn-outline-primary " wicket:id="cancelButton"/>
<a class="btn btn-success " wicket:id="addButton"/>
</p>
</form>
</wicket:panel>
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public void onClick(AjaxRequestTarget target) {

private void addOrReplaceTabPanels(Form form, AssignmentObjectRelation relationSpec) {
tabs = createAssignmentTabs(relationSpec);
TabbedPanel<ITab> tabPanel = WebComponentUtil.createTabPanel(ID_TABS_PANEL, getPageBase(), tabs, null);
TabCenterTabbedPanel<ITab> tabPanel = new TabCenterTabbedPanel(ID_TABS_PANEL, tabs);
tabPanel.add(new VisibleBehaviour(() -> !isCompositedButtonsPanelVisible));
tabPanel.setOutputMarkupId(true);
form.addOrReplace(tabPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
<wicket:extend>
<wicket:child/>
<wicket:fragment wicket:id="parametersPanelFragment">
<label>
<wicket:message key="AssignmentPanel.newAssignmentParameters"/>
</label>
<div class="d-flex flex-wrap gap-2">
<div class="d-flex flex-wrap gap-2 mr-4">
<span class="col-form-label-sm"><wicket:message key="ObjectReferenceType.relation"/></span>
<select class="form-control form-control-sm w-auto" wicket:id="relation"/>
<div class="pl-3">
<label>
<wicket:message key="AssignmentPanel.newAssignmentParameters"/>
</label>
<div class="d-flex flex-wrap gap-2">
<div class="d-flex flex-wrap gap-2 mr-4">
<span class="col-form-label-sm"><wicket:message key="ObjectReferenceType.relation"/></span>
<select class="form-control form-control-sm w-auto" wicket:id="relation"/>
</div>
</div>
</div>
</wicket:fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.evolveum.midpoint.web.component.util.VisibleBehaviour;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.panel.Fragment;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -154,4 +155,10 @@ protected List<ObjectReferenceType> getArchetypeRefList() {
private RelationDropDownChoice getRelationDropDown() {
return (RelationDropDownChoice) get(ID_PARAMETERS_PANEL).get(ID_RELATION);
}

@Override
protected void onBeforeRender() {
super.onBeforeRender();
getObjectListPanel().getTable().setShowAsCard(false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ public String getMainPopupBodyId() {
return ModalDialog.CONTENT_ID;
}

public void replaceMainPopup(Popupable popupable, AjaxRequestTarget target) {
target.appendJavaScript("$('.modal-backdrop').remove();");
showMainPopup(popupable, target);
}

public void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
MainPopupDialog dialog = getMainPopup();
dialog.getDialogComponent().add(AttributeModifier.replace("style",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.resource.IResource;

import java.io.Serializable;
Expand Down Expand Up @@ -131,10 +132,18 @@ protected DisplayType createDisplayType(IModel<T> model) {
}

protected IModel<IResource> createPreferredImage(IModel<T> model) {
return null;
return Model.of();
}

protected RoundedImagePanel getLogo() {
return (RoundedImagePanel) get(ID_LOGO);
}

protected Label getTitle() {
return (Label) get(ID_TITLE);
}

protected WebMarkupContainer getIcon() {
return (WebMarkupContainer) get(ID_ICON);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ public MemberTilePanel(String id, IModel<TemplateTile<T>> model) {
protected void initLayout() {
super.initLayout();

getLogo().add(new AjaxEventBehavior("click") {
if (isSelectable()) {
getLogo().add(new AjaxEventBehavior("click") {

@Override
protected void onEvent(AjaxRequestTarget target) {
MemberTilePanel.this.onClick(target);
}
});
@Override
protected void onEvent(AjaxRequestTarget target) {
MemberTilePanel.this.onClick(target);
}
});
}

add(AttributeAppender.append("class", "card catalog-tile-panel d-flex flex-column align-items-center bordered p-3 h-100 mb-0"));
add(AttributeAppender.append("class", () -> getModelObject().isSelected() ? "active selectable" : null));
Expand All @@ -92,6 +94,7 @@ public void onUpdate(AjaxRequestTarget target) {
onClick(target);
}
};
check.add(new VisibleBehaviour(this::isSelectable));
add(check);

DropdownButtonPanel menu = new DropdownButtonPanel(
Expand Down Expand Up @@ -158,6 +161,10 @@ protected void populateItem(ListItem<DisplayType> item) {
add(unassign);
}

protected boolean isSelectable() {
return true;
}

protected String getCssForUnassignButton() {
return "btn btn-link mt-3 ml-auto";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
</div>
</wicket:fragment>
<wicket:fragment wicket:id="tilesFragment">
<div class="d-flex">
<div class="mr-auto pr-4">
<div wicket:id="viewToggle"/>
</div>
<div class="ml-auto" wicket:id="panelHeader"/>
<div wicket:id="tiles" style="min-height: 250px;">
<div wicket:id="tile"/>
</div>
</wicket:fragment>
</wicket:panel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,14 @@ public void refresh(AjaxRequestTarget target) {
if (viewToggleModel.getObject() == ViewToggle.TABLE) {
target.add(get(ID_TABLE));
} else {
target.add(get(ID_TILES_CONTAINER), get(createComponentPath(ID_FOOTER_CONTAINER, ID_TILES_PAGING)));
target.add(get(ID_TILES_CONTAINER), getTilesNavigation());
}
}

protected NavigatorPanel getTilesNavigation() {
return (NavigatorPanel) get(createComponentPath(ID_FOOTER_CONTAINER, ID_TILES_PAGING));
}

protected IModel<Search> createSearchModel() {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.stream.Collectors;
import javax.xml.namespace.QName;

import com.evolveum.midpoint.web.component.dialog.*;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
Expand Down Expand Up @@ -80,10 +82,6 @@
import com.evolveum.midpoint.web.component.MultiFunctinalButtonDto;
import com.evolveum.midpoint.gui.impl.component.data.provider.SelectableBeanObjectDataProvider;
import com.evolveum.midpoint.web.component.data.column.ColumnMenuAction;
import com.evolveum.midpoint.web.component.dialog.ChooseFocusTypeAndRelationDialogPanel;
import com.evolveum.midpoint.web.component.dialog.ConfigureTaskConfirmationPanel;
import com.evolveum.midpoint.web.component.dialog.ConfirmationPanel;
import com.evolveum.midpoint.web.component.dialog.DeleteConfirmationPanel;
import com.evolveum.midpoint.web.component.form.MidpointForm;
import com.evolveum.midpoint.web.component.menu.cog.ButtonInlineMenuItem;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem;
Expand Down Expand Up @@ -494,15 +492,17 @@ protected AjaxIconButton createAssignButton(String buttonId) {

@Override
public void onClick(AjaxRequestTarget target) {
assignMembersPerformed(target, null);
AbstractRoleMemberPanel.this.getPageBase().showMainPopup(
createAssignPopup(target, null),
target);
}
};
assignButton.add(new VisibleBehaviour(() -> isAuthorized(GuiAuthorizationConstants.MEMBER_OPERATION_ASSIGN)));
assignButton.add(AttributeAppender.append("class", "btn btn-default btn-sm"));
return assignButton;
}

protected void assignMembersPerformed(AjaxRequestTarget target, QName stableRelation) {
protected Popupable createAssignPopup(AjaxRequestTarget target, QName stableRelation) {
ChooseMemberPopup browser = new ChooseMemberPopup(AbstractRoleMemberPanel.this.getPageBase().getMainPopupBodyId(),
getMemberPanelStorage().getSearch(), loadMultiFunctionalButtonModel(false)) {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -535,7 +535,7 @@ protected QName getRelationIfIsStable() {
}
};
browser.setOutputMarkupId(true);
AbstractRoleMemberPanel.this.getPageBase().showMainPopup(browser, target);
return browser;
}

protected void processTaskAfterOperation(Task task, AjaxRequestTarget target) {
Expand All @@ -562,7 +562,7 @@ protected void showMessageWithoutLinkForTask(Task task, AjaxRequestTarget target
}

protected AjaxIconButton createUnassignButton(String buttonId) {
AjaxIconButton assignButton = new AjaxIconButton(buttonId, new Model<>(GuiStyleConstants.EVO_ASSIGNMENT_ICON),
AjaxIconButton assignButton = new AjaxIconButton(buttonId, new Model<>(GuiStyleConstants.CLASS_UNASSIGN),
createStringResource("TreeTablePanel.menu.removeMembers")) {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!--
~ Copyright (c) 2010-2018 Evolveum
~
~ This work is dual-licensed under the Apache License 2.0
~ and European Union Public License. See LICENSE file for details.
-->

<wicket:panel xmlns:wicket="http://wicket.apache.org">
<div class="d-flex flex-column align-items-center">
<h2 class="mb-3">
<wicket:message key="ChooseRelationPopup.text"/>
</h2>
<h5 class="text-center text-secondary">
<wicket:message key="ChooseRelationPopup.subText"/>
</h5>

<div wicket:id="panel"/>

<div class="ml-auto mt-3">
<a class="btn btn-outline-primary" wicket:id="cancelButton">
<i class="fa fa-xmark"/>
<span><wicket:message key="ChooseRelationPopup.button.cancel"/></span>
</a>
<a class="btn btn-success" wicket:id="selectButton">
<span><wicket:message key="ChooseRelationPopup.button.select"/></span>
<i class="fa fa-arrow-right"/>
</a>
</div>
</div>
</wicket:panel>

0 comments on commit 6f582db

Please sign in to comment.