Search in sources :

Example 11 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerFilterPanel method applyBaseFilter.

@Override
public void applyBaseFilter(Filter rawFilter) {
    // we need to remove any partner filter from this base filter
    // so the user has the full selection
    final Filter filter = new Filter(rawFilter);
    filter.clearRestrictions(DimensionType.Partner);
    if (baseFilter == null || !baseFilter.equals(filter)) {
        service.execute(new GetPartnersDimension(filter), new AsyncCallback<PartnerResult>() {

            @Override
            public void onFailure(Throwable caught) {
            }

            @Override
            public void onSuccess(PartnerResult result) {
                List<Integer> ids = getSelectedIds();
                store.removeAll();
                store.add(result.getData());
                applyInternalValue();
                for (PartnerDTO partner : store.getModels()) {
                    if (ids.contains(partner.getId())) {
                        listView.setChecked(partner, true);
                    }
                }
                baseFilter = filter;
            }
        });
    }
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) Filter(org.activityinfo.shared.command.Filter) ArrayList(java.util.ArrayList) List(java.util.List) PartnerResult(org.activityinfo.shared.command.result.PartnerResult) GetPartnersDimension(org.activityinfo.shared.command.GetPartnersDimension)

Example 12 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class DbTargetEditor method onEdit.

@Override
protected void onEdit(final TargetDTO dto) {
    this.view.showAddDialog(dto, db, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            final Record record = store.getRecord(dto);
            service.execute(new UpdateEntity(dto, getChangedProperties(record)), dlg, new AsyncCallback<VoidResult>() {

                @Override
                public void onFailure(Throwable caught) {
                }

                @Override
                public void onSuccess(VoidResult result) {
                    PartnerDTO partner = db.getPartnerById((Integer) record.get("partnerId"));
                    dto.setPartner(partner);
                    ProjectDTO project = db.getProjectById((Integer) record.get("projectId"));
                    dto.setProject(project);
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) UpdateEntity(org.activityinfo.shared.command.UpdateEntity) VoidResult(org.activityinfo.shared.command.result.VoidResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) Record(com.extjs.gxt.ui.client.store.Record)

Example 13 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class DbTargetEditor method onAdd.

@Override
protected void onAdd() {
    final TargetDTO newTarget = new TargetDTO();
    this.view.showAddDialog(newTarget, db, new FormDialogCallback() {

        @Override
        public void onValidated(final FormDialogTether dlg) {
            service.execute(new AddTarget(db.getId(), newTarget), dlg, new AsyncCallback<CreateResult>() {

                @Override
                public void onFailure(Throwable caught) {
                    MessageBox.alert(I18N.CONSTANTS.error(), I18N.CONSTANTS.errorOnServer(), null);
                }

                @Override
                public void onSuccess(CreateResult result) {
                    newTarget.setId(result.getNewId());
                    PartnerDTO partner = db.getPartnerById((Integer) newTarget.get("partnerId"));
                    newTarget.setPartner(partner);
                    ProjectDTO project = db.getProjectById((Integer) newTarget.get("projectId"));
                    newTarget.setProject(project);
                    store.add(newTarget);
                    store.commitChanges();
                    eventBus.fireEvent(AppEvents.SCHEMA_CHANGED);
                    dlg.hide();
                }
            });
        }
    });
}
Also used : ProjectDTO(org.activityinfo.shared.dto.ProjectDTO) FormDialogCallback(org.activityinfo.client.page.common.dialog.FormDialogCallback) CreateResult(org.activityinfo.shared.command.result.CreateResult) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) FormDialogTether(org.activityinfo.client.page.common.dialog.FormDialogTether) AddTarget(org.activityinfo.shared.command.AddTarget) TargetDTO(org.activityinfo.shared.dto.TargetDTO)

Example 14 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class DbUserEditor method onSelectionChanged.

private void onSelectionChanged(UserPermissionDTO selectedItem) {
    if (selectedItem != null) {
        PartnerDTO selectedPartner = selectedItem.getPartner();
        toolBar.setActionEnabled(UIActions.DELETE, db.isManageAllUsersAllowed() || (db.isManageUsersAllowed() && db.getMyPartnerId() == selectedPartner.getId()));
    }
    toolBar.setActionEnabled(UIActions.DELETE, selectedItem != null);
}
Also used : PartnerDTO(org.activityinfo.shared.dto.PartnerDTO)

Example 15 with PartnerDTO

use of org.activityinfo.shared.dto.PartnerDTO in project activityinfo by bedatadriven.

the class PartnerFilterDialog method show.

public void show(Filter baseFilter, final Filter currentFilter, SelectionCallback<Set<Integer>> callback) {
    show();
    this.callback = callback;
    service.execute(new GetPartnersDimension(baseFilter), new AsyncCallback<PartnerResult>() {

        @Override
        public void onFailure(Throwable caught) {
        }

        @Override
        public void onSuccess(PartnerResult result) {
            Set<Integer> ids = currentFilter.getRestrictions(DimensionType.Partner);
            store.removeAll();
            store.add(result.getData());
            for (PartnerDTO partner : store.getModels()) {
                if (ids.contains(partner.getId())) {
                    listView.setChecked(partner, true);
                }
            }
        }
    });
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) PartnerDTO(org.activityinfo.shared.dto.PartnerDTO) PartnerResult(org.activityinfo.shared.command.result.PartnerResult) GetPartnersDimension(org.activityinfo.shared.command.GetPartnersDimension)

Aggregations

PartnerDTO (org.activityinfo.shared.dto.PartnerDTO)23 CreateResult (org.activityinfo.shared.command.result.CreateResult)8 Test (org.junit.Test)8 ProjectDTO (org.activityinfo.shared.dto.ProjectDTO)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)6 AddPartner (org.activityinfo.shared.command.AddPartner)5 CreateSite (org.activityinfo.shared.command.CreateSite)4 DuplicateCreateResult (org.activityinfo.shared.command.result.DuplicateCreateResult)4 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)3 GregorianCalendar (java.util.GregorianCalendar)3 FormDialogCallback (org.activityinfo.client.page.common.dialog.FormDialogCallback)3 FormDialogTether (org.activityinfo.client.page.common.dialog.FormDialogTether)3 OnDataSet (org.activityinfo.server.database.OnDataSet)3 GetPartnersDimension (org.activityinfo.shared.command.GetPartnersDimension)3 PartnerResult (org.activityinfo.shared.command.result.PartnerResult)3 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 KeyGenerator (org.activityinfo.client.local.command.handler.KeyGenerator)2