diff --git a/src/js/layout/modules/nerve/nerve.js b/src/js/layout/modules/nerve/nerve.js index 0d6ed36..4775436 100644 --- a/src/js/layout/modules/nerve/nerve.js +++ b/src/js/layout/modules/nerve/nerve.js @@ -910,13 +910,12 @@ function Nerve(config) { }) } - var editEntity = function(entityId) { + const editEntity = (entityId) => { if (editDialog === null) { editDialog = new NerveEditDialog(w, $parent); editDialog.$el.dialog('option', 'modal', false); // TODO modal dialog interferes with typing in lookups input - editDialog.$el.on('save', function(e, dialog) { - var entity = w.entitiesManager.getEntity(dialog.currentId); - + editDialog.$el.on('save', (e, dialog) => { + const entity = w.entitiesManager.getEntity(dialog.currentId); updateEntityView(entity, true); filterEntityView(getFilterValue()); }); @@ -1096,68 +1095,70 @@ var doLookup = function(w, query, type, callback) { }); } -function NerveEditDialog(writer, parentEl) { - var w = writer; - var forceSave = false; // needed for confirmation dialog in beforeSave - var $el = $(''+ - '
The URI you\'ve entered does not look valid.
'+ - 'Are you sure you want to use it?
', + msg: ` +The URI you have entered does not look valid.
+Are you sure you want to use it?
`, showConfirmKey: 'confirm-nerve-uri', type: 'info', - callback: function(doIt) { - setTimeout(function() { // need setTimeout in case confirm dialog is skipped + callback: (doIt) => { + setTimeout(() => { // need setTimeout in case confirm dialog is skipped if (doIt) { forceSave = true; dialog.save(); @@ -1171,27 +1172,28 @@ function NerveEditDialog(writer, parentEl) { } if (dialog.isValid) { - var sm = w.schemaManager; + console.log(dialog.currentData) + const sm = writer.schemaManager; - var type = dialog.currentData.properties.type; - var tag = sm.mapper.getParentTag(type); + const type = dialog.currentData.properties.type; + const tag = sm.mapper.getParentTag(type); dialog.currentData.properties.tag = tag; - var oldType = w.entitiesManager.getEntity(dialog.currentId).getType(); + const oldType = writer.entitiesManager.getEntity(dialog.currentId).getType(); if (type !== oldType) { - var requiredAttributes = sm.mapper.getRequiredAttributes(oldType) - for (var attName in requiredAttributes) { + const requiredAttributes = sm.mapper.getRequiredAttributes(oldType) + for (const attName in requiredAttributes) { delete dialog.currentData.attributes[attName]; } } - var lemmaMapping = sm.mapper.getAttributeForProperty(type, 'lemma'); + const lemmaMapping = sm.mapper.getAttributeForProperty(type, 'lemma'); if (lemmaMapping) { - dialog.currentData.attributes[lemmaMapping] = dialog.currentData.properties.lemma + dialog.currentData.attributes[lemmaMapping] = dialog.$el.find('input[data-mapping="prop.lemma"]').val() } - var uriMapping = sm.mapper.getAttributeForProperty(type, 'uri'); + const uriMapping = sm.mapper.getAttributeForProperty(type, 'uri'); if (uriMapping) { - dialog.currentData.attributes[uriMapping] = dialog.currentData.properties.uri + dialog.currentData.attributes[uriMapping] = dialog.$el.find('input[data-mapping="prop.uri"]').val() } dialog.currentData.customValues.edited = 'true';