From adc766978025a99769a7e1b2a7fb125933f14026 Mon Sep 17 00:00:00 2001 From: tomasz stryjewski Date: Thu, 25 Jun 2015 11:35:08 +0200 Subject: [PATCH] enhances BaseObject constructor --- modules/Object.js | 8 ++++---- modules/Task/Task.js | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/Object.js b/modules/Object.js index 5942cf4..f18ebb0 100644 --- a/modules/Object.js +++ b/modules/Object.js @@ -3,8 +3,8 @@ var module = angular.module('App'); module.factory('BaseObject', () => { class BaseObject { - constructor(data) { - Object.assign(this, data); + constructor(...datas) { + Object.assign(this, ...datas); } /** @@ -40,11 +40,11 @@ module.factory('BaseObject', () => { /** * Make a copy of object for use in forms - * + * * When you edit a record in a form, you want the original to be preserved while the user makes changes * This allows you to edit a record exactly as if you were creating one without having to worry about * rolling back changes to the object. - * + * * @note This makes a shallow copy only */ clone() { diff --git a/modules/Task/Task.js b/modules/Task/Task.js index 9020720..8796301 100644 --- a/modules/Task/Task.js +++ b/modules/Task/Task.js @@ -97,6 +97,10 @@ module.factory( 'Task', (BaseObject, $http) => { } + constructor(...datas) { + super({ done : false }, ...datas); + } + create() { return $http.post('/api/tasks', this) .then( (response) => {