From a4ecfe5ad726fb86d9b710fd22db219ba6d1d435 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Thu, 2 May 2024 20:07:46 +0300 Subject: [PATCH] [SSE] Fix generate new sheet names --- .../main/app/controller/Statusbar.js | 26 ++++++++++++------- .../main/app/view/Statusbar.js | 24 +++-------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 9bd73beee0..391551bcb3 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -110,6 +110,9 @@ define([ this.api.asc_registerCallback('asc_onFilterInfo', _.bind(this.onApiFilterInfo , this)); this.api.asc_registerCallback('asc_onActiveSheetChanged', _.bind(this.onApiActiveSheetChanged, this)); this.api.asc_registerCallback('asc_onRefreshNamedSheetViewList', _.bind(this.onRefreshNamedSheetViewList, this)); + this.api.asc_registerCallback('asc_generateNewSheetNames', _.bind(function (arrNames, callback) { + callback(this.generateSheetNames(false, undefined, arrNames)); + }, this)); this.statusbar.setApi(api); }, @@ -383,7 +386,7 @@ define([ return name; }, - generateSheetNames: function (copy, sheetIndexes, otherWorksheetNames) { + generateSheetNames: function (copy, arrIndexes, arrNames) { var me = this, names = []; if (copy) { @@ -392,14 +395,17 @@ define([ names.push(this.api.asc_getWorksheetName(wc).toLowerCase()); } } - otherWorksheetNames && otherWorksheetNames.forEach(function (item) { - names.push(item.toLowerCase()); - }); var newNames = []; - sheetIndexes.forEach(function (item) { - newNames.push(me.createCopyName(copy, me.api.asc_getWorksheetName(item), newNames, names)); - }); + if (arrIndexes) { + arrIndexes.forEach(function (item) { + newNames.push(me.createCopyName(copy, me.api.asc_getWorksheetName(item), newNames, names)); + }); + } else if (arrNames) { + arrNames.forEach(function (item) { + newNames.push(me.createCopyName(copy, item, newNames, names)); + }); + } return newNames; }, @@ -517,7 +523,7 @@ define([ sheets : items, spreadsheetName: me.api.asc_getDocumentName(), isDesktopApp: me.statusbar.mode.isDesktopApp, - handler : function(btn, i, copy, workbook, names) { + handler : function(btn, i, copy, workbook) { if (btn == 'ok') { var arrBooks, arrNames; @@ -527,13 +533,13 @@ define([ else if (workbook !== 'current') arrBooks = [workbook]; if (workbook !== 'current') { - arrNames = me.generateSheetNames(copy, arrIndex, names); + arrNames = me.generateSheetNames(copy, arrIndex); } } if (!copy) { me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex, arrNames, arrBooks); } else { - arrNames = me.generateSheetNames(copy, arrIndex, names); + arrNames = me.generateSheetNames(copy, arrIndex); me.api.asc_copyWorksheet(i == -255 ? wc : i, arrNames, arrIndex, arrBooks); } } diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 6150ab2d1e..4e53d5f72c 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1351,16 +1351,6 @@ define([ } }, - getSheetNames: function (sheets) { - if (sheets) { - var names = []; - sheets.forEach(function (item) { - names.push(item.value); - }); - return names; - } - }, - getFocusedComponents: function() { return [this.cmbSpreadsheet, this.listNames, this.chCreateCopy].concat(this.getFooterButtons()); }, @@ -1390,12 +1380,9 @@ define([ if (index === -255) index = this.listNames.store.length - 1; - var record = this.cmbSpreadsheet.getSelectedRecord(), - sheetNames; - if (record.value !== 'current' && record.value !== 'new') - sheetNames = this.getSheetNames(this.sheets[record.index]); + var record = this.cmbSpreadsheet.getSelectedRecord(); this.options.handler.call(this, - event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', record.value, sheetNames); + event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', record.value); } this.close(); @@ -1408,11 +1395,8 @@ define([ if (index === -255) index = this.listNames.store.length - 1; - var record = this.cmbSpreadsheet.getSelectedRecord(), - sheetNames; - if (record.value !== 'current' && record.value !== 'new') - sheetNames = this.getSheetNames(this.sheets[record.index]); - this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', record.value, sheetNames); + var record = this.cmbSpreadsheet.getSelectedRecord(); + this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', record.value); } this.close();