From 0d43b02cab1e43ad8da6b130d2a9325c139ededa Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Tue, 22 Dec 2015 22:37:36 -0500 Subject: [PATCH] (js) Fix the "save" method of Component service --- .../js/Scheduler/Component.service.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/UI/WebServerResources/js/Scheduler/Component.service.js b/UI/WebServerResources/js/Scheduler/Component.service.js index 28a4fde18..5c0795ce0 100644 --- a/UI/WebServerResources/js/Scheduler/Component.service.js +++ b/UI/WebServerResources/js/Scheduler/Component.service.js @@ -1032,7 +1032,9 @@ * @desc Save the component to the server. */ Component.prototype.$save = function() { - var _this = this, options, path = [this.pid, this.id]; + var _this = this, options, path, component, date; + + component = this.$omit(); // Format dates and times component.startDate = component.start ? formatDate(component.start) : ''; @@ -1076,8 +1078,8 @@ if (this.alarm.action && this.alarm.action == 'email' && !(this.attendees && this.attendees.length > 0)) { // No attendees; email reminder must be sent to organizer only - this.alarm.attendees = 0; - this.alarm.organizer = 1; + component.alarm.attendees = 0; + component.alarm.organizer = 1; } } else { @@ -1085,13 +1087,15 @@ } // Build URL + path = [this.pid, this.id]; + if (this.isNew) options = { action: 'saveAs' + this.type.capitalize() }; if (this.occurrenceId) path.push(this.occurrenceId); - return Component.$$resource.save(path.join('/'), this.$omit(), options) + return Component.$$resource.save(path.join('/'), component, options) .then(function(data) { // Make a copy of the data for an eventual reset _this.$shadowData = _this.$omit(); @@ -1169,7 +1173,7 @@ * @return an object literal copy of the Component instance */ Component.prototype.$omit = function() { - var component = {}, date; + var component = {}; angular.forEach(this, function(value, key) { if (key != 'constructor' && key[0] != '$' &&