From 7ab28601ca7b51b4ddcb8b95b05bb511fb3f3128 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 23 Mar 2015 10:04:34 +0200 Subject: [PATCH] dashlet options clone --- .../src/views/dashlets/abstract/base.js | 29 ++++++++++--------- frontend/client/src/views/dashlets/stream.js | 22 +++++++------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/frontend/client/src/views/dashlets/abstract/base.js b/frontend/client/src/views/dashlets/abstract/base.js index 9064e8aaa4..331ce18f3b 100644 --- a/frontend/client/src/views/dashlets/abstract/base.js +++ b/frontend/client/src/views/dashlets/abstract/base.js @@ -17,7 +17,7 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Dashlets.Abstract.Base', 'View', function (Dep) { @@ -50,33 +50,34 @@ Espo.define('Views.Dashlets.Abstract.Base', 'View', function (Dep) { this.defaultOptions = _.extend({ title: this.getLanguage().translate(this.name, 'dashlets'), }, this.defaultOptions || {}); - - - var options = _.clone(this.defaultOptions); - + + this.optionsFields = Espo.Utils.clone(this.optionsFields); + + var options = Espo.Utils.clone(this.defaultOptions); + for (var key in options) { if (typeof options[key] == 'function') { options[key] = options[key].call(this); - } + } } var storedOptions = this.getPreferences().getDashletOptions(this.options.id) || {}; - + this.optionsData = _.extend(options, storedOptions); - + if (this.optionsData.autorefreshInterval || false) { - var interval = this.optionsData.autorefreshInterval * 60000; - - var t; + var interval = this.optionsData.autorefreshInterval * 60000; + + var t; var process = function () { t = setTimeout(function () { this.actionRefresh(); - process(); + process(); }.bind(this), interval); }.bind(this); - + process(); - + this.once('remove', function () { clearTimeout(t); }, this); diff --git a/frontend/client/src/views/dashlets/stream.js b/frontend/client/src/views/dashlets/stream.js index 796590b6c0..99427abd73 100644 --- a/frontend/client/src/views/dashlets/stream.js +++ b/frontend/client/src/views/dashlets/stream.js @@ -17,12 +17,12 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ Espo.define('Views.Dashlets.Stream', 'Views.Dashlets.Abstract.Base', function (Dep) { return Dep.extend({ - + name: 'Stream', defaultOptions: { @@ -30,9 +30,9 @@ Espo.define('Views.Dashlets.Stream', 'Views.Dashlets.Abstract.Base', function (D autorefreshInterval: 0.5, isDoubleHeight: false }, - + _template: '
{{{list}}}
', - + optionsFields: _.extend(_.clone(Dep.prototype.optionsFields), { 'displayRecords': { type: 'enumInt', @@ -42,19 +42,19 @@ Espo.define('Views.Dashlets.Stream', 'Views.Dashlets.Abstract.Base', function (D type: 'bool', }, }), - + actionRefresh: function () { this.getView('list').showNewRecords(); }, - + afterRender: function () { - + this.getCollectionFactory().create('Note', function (collection) { this.collection = collection; - + collection.url = 'Stream'; collection.maxSize = this.getOption('displayRecords'); - + this.listenToOnce(collection, 'sync', function () { this.createView('list', 'Stream.List', { el: this.options.el + ' > .list-container', @@ -66,10 +66,10 @@ Espo.define('Views.Dashlets.Stream', 'Views.Dashlets.Abstract.Base', function (D }); }.bind(this)); collection.fetch(); - + }, this); }, - + }); });