Properly track changes in code attribute

If the code was initially nil, some value is added, and then removed, we
would not detect that the code has not actually changed.
This commit is contained in:
David Rodríguez
2025-11-04 11:27:27 +01:00
parent 4b31352e4f
commit 3d7207d8c5
2 changed files with 8 additions and 3 deletions

View File

@@ -4,15 +4,16 @@ angular.module("admin.indexUtils").directive "objForUpdate", (switchClass, pendi
type: "@objForUpdate"
attr: "@attrForUpdate"
link: (scope, element, attrs) ->
scope.savedValue = scope.object()[scope.attr]
scope.savedValue = scope.object()[scope.attr] || ""
scope.$watch "object().#{scope.attr}", (value) ->
if value == scope.savedValue
strValue = value || ""
if strValue == scope.savedValue
pendingChanges.remove(scope.object().id, scope.attr)
scope.clear()
else
scope.pending()
addPendingChange(scope.attr, value ? "")
addPendingChange(scope.attr, strValue)
scope.reset = (value) ->
scope.savedValue = value