dashlet options clone

This commit is contained in:
yuri
2015-03-23 10:04:34 +02:00
parent 5de509a0de
commit 7ab28601ca
2 changed files with 26 additions and 25 deletions
@@ -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);
+11 -11
View File
@@ -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: '<div class="list-container">{{{list}}}</div>',
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);
},
});
});