diff --git a/client/core/src/watcher/watcher.js b/client/core/src/watcher/watcher.js index bbe298bb4..5108174cd 100644 --- a/client/core/src/watcher/watcher.js +++ b/client/core/src/watcher/watcher.js @@ -12,12 +12,13 @@ import isFullEmpty from '../lib/fullEmpty'; * properties are provided. */ export default class Watcher extends Component { - constructor($element, $scope, $state, $transitions, $http, vnApp, $translate) { + constructor($element, $scope, $state, $transitions, $http, vnApp, $translate, $attrs) { super($element); this.$scope = $scope; this.$state = $state; this.$http = $http; this.$translate = $translate; + this.$attrs = $attrs; this.vnApp = vnApp; this.state = null; @@ -93,7 +94,7 @@ export default class Watcher extends Component { (resolve, reject) => this.noChanges(reject) ); } - let changedData = getModifiedData(this.data, this.orgData); + let changedData = this.$attrs.save === 'post' ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData); if (this.save) { this.save.model = changedData; // this.copyInNewObject(changedData); @@ -194,7 +195,7 @@ export default class Watcher extends Component { } } -Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate']; +Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate', '$attrs']; module.component('vnWatcher', { template: require('./watcher.html'), diff --git a/client/core/src/watcher/watcher.spec.js b/client/core/src/watcher/watcher.spec.js index 5faba7934..e27efc9f0 100644 --- a/client/core/src/watcher/watcher.spec.js +++ b/client/core/src/watcher/watcher.spec.js @@ -11,6 +11,7 @@ describe('Component vnWatcher', () => { let vnApp; let $translate; let controller; + let $attrs; beforeEach(() => { angular.mock.module('client'); @@ -25,7 +26,10 @@ describe('Component vnWatcher', () => { $transitions = _$transitions_; $httpBackend = _$httpBackend_; $translate = _$translate_; - controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate}); + $attrs = { + save: "patch" + }; + controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate, $attrs}); })); describe('$onInit()', () => {