Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

739-auto-sequence-thing-label #740

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion modules/Components/src/client/ACASFormFields.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion modules/ServerAPI/src/client/Thing.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Typo in deafault

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")
Expand Down