diff --git a/src/locales/en.json b/src/locales/en.json index 8090f1f..aac3353 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -184,5 +184,6 @@ "open": "Open", "openRevision": "Open from revision", "confirmOpenRevision": "Data is changed! Do you confirm opening data from the revision?", - "revisions": "Changes history" + "revisions": "Changes history", + "confirmSaveOnServerDataChanged": "Data is changed on server! Do you confirm save current data?" } \ No newline at end of file diff --git a/src/locales/ru.json b/src/locales/ru.json index d105305..e497ad7 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -183,5 +183,6 @@ "open": "Открыть", "openRevision": "Открыть из истории", "confirmOpenRevision": "Данные изменены! Открыть запись из истории?", - "revisions": "История изменений" + "revisions": "История изменений", + "confirmSaveOnServerDataChanged": "Данные на сервере изменены! Вы точно хотите сохранить данные?" } \ No newline at end of file diff --git a/src/pages/PageView.vue b/src/pages/PageView.vue index 0f26080..078942d 100644 --- a/src/pages/PageView.vue +++ b/src/pages/PageView.vue @@ -155,6 +155,7 @@ let revisionBtn = ref(null) let editEntity = ref(null) let editEntityRevisionId = -1 +let serverRevision = null let isSaving = false let editDataSource: DataSourceInterface = null let isNew = ref(false) @@ -230,6 +231,19 @@ async function save() { .then(async () => { await saveData() }) + } else if (!isNew.value && serverRevision !== editEntityRevisionId) { + ElMessageBox.confirm( + t('confirmSaveOnServerDataChanged'), + t('save'), + { + confirmButtonText: t('save'), + cancelButtonText: t('cancel'), + type: 'warning', + } + ) + .then(async () => { + await saveData() + }) } else { await saveData() } @@ -250,6 +264,7 @@ async function save() { id: editEntityRevisionId } isChanged.value = false + serverRevision = editEntityRevisionId await setViewed() ElMessage.success(t('saved')) @@ -445,11 +460,13 @@ async function init() { currentRevision.value = { id: editEntityRevisionId } + serverRevision = editEntityRevisionId setViewed() } else { editEntity.value = await generateEntityWithDefault(editDataSource.fields) isNew.value = true editEntityRevisionId = -1 + serverRevision = null } scriptContext.value.item = editEntity.value @@ -627,12 +644,14 @@ async function onUpdates(msg: any) { if (msg.entity.id === editEntity.value.id && editEntityRevisionId !== msg.entity.rev) { + serverRevision = msg.entity.rev ElMessage.warning({ message: t('entityUpdated'), duration: 0, showClose: true, grouping: true }) + } }