Search in sources :

Example 1 with BeforeSaveEvent

use of org.activityinfo.ui.client.component.form.event.BeforeSaveEvent in project activityinfo by bedatadriven.

the class FormActions method save.

public Promise<List<FormInstance>> save() {
    model.getEventBus().fireEvent(new BeforeSaveEvent());
    final List<FormInstance> instancesToPersist = getInstancesToPersist();
    Promise<Void> persist = locator.persist(instancesToPersist);
    Promise<Void> remove = remove();
    final Promise<List<FormInstance>> result = new Promise<>();
    Promise.waitAll(persist, remove).then(new AsyncCallback<Void>() {

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

        @Override
        public void onSuccess(Void input) {
            model.getChangedInstances().clear();
            result.onSuccess(instancesToPersist);
        }
    });
    return result;
}
Also used : Promise(org.activityinfo.promise.Promise) BeforeSaveEvent(org.activityinfo.ui.client.component.form.event.BeforeSaveEvent) List(java.util.List) FormInstance(org.activityinfo.model.form.FormInstance)

Aggregations

List (java.util.List)1 FormInstance (org.activityinfo.model.form.FormInstance)1 Promise (org.activityinfo.promise.Promise)1 BeforeSaveEvent (org.activityinfo.ui.client.component.form.event.BeforeSaveEvent)1