mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-18 00:17:25 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user