Add schema unsaved warning

This commit is contained in:
Antonin Delpeuch 2018-03-30 18:31:19 +01:00
parent d8d7e82be1
commit eed1049df3
2 changed files with 10 additions and 2 deletions

View File

@ -46,8 +46,8 @@
"reset-button": "Reset",
"save-button": "Save",
"close-button": "Close",
"unsaved-changes": "There are unsaved changes. Close anyway?",
"incomplete-schema-could-not-be-saved": "Your schema is incomplete so it cannot be saved yet."
"incomplete-schema-could-not-be-saved": "Your schema is incomplete so it cannot be saved yet.",
"unsaved-warning": "You have made unsaved changes to your Wikidata schema. Close anyway?"
},
"wikidata-preview": {
"new-id": "new item"

View File

@ -176,6 +176,14 @@ SchemaAlignmentDialog.launch = function(onDone) {
this._reset(theProject.overlayModels.wikibaseSchema, true);
}
$(window).bind('beforeunload', function(e) {
if (SchemaAlignmentDialog.isSetUp() && SchemaAlignmentDialog._hasUnsavedChanges) {
return (e = $.i18n._('wikidata-schema')["unsaved-warning"]);
}
return null;
});
SchemaAlignmentDialog._reset = function(schema, initial) {
this._originalSchema = schema || { itemDocuments: [] };
this._schema = cloneDeep(this._originalSchema); // this is what can be munched on