From 37bda824ae7b8e3e14acd0853f027c97158379a9 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 4 Oct 2021 15:56:34 +0300 Subject: [PATCH] [DE PE SSE] Refactoring DataViewShape --- apps/common/main/lib/component/DataView.js | 8 +++++--- apps/documenteditor/main/app/controller/Toolbar.js | 5 ++--- apps/documenteditor/main/app/view/ShapeSettings.js | 3 +-- apps/presentationeditor/main/app/view/ShapeSettings.js | 3 +-- apps/presentationeditor/main/app/view/Toolbar.js | 2 +- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 5 ++--- apps/spreadsheeteditor/main/app/view/ShapeSettings.js | 3 +-- 7 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/common/main/lib/component/DataView.js b/apps/common/main/lib/component/DataView.js index 2cda7dae4..d8be28189 100644 --- a/apps/common/main/lib/component/DataView.js +++ b/apps/common/main/lib/component/DataView.js @@ -1316,7 +1316,7 @@ define([ Common.UI.DataViewShape = Common.UI.DataViewSimple.extend(_.extend({ template: _.template([ '
', - '<% _.each(options.groups, function(group, index) { %>', + '<% _.each(options.groupsWithRecent, function(group, index) { %>', '
style="display: none;" <% } %>>', '<% if (!_.isEmpty(group.groupName)) { %>', '
', @@ -1340,7 +1340,7 @@ define([ var filter = Common.localStorage.getKeysFilter(); this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : ''; - me.groups = options.groups; + me.groups = options.groups.toJSON(); if (options.isFromImage) { var store = me.groups[0].groupStore.clone(); store.shift(); @@ -1364,6 +1364,8 @@ define([ groupHeight : height }); + me.options.groupsWithRecent = me.groups; + var store = new Common.UI.DataViewStore(); _.each(me.groups, function (group) { @@ -1386,7 +1388,7 @@ define([ _.each(me.cmpEl.find('div.grouped-data'), function (group, indexGroup) { _.each($(group).find('div.item'), function (item, index) { var $item = $(item), - rec = me.options.groups[indexGroup].groupStore.at(index); + rec = me.groups[indexGroup].groupStore.at(index); me.dataViewItems.push({el: $item, groupIndex: indexGroup, index: index}); var tip = rec.get('tip'); if (tip) { diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index a373a274c..a58af342e 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2640,8 +2640,7 @@ define([ }, fillAutoShapes: function() { - var me = this, - shapesStore = this.getApplication().getCollection('ShapeGroups'); + var me = this; var menuitem = new Common.UI.MenuItem({ template: _.template('') @@ -2653,7 +2652,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-toolbar-menu-insertshape'), itemTemplate: _.template('
\">
'), - groups: shapesStore.toJSON(), + groups: me.getApplication().getCollection('ShapeGroups'), parentMenu: me.toolbar.btnInsertShape.menu, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed, diff --git a/apps/documenteditor/main/app/view/ShapeSettings.js b/apps/documenteditor/main/app/view/ShapeSettings.js index 63877cc67..eb59fede3 100644 --- a/apps/documenteditor/main/app/view/ShapeSettings.js +++ b/apps/documenteditor/main/app/view/ShapeSettings.js @@ -1788,7 +1788,6 @@ define([ fillAutoShapes: function() { var me = this, - shapesStore = this.application.getCollection('ShapeGroups'), recents = Common.localStorage.getItem('de-recent-shapes'); for (var i = 0; i < 2; i++) { @@ -1801,7 +1800,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-change-shape-menu-' + i), itemTemplate: _.template('
\">
'), - groups: shapesStore.toJSON(), + groups: me.application.getCollection('ShapeGroups'), parentMenu: me.btnChangeShape.menu, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed, diff --git a/apps/presentationeditor/main/app/view/ShapeSettings.js b/apps/presentationeditor/main/app/view/ShapeSettings.js index 6479b17a7..71194d5cc 100644 --- a/apps/presentationeditor/main/app/view/ShapeSettings.js +++ b/apps/presentationeditor/main/app/view/ShapeSettings.js @@ -1642,7 +1642,6 @@ define([ fillAutoShapes: function() { var me = this, - shapesStore = this.application.getCollection('ShapeGroups'), recents = Common.localStorage.getItem('pe-recent-shapes'); for (var i = 0; i < 2; i++) { @@ -1655,7 +1654,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-change-shape-menu-' + i), itemTemplate: _.template('
\">
'), - groups: shapesStore.toJSON(), + groups: me.application.getCollection('ShapeGroups'), parentMenu: me.btnChangeShape.menu, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed, diff --git a/apps/presentationeditor/main/app/view/Toolbar.js b/apps/presentationeditor/main/app/view/Toolbar.js index a997cc9d0..3252c4cc0 100644 --- a/apps/presentationeditor/main/app/view/Toolbar.js +++ b/apps/presentationeditor/main/app/view/Toolbar.js @@ -1715,7 +1715,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-toolbar-menu-insertshape-'+index), itemTemplate: _.template('
\">
'), - groups: collection.toJSON(), + groups: collection, parentMenu: menuShape, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed, diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index eb91dfd16..d8036d911 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -3155,8 +3155,7 @@ define([ }, fillAutoShapes: function() { - var me = this, - shapesStore = this.getApplication().getCollection('ShapeGroups'); + var me = this; var menuitem = new Common.UI.MenuItem({ template: _.template('') @@ -3168,7 +3167,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-toolbar-menu-insertshape'), itemTemplate: _.template('
\">
'), - groups: shapesStore.toJSON(), + groups: me.getApplication().getCollection('ShapeGroups'), parentMenu: me.toolbar.btnInsertShape.menu, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed, diff --git a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js index da203e13b..5c61cf783 100644 --- a/apps/spreadsheeteditor/main/app/view/ShapeSettings.js +++ b/apps/spreadsheeteditor/main/app/view/ShapeSettings.js @@ -1660,7 +1660,6 @@ define([ fillAutoShapes: function() { var me = this, - shapesStore = this.application.getCollection('ShapeGroups'), recents = Common.localStorage.getItem('sse-recent-shapes'); for (var i = 0; i < 2; i++) { @@ -1673,7 +1672,7 @@ define([ var shapePicker = new Common.UI.DataViewShape({ el: $('#id-change-shape-menu-' + i), itemTemplate: _.template('
\">
'), - groups: shapesStore.toJSON(), + groups: me.application.getCollection('ShapeGroups'), parentMenu: me.btnChangeShape.menu, restoreHeight: 640, textRecentlyUsed: me.textRecentlyUsed,