[DE][PE] Refactoring table templates loading

This commit is contained in:
Julia Radzhabova 2021-09-24 18:25:11 +03:00
parent d4fb8b4a64
commit 197a0f0fbc
2 changed files with 16 additions and 8 deletions

View file

@ -232,7 +232,7 @@ define([
setApi: function(o) { setApi: function(o) {
this.api = o; this.api = o;
if (o) { if (o) {
this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this._onInitTemplates, this)); this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this.onInitTableTemplates, this));
} }
return this; return this;
}, },
@ -240,7 +240,7 @@ define([
createDelayedControls: function() { createDelayedControls: function() {
var me = this; var me = this;
this._tableTemplates && this._onInitTemplates(this._tableTemplates); this._tableTemplates && this._onInitTemplates();
this.chHeader = new Common.UI.CheckBox({ this.chHeader = new Common.UI.CheckBox({
el: $('#table-checkbox-header'), el: $('#table-checkbox-header'),
@ -730,12 +730,16 @@ define([
!this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor()); !this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor());
}, },
_onInitTemplates: function(Templates){ onInitTableTemplates: function(){
if (this._initSettings) { if (this._initSettings) {
this._tableTemplates = Templates; this._tableTemplates = true;
return; return;
} }
this._onInitTemplates();
},
_onInitTemplates: function(){
var Templates = this.api.asc_getTableStylesPreviews();
var self = this; var self = this;
this._isTemplatesChanged = true; this._isTemplatesChanged = true;

View file

@ -219,7 +219,7 @@ define([
setApi: function(o) { setApi: function(o) {
this.api = o; this.api = o;
if (o) { if (o) {
this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this._onInitTemplates, this)); this.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(this.onInitTableTemplates, this));
} }
return this; return this;
}, },
@ -227,7 +227,7 @@ define([
createDelayedControls: function() { createDelayedControls: function() {
var me = this; var me = this;
this._tableTemplates && this._onInitTemplates(this._tableTemplates); this._tableTemplates && this._onInitTemplates();
this.chHeader = new Common.UI.CheckBox({ this.chHeader = new Common.UI.CheckBox({
el: $('#table-checkbox-header'), el: $('#table-checkbox-header'),
@ -671,12 +671,16 @@ define([
!this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor()); !this.btnBorderColor.isAutoColor() && this.btnBorderColor.setColor(this.borderColor.getColor());
}, },
_onInitTemplates: function(Templates){ onInitTableTemplates: function(){
if (this._initSettings) { if (this._initSettings) {
this._tableTemplates = Templates; this._tableTemplates = true;
return; return;
} }
this._onInitTemplates();
},
_onInitTemplates: function(){
var Templates = this.api.asc_getTableStylesPreviews();
var self = this; var self = this;
this._isTemplatesChanged = true; this._isTemplatesChanged = true;