Search in sources :

Example 6 with MaskingAsyncMonitor

use of org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor in project activityinfo by bedatadriven.

the class MonthlyReportsPanel method save.

public Promise<Void> save() {
    ArrayList<UpdateMonthlyReports.Change> changes = new ArrayList<>();
    for (Record record : store.getModifiedRecords()) {
        IndicatorRowDTO report = (IndicatorRowDTO) record.getModel();
        for (String property : record.getChanges().keySet()) {
            UpdateMonthlyReports.Change change = new UpdateMonthlyReports.Change();
            change.setIndicatorId(report.getIndicatorId());
            change.setMonth(IndicatorRowDTO.monthForProperty(property));
            change.setValue(report.get(property));
            changes.add(change);
        }
    }
    final Promise<Void> promise = new Promise<>();
    service.execute(new UpdateMonthlyReports(currentSiteId, changes), new MaskingAsyncMonitor(this, I18N.CONSTANTS.saving()), new AsyncCallback<VoidResult>() {

        @Override
        public void onFailure(Throwable caught) {
            promise.onFailure(caught);
        }

        @Override
        public void onSuccess(VoidResult result) {
            store.commitChanges();
            promise.onSuccess(null);
        }
    });
    return promise;
}
Also used : UpdateMonthlyReports(org.activityinfo.legacy.shared.command.UpdateMonthlyReports) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) ArrayList(java.util.ArrayList) Promise(org.activityinfo.promise.Promise) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) Record(com.extjs.gxt.ui.client.store.Record)

Example 7 with MaskingAsyncMonitor

use of org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor in project activityinfo by bedatadriven.

the class ShareReportDialog method show.

public void show(final Report report) {
    if (report.getIndicators().isEmpty()) {
        MessageBox.alert(I18N.CONSTANTS.alert(), I18N.CONSTANTS.unableToShareReport(), null);
        return;
    }
    super.show();
    this.currentReport = report;
    // we need to combine the databases which already have visiblity with
    // those that could potentially be added
    BatchCommand batch = new BatchCommand();
    batch.add(new GetIndicators(currentReport.getIndicators()));
    batch.add(new GetReportVisibility(currentReport.getId()));
    dispatcher.execute(batch, new MaskingAsyncMonitor(grid, I18N.CONSTANTS.loading()), new SuccessCallback<BatchResult>() {

        @Override
        public void onSuccess(BatchResult batch) {
            populateGrid((IndicatorResult) batch.getResult(0), (ReportVisibilityResult) batch.getResult(1));
        }
    });
}
Also used : IndicatorResult(org.activityinfo.legacy.shared.command.result.IndicatorResult) ReportVisibilityResult(org.activityinfo.legacy.shared.command.result.ReportVisibilityResult) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) BatchResult(org.activityinfo.legacy.shared.command.result.BatchResult)

Example 8 with MaskingAsyncMonitor

use of org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor in project activityinfo by bedatadriven.

the class PrintDataEntryForm method print.

public void print(final int activityId) {
    setVisible(true);
    dispatcher.execute(new GetActivityForm(activityId), new MaskingAsyncMonitor(this, I18N.CONSTANTS.loading()), new AsyncCallback<ActivityFormDTO>() {

        @Override
        public void onFailure(Throwable caught) {
            showError(caught);
        }

        @Override
        public void onSuccess(ActivityFormDTO result) {
            renderForm(result);
        }
    });
}
Also used : MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) GetActivityForm(org.activityinfo.legacy.shared.command.GetActivityForm)

Example 9 with MaskingAsyncMonitor

use of org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor in project activityinfo by bedatadriven.

the class EmailDialog method onButtonPressed.

@Override
protected void onButtonPressed(Button button) {
    if (button.getItemId().equals(OK)) {
        final UpdateReportSubscription update = new UpdateReportSubscription();
        update.setReportId(reportMetadata.getId());
        if (weekly.getValue()) {
            update.setEmailDelivery(EmailDelivery.WEEKLY);
            update.setEmailDay(dayOfWeek.getMappedValue());
        } else if (monthly.getValue()) {
            update.setEmailDelivery(EmailDelivery.MONTHLY);
            update.setEmailDay(dayOfMonth.getMappedValue());
        } else {
            update.setEmailDelivery(EmailDelivery.NONE);
        }
        dispatcher.execute(update, new MaskingAsyncMonitor(this, I18N.CONSTANTS.saving()), new AsyncCallback<VoidResult>() {

            @Override
            public void onFailure(Throwable caught) {
            }

            @Override
            public void onSuccess(VoidResult result) {
                hide();
                reportMetadata.setEmailDelivery(update.getEmailDelivery());
                reportMetadata.setDay(update.getEmailDay());
                callback.onUpdated();
            }
        });
    } else if (button.getItemId().equals(CANCEL)) {
        hide();
    }
}
Also used : UpdateReportSubscription(org.activityinfo.legacy.shared.command.UpdateReportSubscription) VoidResult(org.activityinfo.legacy.shared.command.result.VoidResult) MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)

Example 10 with MaskingAsyncMonitor

use of org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor in project activityinfo by bedatadriven.

the class ShareReportDialog method show.

public void show(ReportMetadataDTO metadata) {
    super.show();
    dispatcher.execute(new GetReportModel(metadata.getId()), new MaskingAsyncMonitor(grid, I18N.CONSTANTS.loading()), new SuccessCallback<ReportDTO>() {

        @Override
        public void onSuccess(ReportDTO reportDTO) {
            show(reportDTO.getReport());
        }
    });
}
Also used : MaskingAsyncMonitor(org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor) ReportDTO(org.activityinfo.legacy.shared.model.ReportDTO)

Aggregations

MaskingAsyncMonitor (org.activityinfo.ui.client.dispatch.monitor.MaskingAsyncMonitor)11 VoidResult (org.activityinfo.legacy.shared.command.result.VoidResult)4 BatchResult (org.activityinfo.legacy.shared.command.result.BatchResult)3 Record (com.extjs.gxt.ui.client.store.Record)2 ArrayList (java.util.ArrayList)2 GetActivityForm (org.activityinfo.legacy.shared.command.GetActivityForm)2 UpdateUserPermissions (org.activityinfo.legacy.shared.command.UpdateUserPermissions)2 UserPermissionDTO (org.activityinfo.legacy.shared.model.UserPermissionDTO)2 BaseModelData (com.extjs.gxt.ui.client.data.BaseModelData)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)1 List (java.util.List)1 BatchCommand (org.activityinfo.legacy.shared.command.BatchCommand)1 DeleteReport (org.activityinfo.legacy.shared.command.DeleteReport)1 GetBaseMaps (org.activityinfo.legacy.shared.command.GetBaseMaps)1 GetSchema (org.activityinfo.legacy.shared.command.GetSchema)1 UpdateMonthlyReports (org.activityinfo.legacy.shared.command.UpdateMonthlyReports)1 UpdateReportSubscription (org.activityinfo.legacy.shared.command.UpdateReportSubscription)1 BaseMapResult (org.activityinfo.legacy.shared.command.result.BaseMapResult)1 IndicatorResult (org.activityinfo.legacy.shared.command.result.IndicatorResult)1