Search in sources :

Example 1 with RoleCatalogStorage

use of com.evolveum.midpoint.web.session.RoleCatalogStorage in project midpoint by Evolveum.

the class MultiButtonTable method addAssignmentPerformed.

private void addAssignmentPerformed(AssignmentEditorDto assignment, AjaxRequestTarget target) {
    plusIconClicked = true;
    RoleCatalogStorage storage = pageBase.getSessionStorage().getRoleCatalog();
    if (storage.getAssignmentShoppingCart() == null) {
        storage.setAssignmentShoppingCart(new ArrayList<AssignmentEditorDto>());
    }
    AssignmentEditorDto dto = assignment.clone();
    dto.setDefaultRelation();
    storage.getAssignmentShoppingCart().add(dto);
    AssignmentCatalogPanel parent = MultiButtonTable.this.findParent(AssignmentCatalogPanel.class);
    parent.reloadCartButton(target);
}
Also used : RoleCatalogStorage(com.evolveum.midpoint.web.session.RoleCatalogStorage)

Example 2 with RoleCatalogStorage

use of com.evolveum.midpoint.web.session.RoleCatalogStorage 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 3 with RoleCatalogStorage

use of com.evolveum.midpoint.web.session.RoleCatalogStorage 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)

Aggregations

RoleCatalogStorage (com.evolveum.midpoint.web.session.RoleCatalogStorage)3 AjaxButton (com.evolveum.midpoint.web.component.AjaxButton)2 AssignmentEditorDto (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AssignmentDetailsPanel (com.evolveum.midpoint.web.component.assignment.AssignmentDetailsPanel)1 Form (com.evolveum.midpoint.web.component.form.Form)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 PageAssignmentShoppingKart (com.evolveum.midpoint.web.page.self.PageAssignmentShoppingKart)1 AjaxChannel (org.apache.wicket.ajax.AjaxChannel)1 AjaxRequestAttributes (org.apache.wicket.ajax.attributes.AjaxRequestAttributes)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 Label (org.apache.wicket.markup.html.basic.Label)1