diff --git a/modules/Components/src/client/ACASFormFields.coffee b/modules/Components/src/client/ACASFormFields.coffee index 5147f01d0..648cdfd42 100644 --- a/modules/Components/src/client/ACASFormFields.coffee +++ b/modules/Components/src/client/ACASFormFields.coffee @@ -188,7 +188,11 @@ class ACASFormLSLabelFieldController extends ACASFormAbstractFieldController @isValid value, (isValid) => if isValid @clearError() - if value != "" + # Behavior of persistance layer on save is to look up auto label sequences based on + # thing lsTypeAndKind and label lsTypeAndKind + # If the label text is "" or null then it will set the next auto sequence value + # so in this case its ok to send "" and ignored = false + if value != "" || @getModel.get("isAutoLabel") @getModel().set labelText: value ignored: false diff --git a/modules/ServerAPI/src/client/Thing.coffee b/modules/ServerAPI/src/client/Thing.coffee index 71907c2c4..8317f5c68 100644 --- a/modules/ServerAPI/src/client/Thing.coffee +++ b/modules/ServerAPI/src/client/Thing.coffee @@ -72,7 +72,10 @@ class Thing extends Backbone.Model attsToSave = super(options) if @deleteEmptyLabelsValsItxsBeforeSave toDel = attsToSave.lsLabels.filter (lab) -> - (lab.get('ignored') || lab.get('labelText')=="") && lab.isNew() + isAutoLabel = false + if typeof(lab.get("isAutoLabel")) != "undefined" && lab.get("isAutoLabel") == true + isAutoLabel = true + (lab.get('ignored') || (lab.get('labelText')=="" && !isAutoLabel)) && lab.isNew() for lab in toDel attsToSave.lsLabels.remove lab @@ -217,6 +220,13 @@ class Thing extends Backbone.Model newLabel.set key: dLabel.key newLabel.set preferred: dLabel.preferred + # If auto label is set then use it (evaluating only to true if set to true) + # Otherwise set the deafault to false + isAutoLabel = false + if typeof(dLabel.isAutoLabel) != "undefined" && dLabel.isAutoLabel==true + isAutoLabel = true + newLabel.set isAutoLabel: isAutoLabel + newLabel.set unique: dLabel.unique newLabel.set thingType: @get("lsType") newLabel.set thingKind: @get("lsKind")