use of org.activityinfo.ui.client.dispatch.AsyncMonitor in project activityinfo by bedatadriven.
the class FormSavedGuard method navigate.
@Override
public void navigate(final NavigationCallback callback) {
if (!saved) {
final SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(final AsyncMonitor monitor) {
formDesigner.getFormDesignerActions().save().then(new SuccessCallback<Void>() {
@Override
public void onSuccess(Void result) {
box.hide();
callback.onDecided(true);
}
});
}
@Override
public void discard() {
box.hide();
callback.onDecided(true);
}
@Override
public void cancel() {
box.hide();
callback.onDecided(false);
}
});
} else {
callback.onDecided(true);
}
}
use of org.activityinfo.ui.client.dispatch.AsyncMonitor in project activityinfo by bedatadriven.
the class AbstractEditorGridPresenter method requestToNavigateAway.
/*
* The user has chosen to navigate away from this page We will automatically
* try to save any unsaved changes, but if it fails, we give the user a
* choice between retrying and and discarding changes
*/
@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
if (getModifiedRecords().size() == 0) {
callback.onDecided(true);
} else {
final SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(AsyncMonitor monitor) {
service.execute(createSaveCommand(), view.getSavingMonitor(), new SuccessCallback<BatchResult>() {
@Override
public void onSuccess(BatchResult result) {
box.hide();
getStore().commitChanges();
callback.onDecided(true);
}
});
}
@Override
public void cancel() {
box.hide();
callback.onDecided(false);
}
@Override
public void discard() {
box.hide();
callback.onDecided(true);
}
});
}
}
use of org.activityinfo.ui.client.dispatch.AsyncMonitor in project activityinfo by bedatadriven.
the class ReportDesignPage method requestToNavigateAway.
@Override
public void requestToNavigateAway(final PageState place, final NavigationCallback callback) {
if (!dirty) {
callback.onDecided(true);
} else {
SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(final AsyncMonitor monitor) {
saveTitled(monitor, new SaveCallback() {
@Override
public void onSaved() {
callback.onDecided(true);
}
});
}
@Override
public void discard() {
callback.onDecided(true);
}
@Override
public void cancel() {
callback.onDecided(false);
}
});
}
}
use of org.activityinfo.ui.client.dispatch.AsyncMonitor in project activityinfo by bedatadriven.
the class DbUserEditor method requestToNavigateAway.
@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
if (modified) {
final SavePromptMessageBox savePrompt = new SavePromptMessageBox();
savePrompt.show(new SaveChangesCallback() {
@Override
public void save(AsyncMonitor monitor) {
savePrompt.hide();
actions.save(callback);
}
@Override
public void cancel() {
savePrompt.hide();
callback.onDecided(false);
}
@Override
public void discard() {
savePrompt.hide();
callback.onDecided(true);
}
});
} else {
callback.onDecided(true);
}
}
use of org.activityinfo.ui.client.dispatch.AsyncMonitor in project activityinfo by bedatadriven.
the class DataEntryPage method requestToNavigateAway.
@Override
public void requestToNavigateAway(PageState place, final NavigationCallback callback) {
if (monthlyPanel.isModified()) {
final SavePromptMessageBox box = new SavePromptMessageBox();
box.show(new SaveChangesCallback() {
@Override
public void save(AsyncMonitor monitor) {
monthlyPanel.save().then(new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
// handled by monitor
}
@Override
public void onSuccess(Void result) {
box.hide();
callback.onDecided(true);
}
});
}
@Override
public void cancel() {
box.hide();
callback.onDecided(false);
}
@Override
public void discard() {
box.hide();
callback.onDecided(true);
}
});
} else {
callback.onDecided(true);
}
}
Aggregations