Search in sources :

Example 6 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class AbstractRoleMainPanel method initShoppingCartPanel.

private void initShoppingCartPanel(PageAdminObjectDetails<R> parentPage) {
    RoleCatalogStorage storage = parentPage.getSessionStorage().getRoleCatalog();
    WebMarkupContainer shoppingCartButtonsPanel = new WebMarkupContainer(ID_SHOPPING_CART_BUTTONS_PANEL);
    shoppingCartButtonsPanel.setOutputMarkupId(true);
    shoppingCartButtonsPanel.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            // Role Catalog page
            return PageAssignmentShoppingKart.class.equals(getPreviousPage(parentPage));
        }
    });
    getMainForm().add(shoppingCartButtonsPanel);
    AjaxButton addToCartButton = new AjaxButton(ID_ADD_TO_CART_BUTTON, parentPage.createStringResource("PageAssignmentDetails.addToCartButton")) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget target) {
            AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
            storage.getAssignmentShoppingCart().add(dto);
            target.add(shoppingCartButtonsPanel);
        }
    };
    addToCartButton.setOutputMarkupId(true);
    addToCartButton.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isEnabled() {
            AssignmentEditorDto dto = AssignmentEditorDto.createDtoFromObject(getObject().asObjectable(), UserDtoStatus.ADD, parentPage);
            return storage.isMultiUserRequest() || dto.isAssignable();
        }
    });
    shoppingCartButtonsPanel.add(addToCartButton);
    AjaxButton shoppingCartButton = new AjaxButton(ID_SHOPPING_CART_BUTTON) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
            attributes.setChannel(new AjaxChannel("blocking", AjaxChannel.Type.ACTIVE));
        }

        @Override
        public void onClick(AjaxRequestTarget ajaxRequestTarget) {
            parentPage.navigateToNext(PageAssignmentsList.class);
        }
    };
    shoppingCartButton.setOutputMarkupId(true);
    shoppingCartButtonsPanel.add(shoppingCartButton);
    Label cartItemsCount = new Label(ID_ITEMS_COUNT, new LoadableModel<String>(true) {

        private static final long serialVersionUID = 1L;

        @Override
        public String load() {
            return Integer.toString(storage.getAssignmentShoppingCart().size());
        }
    });
    cartItemsCount.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            if (storage.getAssignmentShoppingCart().size() == 0) {
                return false;
            } else {
                return true;
            }
        }
    });
    cartItemsCount.setOutputMarkupId(true);
    shoppingCartButton.add(cartItemsCount);
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) RoleCatalogStorage(com.evolveum.midpoint.web.session.RoleCatalogStorage) Label(org.apache.wicket.markup.html.basic.Label) PageAssignmentShoppingKart(com.evolveum.midpoint.web.page.self.PageAssignmentShoppingKart) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestAttributes(org.apache.wicket.ajax.attributes.AjaxRequestAttributes) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AjaxChannel(org.apache.wicket.ajax.AjaxChannel) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)

Example 7 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageRequestRole method loadAssignments.

private List<AssignmentEditorDto> loadAssignments() {
    List<AssignmentEditorDto> list = new ArrayList<AssignmentEditorDto>();
    List<AssignmentType> assignments = user.asObjectable().getAssignment();
    for (AssignmentType assignment : assignments) {
        list.add(new AssignmentEditorDto(UserDtoStatus.MODIFY, assignment, this));
    }
    Collections.sort(list);
    return list;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 8 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAssignmentDetails method initLayout.

public void initLayout(final IModel<AssignmentEditorDto> assignmentModel) {
    setOutputMarkupId(true);
    Form mainForm = new Form(ID_FORM);
    mainForm.setOutputMarkupId(true);
    add(mainForm);
    AssignmentDetailsPanel detailsPanel = new AssignmentDetailsPanel(ID_DETAILS_PANEL, assignmentModel, PageAssignmentDetails.this);
    detailsPanel.setOutputMarkupId(true);
    mainForm.add(detailsPanel);
    AjaxButton back = new AjaxButton(ID_BACK, createStringResource("PageAssignmentDetails.backButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            redirectBack();
        }
    };
    mainForm.add(back);
    AjaxButton addToCart = new AjaxButton(ID_ADD_TO_CART, createStringResource("PageAssignmentDetails.addToCartButton")) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            RoleCatalogStorage storage = getSessionStorage().getRoleCatalog();
            if (storage.getAssignmentShoppingCart() == null) {
                storage.setAssignmentShoppingCart(new ArrayList<AssignmentEditorDto>());
            }
            AssignmentEditorDto dto = assignmentModel.getObject();
            dto.setMinimized(true);
            dto.setSimpleView(false);
            storage.getAssignmentShoppingCart().add(dto);
            redirectBack();
        }
    };
    mainForm.add(addToCart);
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) AjaxButton(com.evolveum.midpoint.web.component.AjaxButton) AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) Form(com.evolveum.midpoint.web.component.form.Form) RoleCatalogStorage(com.evolveum.midpoint.web.session.RoleCatalogStorage) AssignmentDetailsPanel(com.evolveum.midpoint.web.component.assignment.AssignmentDetailsPanel)

Example 9 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAssignmentsList method addAssignmentsToUser.

private List<AssignmentEditorDto> addAssignmentsToUser(UserType user) {
    List<String> assignmentsToDeselect = getAssignmentsToDeselectList(user);
    List<AssignmentEditorDto> assignmentsToRemove = getAssignmentsToRemoveList(user);
    List<AssignmentEditorDto> assignmentsList = new ArrayList<>();
    assignmentsList.addAll(assignmentsToRemove);
    if (assignmentsModel != null && assignmentsModel.getObject() != null) {
        for (AssignmentEditorDto assignmentsToAdd : assignmentsModel.getObject()) {
            if (!assignmentsToDeselect.contains(assignmentsToAdd.getTargetRef().getOid())) {
                assignmentsToAdd.setStatus(UserDtoStatus.ADD);
                assignmentsList.add(assignmentsToAdd);
            }
        }
    }
    return assignmentsList;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)

Example 10 with AssignmentEditorDto

use of com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto in project midpoint by Evolveum.

the class PageAssignmentsList method handleAssignmentDeltas.

private ContainerDelta handleAssignmentDeltas(ObjectDelta<UserType> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition def) throws SchemaException {
    ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());
    for (AssignmentEditorDto assDto : assignments) {
        PrismContainerValue newValue = assDto.getNewValue(getPrismContext());
        switch(assDto.getStatus()) {
            case ADD:
                newValue.applyDefinition(def, false);
                assDelta.addValueToAdd(newValue.clone());
                break;
            case DELETE:
                PrismContainerValue oldValue = assDto.getOldValue();
                oldValue.applyDefinition(def);
                assDelta.addValueToDelete(oldValue.clone());
                break;
            case MODIFY:
                if (!assDto.isModified(getPrismContext())) {
                    LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
                    continue;
                }
                handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
                break;
            default:
                warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
        }
    }
    if (!assDelta.isEmpty()) {
        assDelta = focusDelta.addModification(assDelta);
    }
    return assDelta;
}
Also used : AssignmentEditorDto(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Aggregations

AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)18 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)5 ArrayList (java.util.ArrayList)4 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 DelegationEditorPanel (com.evolveum.midpoint.web.component.assignment.DelegationEditorPanel)3 FocusMainPanel (com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel)3 PageAdminObjectDetails (com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails)3 List (java.util.List)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 CountablePanelTab (com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab)2 FocusTabVisibleBehavior (com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior)2 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)2 ObjectFilter (com.evolveum.midpoint.prism.query.ObjectFilter)2 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)2 RoleCatalogStorage (com.evolveum.midpoint.web.session.RoleCatalogStorage)2 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)2 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)2 ObjectBrowserPanel (com.evolveum.midpoint.gui.api.component.ObjectBrowserPanel)1