From 32a9df8489721d62bc05cd779fdfa51105680094 Mon Sep 17 00:00:00 2001 From: azivner Date: Mon, 19 Nov 2018 22:06:51 +0100 Subject: [PATCH] fixes (and refactoring) for "empty attribute name" check --- src/public/javascripts/dialogs/attributes.js | 24 +++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/public/javascripts/dialogs/attributes.js b/src/public/javascripts/dialogs/attributes.js index 599d3a938..dde933b04 100644 --- a/src/public/javascripts/dialogs/attributes.js +++ b/src/public/javascripts/dialogs/attributes.js @@ -209,7 +209,29 @@ function AttributesModel() { this.isEmptyName = function(index) { const cur = self.ownedAttributes()[index](); - return cur.name.trim() === "" && !cur.isDeleted && (cur.attributeId !== "" || cur.labelValue !== "" || cur.relationValue); + if (cur.name.trim() || cur.isDeleted) { + return false; + } + + if (cur.attributeId) { + // name is empty and attribute already exists so this is NO-GO + return true; + } + + if (cur.type === 'relation-definition' || cur.type === 'label-definition') { + // for definitions there's no possible empty value so we always require name + return true; + } + + if (cur.type === 'label' && cur.labelValue) { + return true; + } + + if (cur.type === 'relation' && cur.relationValue) { + return true; + } + + return false; }; this.isEmptyRelationTarget = function(index) {