From c9d88e57f0ffc3fac0cd4cba1da81007da449a73 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 19 Apr 2024 21:14:59 +0300 Subject: [PATCH 01/11] [SSE] Change copy move dialog --- .../main/app/controller/Statusbar.js | 15 ++-- .../main/app/view/Statusbar.js | 71 ++++++++++++------- apps/spreadsheeteditor/main/locale/en.json | 11 +-- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 09b2b2b34b..3cee33fff2 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -314,11 +314,8 @@ define([ case 'ren': this.renameWorksheet(); break; - case 'copy': - this.moveWorksheet(arrIndex, false); - break; - case 'move': - this.moveWorksheet(arrIndex, true); + case 'move-copy': + this.moveWorksheet(arrIndex); break; case 'hide': setTimeout(function () { @@ -501,12 +498,12 @@ define([ } (new SSE.Views.Statusbar.CopyDialog({ - title : cut ? me.statusbar.itemMove : me.statusbar.itemCopy, - ismove : cut, + title : me.statusbar.itemMoveOrCopy, names : items, - handler : function(btn, i) { + isDesktopApp: true,//me.statusbar.mode.isDesktopApp, + handler : function(btn, i, copy) { if (btn == 'ok') { - if (cut) { + if (!copy) { me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex); } else { var arrNames = []; diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index ee12d092ff..1690d47b95 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -341,8 +341,7 @@ define([ {caption: this.itemInsert, value: 'ins'}, {caption: this.itemDelete, value: 'del'}, {caption: this.itemRename, value: 'ren'}, - {caption: this.itemCopy, value: 'copy'}, - {caption: this.itemMove, value: 'move'}, + {caption: this.itemMoveOrCopy, value: 'move-copy'}, {caption: this.itemHide, value: 'hide'}, { caption: this.itemHidden, @@ -532,8 +531,8 @@ define([ var me = this; this.tabbar.empty(true); - this.tabMenu.items[6].menu.removeAll(); - this.tabMenu.items[6].hide(); + this.tabMenu.items[5].menu.removeAll(); + this.tabMenu.items[5].hide(); this.btnAddWorksheet.setDisabled(true); this.sheetListMenu.removeAll(); @@ -564,13 +563,13 @@ define([ if (hidentems.length) { hidentems.forEach(function(item){ - me.tabMenu.items[6].menu.addItem(new Common.UI.MenuItem({ + me.tabMenu.items[5].menu.addItem(new Common.UI.MenuItem({ style: 'white-space: pre-wrap', caption: item.label, value: item.sheetindex })); }); - this.tabMenu.items[6].show(); + this.tabMenu.items[5].show(); } this.tabbar.add(items); @@ -737,22 +736,21 @@ define([ this.tabMenu.items[2].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[3].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[4].setDisabled(issheetlocked || isdocprotected); - this.tabMenu.items[5].setDisabled(issheetlocked || isdocprotected); - this.tabMenu.items[6].setDisabled(isdoclocked || isdocprotected); - this.tabMenu.items[7].setDisabled(select.length>1); - this.tabMenu.items[8].setDisabled(issheetlocked || isdocprotected); + this.tabMenu.items[5].setDisabled(isdoclocked || isdocprotected); + this.tabMenu.items[6].setDisabled(select.length>1); + this.tabMenu.items[7].setDisabled(issheetlocked || isdocprotected); - this.tabMenu.items[7].setVisible(!this.mode.isEditOle && this.mode.canProtect); - this.tabMenu.items[7].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); + this.tabMenu.items[6].setVisible(!this.mode.isEditOle && this.mode.canProtect); + this.tabMenu.items[6].setCaption(this.api.asc_isProtectedSheet() ? this.itemUnProtect : this.itemProtect); if (select.length === 1) { - this.tabMenu.items[11].hide(); + this.tabMenu.items[10].hide(); } else { - this.tabMenu.items[11].show(); + this.tabMenu.items[10].show(); } + this.tabMenu.items[9].setDisabled(issheetlocked || isdocprotected); this.tabMenu.items[10].setDisabled(issheetlocked || isdocprotected); - this.tabMenu.items[11].setDisabled(issheetlocked || isdocprotected); this.api.asc_closeCellEditor(); this.api.asc_enableKeyEvents(false); @@ -1061,8 +1059,7 @@ define([ itemInsert : 'Insert', itemDelete : 'Delete', itemRename : 'Rename', - itemCopy : 'Copy', - itemMove : 'Move', + itemMoveOrCopy : 'Move or copy', itemHide : 'Hide', itemHidden : 'Hidden', itemTabColor : 'Tab Color', @@ -1212,15 +1209,23 @@ define([ }, template: '
' + + '<% if (isDesktopApp) { %>' + '
' + - '' + + '' + '
' + - '
' + + '
' + + '<% } %>' + + '
' + + '' + + '
' + + '
' + + '
' + '
', initialize : function(options) { _.extend(this.options, options || {}, { - label: options.ismove ? this.textMoveBefore : this.textCopyBefore + labelSpreadsheet: this.textSpreadsheet, + labelMoveBefore: this.textMoveBefore }); this.options.tpl = _.template(this.template)(this.options); @@ -1233,6 +1238,14 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); + this.cmbSpreadsheet = new Common.UI.ComboBox({ + el: $('#status-cmb-spreadsheet', this.$window), + menuStyle: 'min-width: 100%;', + cls: 'input-group-nr', + data: [], + editable: false + }); + var pages = []; this.options.names.forEach(function(item){ pages.push(new Common.UI.DataViewModel(item)); @@ -1240,7 +1253,7 @@ define([ if (pages.length) { pages.push(new Common.UI.DataViewModel({ - value : this.options.ismove ? this.itemMoveToEnd : this.itemCopyToEnd, + value : this.itemMoveToEnd, inindex : -255 })); } @@ -1257,6 +1270,12 @@ define([ this.listNames.on('entervalue', _.bind(this.onPrimary, this)); this.listNames.on('item:dblclick', _.bind(this.onPrimary, this)); + this.chCreateCopy = new Common.UI.CheckBox({ + el: $('#status-ch-create-copy', $window), + labelText: this.textCreateCopy, + value: false + }); + this.mask = $('.modals-mask'); this.mask.on('mousedown',_.bind(this.onUpdateFocus, this)); }, @@ -1288,7 +1307,7 @@ define([ if (this.options.handler) { this.options.handler.call(this, - event.currentTarget.attributes['result'].value, active.get('inindex')); + event.currentTarget.attributes['result'].value, active.get('inindex'), this.chCreateCopy.getValue()==='checked'); } this.close(); @@ -1296,7 +1315,7 @@ define([ onPrimary: function() { if (this.options.handler) { - this.options.handler.call(this, 'ok', this.listNames.getSelectedRec().get('inindex')); + this.options.handler.call(this, 'ok', this.listNames.getSelectedRec().get('inindex'), this.chCreateCopy.getValue()==='checked'); } this.close(); @@ -1308,10 +1327,10 @@ define([ }, 100, this); }, - itemCopyToEnd : '(Copy to end)', itemMoveToEnd : '(Move to end)', - textCopyBefore : 'Copy before sheet', - textMoveBefore : 'Move before sheet' + textMoveBefore : 'Move before sheet', + textCreateCopy : 'Create a copy', + textSpreadsheet : 'Spreadsheet' }, CopyDialog||{})); } diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index f94b39346a..b13a450e3b 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -3807,14 +3807,16 @@ "SSE.Views.Spellcheck.txtDictionaryLanguage": "Dictionary language", "SSE.Views.Spellcheck.txtNextTip": "Go to the next word", "SSE.Views.Spellcheck.txtSpelling": "Spelling", - "SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", + "del_SSE.Views.Statusbar.CopyDialog.itemCopyToEnd": "(Copy to end)", "SSE.Views.Statusbar.CopyDialog.itemMoveToEnd": "(Move to end)", - "SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Paste before sheet", + "del_SSE.Views.Statusbar.CopyDialog.textCopyBefore": "Paste before sheet", "SSE.Views.Statusbar.CopyDialog.textMoveBefore": "Move before sheet", + "SSE.Views.Statusbar.CopyDialog.textCreateCopy": "Create a copy", + "SSE.Views.Statusbar.CopyDialog.textSpreadsheet": "Spreadsheet", "SSE.Views.Statusbar.filteredRecordsText": "{0} of {1} records filtered", "SSE.Views.Statusbar.filteredText": "Filter mode", "SSE.Views.Statusbar.itemAverage": "Average", - "SSE.Views.Statusbar.itemCopy": "Copy", + "del_SSE.Views.Statusbar.itemCopy": "Copy", "SSE.Views.Statusbar.itemCount": "Count", "SSE.Views.Statusbar.itemDelete": "Delete", "SSE.Views.Statusbar.itemHidden": "Hidden", @@ -3822,7 +3824,7 @@ "SSE.Views.Statusbar.itemInsert": "Insert", "SSE.Views.Statusbar.itemMaximum": "Maximum", "SSE.Views.Statusbar.itemMinimum": "Minimum", - "SSE.Views.Statusbar.itemMove": "Move", + "del_SSE.Views.Statusbar.itemMove": "Move", "SSE.Views.Statusbar.itemProtect": "Protect", "SSE.Views.Statusbar.itemRename": "Rename", "SSE.Views.Statusbar.itemStatus": "Saving status", @@ -3852,6 +3854,7 @@ "SSE.Views.Statusbar.tipZoomOut": "Zoom out", "SSE.Views.Statusbar.ungroupSheets": "Ungroup sheets", "SSE.Views.Statusbar.zoomText": "Zoom {0}%", + "SSE.Views.Statusbar.itemMoveOrCopy": "Move or copy", "SSE.Views.TableOptionsDialog.errorAutoFilterDataRange": "The operation could not be done for the selected range of cells.
Select a uniform data range different from the existing one and try again.", "SSE.Views.TableOptionsDialog.errorFTChangeTableRangeError": "Operation could not be completed for the selected cell range.
Select a range so that the first table row was on the same row
and the resulting table overlapped the current one.", "SSE.Views.TableOptionsDialog.errorFTRangeIncludedOtherTables": "Operation could not be completed for the selected cell range.
Select a range which does not include other tables.", From 9c5b61b6d6fefba32bf67bf2a62f56d777604133 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Thu, 25 Apr 2024 22:39:26 +0300 Subject: [PATCH 02/11] [SSE] Change copy move dialog (2) --- .../main/app/controller/Statusbar.js | 41 +++++-- .../main/app/view/Statusbar.js | 104 ++++++++++++++++-- apps/spreadsheeteditor/main/locale/en.json | 1 + 3 files changed, 126 insertions(+), 20 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 3cee33fff2..222245201c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -497,25 +497,50 @@ define([ return; } - (new SSE.Views.Statusbar.CopyDialog({ + var copyDialog = new SSE.Views.Statusbar.CopyDialog({ title : me.statusbar.itemMoveOrCopy, - names : items, - isDesktopApp: true,//me.statusbar.mode.isDesktopApp, - handler : function(btn, i, copy) { + sheets : items, + spreadsheetName: me.statusbar.mode.isDesktopApp && me.api.asc_getDocumentName(), + isDesktopApp: me.statusbar.mode.isDesktopApp, + handler : function(btn, i, copy, workbook) { if (btn == 'ok') { + var arrBooks, + arrNames; + if (workbook) { + if (workbook === 'new') + arrBooks = []; + else if (workbook !== 'current') + arrBooks = [workbook]; + if (workbook !== 'current') { + arrNames = []; + arrIndex.forEach(function (item) { + arrNames.push(me.api.asc_getWorksheetName(item)); + }); + } + } if (!copy) { - me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex); + me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex, arrNames, arrBooks); } else { - var arrNames = []; + arrNames = []; arrIndex.forEach(function (item) { arrNames.push(me.createCopyName(me.api.asc_getWorksheetName(item), arrNames)); }); - me.api.asc_copyWorksheet(i == -255 ? wc : i, arrNames, arrIndex); + me.api.asc_copyWorksheet(i == -255 ? wc : i, arrNames, arrIndex, arrBooks); } } me.api.asc_enableKeyEvents(true); } - })).show(); + }); + copyDialog.show(); + + if (me.statusbar.mode.isDesktopApp) { + var callback = function (workbooks) { + if (workbooks) { + copyDialog.changeSpreadsheets(workbooks); + } + }; + me.api.asc_getOpeningDocumentsList(callback); + } }, onAddWorksheetClick: function(o, index, opts) { diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 1690d47b95..d3769a4871 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1229,25 +1229,52 @@ define([ }); this.options.tpl = _.template(this.template)(this.options); + if (this.options.isDesktopApp) { + this.spreadsheets = { + data: [ + {displayValue: this.options.spreadsheetName, value: 'current', index: 0}, + {displayValue: this.textCreateNewSpreadsheet, value: 'new', index: -1} + ], + changed: false, + opened: false + }; + } + + this.sheets = [this.options.sheets]; + Common.UI.Window.prototype.initialize.call(this, this.options); }, render: function() { + var me = this; Common.UI.Window.prototype.render.call(this); var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - this.cmbSpreadsheet = new Common.UI.ComboBox({ - el: $('#status-cmb-spreadsheet', this.$window), - menuStyle: 'min-width: 100%;', - cls: 'input-group-nr', - data: [], - editable: false - }); + if (this.options.isDesktopApp) { + this.cmbSpreadsheet = new Common.UI.ComboBox({ + el: $('#status-cmb-spreadsheet', this.$window), + menuStyle: 'min-width: 100%;', + data: this.spreadsheets.data, + cls: 'input-group-nr', + editable: false + }); + this.cmbSpreadsheet.setValue('current'); + var showBefore = function () { + me.spreadsheets.opened = true; + if (me.spreadsheets.changed) { + me.cmbSpreadsheet.setData(me.spreadsheets.data) + me.cmbSpreadsheet.setValue('current'); + } + me.cmbSpreadsheet.off('show:before', showBefore); + }; + this.cmbSpreadsheet.on('show:before', showBefore); + this.cmbSpreadsheet.on('selected', _.bind(this.onChangeSpreadsheet, this)); + } var pages = []; - this.options.names.forEach(function(item){ + this.sheets[0].forEach(function(item){ pages.push(new Common.UI.DataViewModel(item)); }, this); @@ -1280,6 +1307,54 @@ define([ this.mask.on('mousedown',_.bind(this.onUpdateFocus, this)); }, + changeSpreadsheets: function (workbooks) { + this.spreadsheets.changed = true; + var me = this, + data = this.spreadsheets.data, + arr = data.slice(0,data.length-1), + ind = arr.length; + workbooks.forEach(function (workbook, index) { + arr.push({displayValue: workbook.asc_getName(), value: workbook.asc_getId(), index: ind+index}); + var sheets = workbook.asc_getSheets(), + arrSheets = []; + sheets.forEach(function (sheet) { + arrSheets.push({ + value: sheet.asc_getName(), + inindex: sheet.asc_getIndex() + }) + }); + me.sheets[ind+index] = arrSheets; + }); + arr.push(data[data.length-1]); + this.spreadsheets.data = arr; + if (this.spreadsheets.opened) { + this.cmbSpreadsheet.setData(this.spreadsheets.data); + this.cmbSpreadsheet.setValue('current'); + } + }, + + onChangeSpreadsheet: function (combo, record) { + var index = record.index, + sheets = this.sheets[index]; + if (sheets) { + var pages = []; + sheets.forEach(function(item){ + pages.push(new Common.UI.DataViewModel(item)); + }, this); + + if (pages.length) { + pages.push(new Common.UI.DataViewModel({ + value: this.itemMoveToEnd, + inindex: -255 + })); + } + this.listNames.store.reset(pages); + this.listNames.selectByIndex(0); + } else { + this.listNames.store.reset([]); + } + }, + getFocusedComponents: function() { return [this.listNames].concat(this.getFooterButtons()); }, @@ -1303,19 +1378,23 @@ define([ }, onBtnClick: function(event) { - var active = this.listNames.getSelectedRec(); + var active = this.listNames.getSelectedRec(), + index = active ? active.get('inindex') : 0; if (this.options.handler) { this.options.handler.call(this, - event.currentTarget.attributes['result'].value, active.get('inindex'), this.chCreateCopy.getValue()==='checked'); + event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet && this.cmbSpreadsheet.getSelectedRecord().value); } this.close(); }, onPrimary: function() { + var active = this.listNames.getSelectedRec(), + index = active ? active.get('inindex') : 0; + if (this.options.handler) { - this.options.handler.call(this, 'ok', this.listNames.getSelectedRec().get('inindex'), this.chCreateCopy.getValue()==='checked'); + this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet && this.cmbSpreadsheet.getSelectedRecord().value); } this.close(); @@ -1330,7 +1409,8 @@ define([ itemMoveToEnd : '(Move to end)', textMoveBefore : 'Move before sheet', textCreateCopy : 'Create a copy', - textSpreadsheet : 'Spreadsheet' + textSpreadsheet : 'Spreadsheet', + textCreateNewSpreadsheet: '(Create new spreadsheet)' }, CopyDialog||{})); } diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index b13a450e3b..e125fc7462 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -3813,6 +3813,7 @@ "SSE.Views.Statusbar.CopyDialog.textMoveBefore": "Move before sheet", "SSE.Views.Statusbar.CopyDialog.textCreateCopy": "Create a copy", "SSE.Views.Statusbar.CopyDialog.textSpreadsheet": "Spreadsheet", + "SSE.Views.Statusbar.CopyDialog.textCreateNewSpreadsheet": "(Create new spreadsheet)", "SSE.Views.Statusbar.filteredRecordsText": "{0} of {1} records filtered", "SSE.Views.Statusbar.filteredText": "Filter mode", "SSE.Views.Statusbar.itemAverage": "Average", From 65521a528616b2a922cb9e81eb43b141fb292420 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 26 Apr 2024 14:38:44 +0300 Subject: [PATCH 03/11] [SSE] Show workbooks not only for desktop --- .../main/app/controller/Statusbar.js | 16 +++-- .../main/app/view/Statusbar.js | 62 +++++++++---------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 222245201c..16a3aa97e8 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -500,7 +500,7 @@ define([ var copyDialog = new SSE.Views.Statusbar.CopyDialog({ title : me.statusbar.itemMoveOrCopy, sheets : items, - spreadsheetName: me.statusbar.mode.isDesktopApp && me.api.asc_getDocumentName(), + spreadsheetName: me.api.asc_getDocumentName(), isDesktopApp: me.statusbar.mode.isDesktopApp, handler : function(btn, i, copy, workbook) { if (btn == 'ok') { @@ -533,14 +533,12 @@ define([ }); copyDialog.show(); - if (me.statusbar.mode.isDesktopApp) { - var callback = function (workbooks) { - if (workbooks) { - copyDialog.changeSpreadsheets(workbooks); - } - }; - me.api.asc_getOpeningDocumentsList(callback); - } + var callback = function (workbooks) { + if (workbooks) { + copyDialog.changeSpreadsheets(workbooks); + } + }; + me.api.asc_getOpeningDocumentsList(callback); }, onAddWorksheetClick: function(o, index, opts) { diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index d3769a4871..f50d3415f1 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1209,12 +1209,10 @@ define([ }, template: '
' + - '<% if (isDesktopApp) { %>' + '
' + '' + '
' + '
' + - '<% } %>' + '
' + '' + '
' + @@ -1229,16 +1227,14 @@ define([ }); this.options.tpl = _.template(this.template)(this.options); - if (this.options.isDesktopApp) { - this.spreadsheets = { - data: [ - {displayValue: this.options.spreadsheetName, value: 'current', index: 0}, - {displayValue: this.textCreateNewSpreadsheet, value: 'new', index: -1} - ], - changed: false, - opened: false - }; - } + this.spreadsheets = { + data: [ + {displayValue: this.options.spreadsheetName, value: 'current', index: 0}, + {displayValue: this.textCreateNewSpreadsheet, value: 'new', index: -1} + ], + changed: false, + opened: false + }; this.sheets = [this.options.sheets]; @@ -1252,26 +1248,24 @@ define([ var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - if (this.options.isDesktopApp) { - this.cmbSpreadsheet = new Common.UI.ComboBox({ - el: $('#status-cmb-spreadsheet', this.$window), - menuStyle: 'min-width: 100%;', - data: this.spreadsheets.data, - cls: 'input-group-nr', - editable: false - }); - this.cmbSpreadsheet.setValue('current'); - var showBefore = function () { - me.spreadsheets.opened = true; - if (me.spreadsheets.changed) { - me.cmbSpreadsheet.setData(me.spreadsheets.data) - me.cmbSpreadsheet.setValue('current'); - } - me.cmbSpreadsheet.off('show:before', showBefore); - }; - this.cmbSpreadsheet.on('show:before', showBefore); - this.cmbSpreadsheet.on('selected', _.bind(this.onChangeSpreadsheet, this)); - } + this.cmbSpreadsheet = new Common.UI.ComboBox({ + el: $('#status-cmb-spreadsheet', this.$window), + menuStyle: 'min-width: 100%;', + data: this.spreadsheets.data, + cls: 'input-group-nr', + editable: false + }); + this.cmbSpreadsheet.setValue('current'); + var showBefore = function () { + me.spreadsheets.opened = true; + if (me.spreadsheets.changed) { + me.cmbSpreadsheet.setData(me.spreadsheets.data) + me.cmbSpreadsheet.setValue('current'); + } + me.cmbSpreadsheet.off('show:before', showBefore); + }; + this.cmbSpreadsheet.on('show:before', showBefore); + this.cmbSpreadsheet.on('selected', _.bind(this.onChangeSpreadsheet, this)); var pages = []; this.sheets[0].forEach(function(item){ @@ -1383,7 +1377,7 @@ define([ if (this.options.handler) { this.options.handler.call(this, - event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet && this.cmbSpreadsheet.getSelectedRecord().value); + event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet.getSelectedRecord().value); } this.close(); @@ -1394,7 +1388,7 @@ define([ index = active ? active.get('inindex') : 0; if (this.options.handler) { - this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet && this.cmbSpreadsheet.getSelectedRecord().value); + this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet.getSelectedRecord().value); } this.close(); From 731c2b5607786a0f2a5661bca1fe87e80d61ecca Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 26 Apr 2024 15:11:13 +0300 Subject: [PATCH 04/11] [SSE] Show create new workbook only for desktop --- apps/spreadsheeteditor/main/app/view/Statusbar.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index f50d3415f1..da0a6b6586 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1229,12 +1229,14 @@ define([ this.spreadsheets = { data: [ - {displayValue: this.options.spreadsheetName, value: 'current', index: 0}, - {displayValue: this.textCreateNewSpreadsheet, value: 'new', index: -1} + {displayValue: this.options.spreadsheetName, value: 'current', index: 0} ], changed: false, opened: false }; + if (this.options.isDesktopApp) { + this.spreadsheets.data.push({displayValue: this.textCreateNewSpreadsheet, value: 'new', index: -1}); + } this.sheets = [this.options.sheets]; @@ -1305,7 +1307,7 @@ define([ this.spreadsheets.changed = true; var me = this, data = this.spreadsheets.data, - arr = data.slice(0,data.length-1), + arr = this.options.isDesktopApp ? data.slice(0,data.length-1) : data, ind = arr.length; workbooks.forEach(function (workbook, index) { arr.push({displayValue: workbook.asc_getName(), value: workbook.asc_getId(), index: ind+index}); @@ -1319,7 +1321,7 @@ define([ }); me.sheets[ind+index] = arrSheets; }); - arr.push(data[data.length-1]); + this.options.isDesktopApp && arr.push(data[data.length-1]); this.spreadsheets.data = arr; if (this.spreadsheets.opened) { this.cmbSpreadsheet.setData(this.spreadsheets.data); From d2766fee83d3c9b01f6cbb75a0af58de1e7ec0d5 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 26 Apr 2024 15:43:28 +0300 Subject: [PATCH 05/11] [SSE] Fix copy move dialog --- apps/spreadsheeteditor/main/app/controller/Statusbar.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 16a3aa97e8..2fe543903a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -497,7 +497,7 @@ define([ return; } - var copyDialog = new SSE.Views.Statusbar.CopyDialog({ + me.copyDialog = new SSE.Views.Statusbar.CopyDialog({ title : me.statusbar.itemMoveOrCopy, sheets : items, spreadsheetName: me.api.asc_getDocumentName(), @@ -531,11 +531,11 @@ define([ me.api.asc_enableKeyEvents(true); } }); - copyDialog.show(); + me.copyDialog.show(); var callback = function (workbooks) { if (workbooks) { - copyDialog.changeSpreadsheets(workbooks); + me.copyDialog.changeSpreadsheets(workbooks); } }; me.api.asc_getOpeningDocumentsList(callback); From a72a65b0180684bd1e437303dfdfee87e1d1c135 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Sat, 27 Apr 2024 17:03:13 +0300 Subject: [PATCH 06/11] [SSE] Fix copy move dialog (2) --- .../main/app/controller/Statusbar.js | 57 +++++++++++-------- .../main/app/view/Statusbar.js | 24 +++++++- 2 files changed, 54 insertions(+), 27 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 2fe543903a..b06b8aefa8 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -355,25 +355,23 @@ define([ return name; }, - createCopyName: function(orig, curArrNames) { - var wc = this.api.asc_getWorksheetsCount(), names = []; - while (wc--) { - names.push(this.api.asc_getWorksheetName(wc).toLowerCase()); - } - + createCopyName: function(copy, orig, curNames, names) { var re = /^(.*)\((\d)\)$/.exec(orig); var first = re ? re[1] : orig + ' '; - var index = 1, name; - while(true) { + var index = 1, name = orig; + if (copy) { + index++; + name = first + '(' + index + ')'; + } + while(names.indexOf(name.toLowerCase()) !== -1) { index++; name = first + '(' + index + ')'; - if (names.indexOf(name.toLowerCase()) < 0) break; } - if (curArrNames && curArrNames.length > 0) { + if (curNames && curNames.length > 0) { var arr = []; - curArrNames.forEach(function (item) { + curNames.forEach(function (item) { arr.push(item.toLowerCase()); }); while(arr.indexOf(name.toLowerCase()) !== -1) { @@ -385,6 +383,26 @@ define([ return name; }, + generateSheetNames: function (copy, sheetIndexes, otherWorksheetNames) { + var me = this, + names = []; + if (copy) { + var wc = this.api.asc_getWorksheetsCount(); + while (wc--) { + 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)); + }); + return newNames; + }, + deleteWorksheet: function(selectTabs) { var me = this; @@ -488,10 +506,7 @@ define([ me.api.asc_moveWorksheet(indTo, arrIndex); me.api.asc_enableKeyEvents(true); } else { - var arrNames = []; - arrIndex.forEach(function (item) { - arrNames.push(me.createCopyName(me.api.asc_getWorksheetName(item), arrNames)); - }); + var arrNames = me.generateSheetNames(!cut, arrIndex); me.api.asc_copyWorksheet(indTo, arrNames, arrIndex); } return; @@ -502,7 +517,7 @@ define([ sheets : items, spreadsheetName: me.api.asc_getDocumentName(), isDesktopApp: me.statusbar.mode.isDesktopApp, - handler : function(btn, i, copy, workbook) { + handler : function(btn, i, copy, workbook, names) { if (btn == 'ok') { var arrBooks, arrNames; @@ -512,19 +527,13 @@ define([ else if (workbook !== 'current') arrBooks = [workbook]; if (workbook !== 'current') { - arrNames = []; - arrIndex.forEach(function (item) { - arrNames.push(me.api.asc_getWorksheetName(item)); - }); + arrNames = me.generateSheetNames(copy, arrIndex, names); } } if (!copy) { me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex, arrNames, arrBooks); } else { - arrNames = []; - arrIndex.forEach(function (item) { - arrNames.push(me.createCopyName(me.api.asc_getWorksheetName(item), arrNames)); - }); + arrNames = me.generateSheetNames(copy, arrIndex, names); 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 da0a6b6586..5fa1dcb3d1 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1351,8 +1351,18 @@ define([ } }, + getSheetNames: function (sheets) { + if (sheets) { + var names = []; + sheets.forEach(function (item) { + names.push(item.value); + }); + return names; + } + }, + getFocusedComponents: function() { - return [this.listNames].concat(this.getFooterButtons()); + return [this.cmbSpreadsheet, this.listNames, this.chCreateCopy].concat(this.getFooterButtons()); }, getDefaultFocusableComponent: function () { @@ -1378,8 +1388,12 @@ define([ index = active ? active.get('inindex') : 0; if (this.options.handler) { + 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, - event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet.getSelectedRecord().value); + event.currentTarget.attributes['result'].value, index, this.chCreateCopy.getValue()==='checked', record.value, sheetNames); } this.close(); @@ -1390,7 +1404,11 @@ define([ index = active ? active.get('inindex') : 0; if (this.options.handler) { - this.options.handler.call(this, 'ok', index, this.chCreateCopy.getValue()==='checked', this.cmbSpreadsheet.getSelectedRecord().value); + 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); } this.close(); From 24be20fdad12641856d07a4ca45523fe7b4e6065 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Sat, 27 Apr 2024 19:49:24 +0300 Subject: [PATCH 07/11] [SSE] Fix copy move dialog (3) --- .../main/app/controller/Statusbar.js | 3 +++ .../spreadsheeteditor/main/app/view/Statusbar.js | 16 ++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index b06b8aefa8..9bd73beee0 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -540,6 +540,9 @@ define([ me.api.asc_enableKeyEvents(true); } }); + me.copyDialog.on('close', function () { + me.copyDialog = undefined; + }); me.copyDialog.show(); var callback = function (workbooks) { diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 5fa1dcb3d1..6150ab2d1e 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -1384,10 +1384,12 @@ define([ }, onBtnClick: function(event) { - var active = this.listNames.getSelectedRec(), - index = active ? active.get('inindex') : 0; - if (this.options.handler) { + var active = this.listNames.getSelectedRec(), + index = active ? active.get('inindex') : 0; + if (index === -255) + index = this.listNames.store.length - 1; + var record = this.cmbSpreadsheet.getSelectedRecord(), sheetNames; if (record.value !== 'current' && record.value !== 'new') @@ -1400,10 +1402,12 @@ define([ }, onPrimary: function() { - var active = this.listNames.getSelectedRec(), - index = active ? active.get('inindex') : 0; - if (this.options.handler) { + var active = this.listNames.getSelectedRec(), + index = active ? active.get('inindex') : 0; + if (index === -255) + index = this.listNames.store.length - 1; + var record = this.cmbSpreadsheet.getSelectedRecord(), sheetNames; if (record.value !== 'current' && record.value !== 'new') From a4ecfe5ad726fb86d9b710fd22db219ba6d1d435 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Thu, 2 May 2024 20:07:46 +0300 Subject: [PATCH 08/11] [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(); From 99aa03c4ed38ea7189ab34325233aeac65f8aa34 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Thu, 2 May 2024 21:03:20 +0300 Subject: [PATCH 09/11] [SSE] Refactoring copy/move sheet by drag and drop --- .../main/app/controller/Statusbar.js | 89 ++++++++++++++++- .../main/app/view/Statusbar.js | 97 ------------------- 2 files changed, 84 insertions(+), 102 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 391551bcb3..b9009d50c8 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -91,6 +91,87 @@ define([ this.bindViewEvents(this.statusbar, this.events); $('#id-tab-menu-new-color', this.statusbar.$el).on('click', _.bind(this.onNewBorderColor, this)); + + this.statusbar.tabbar.on({ + 'tab:dragstart': _.bind(function (dataTransfer, selectTabs) { + Common.Utils.isIE && (this.isDrop = false); + Common.UI.Menu.Manager.hideAll(); + this.api.asc_closeCellEditor(); + var arrTabs = [], + arrName = [], + me = this; + var wc = me.api.asc_getWorksheetsCount(), items = [], i = -1; + while (++i < wc) { + if (!this.api.asc_isWorksheetHidden(i)) { + items.push({ + value: me.api.asc_getWorksheetName(i), + inindex: i + }); + } + } + var arrSelectIndex = []; + selectTabs.forEach(function (item) { + arrSelectIndex.push(item.sheetindex); + }); + items.forEach(function (item) { + if (arrSelectIndex.indexOf(item.inindex) !== -1) { + arrTabs.push(item.inindex); + arrName.push(item.value); + } + }); + var stringSheet, arr = []; + stringSheet = this.api.asc_StartMoveSheet(_.clone(arrTabs)); + arr.push({type: 'onlyoffice', value: stringSheet}); + arr.push({type: 'indexes', value: arrTabs}); + arr.push({type: 'names', value: arrName}); + arr.push({type: 'key', value: Common.Utils.InternalSettings.get("sse-doc-info-key")}); + var json = JSON.stringify(arr); + if (!Common.Utils.isIE) { + dataTransfer.setData('onlyoffice', json); + } else { + dataTransfer.setData('text', 'sheet'); + this.dataTransfer = json; + } + this.dropTabs = selectTabs; + }, this), + 'tab:drop': _.bind(function (dataTransfer, index, copy) { + if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return; + Common.Utils.isIE && (this.isDrop = true); + var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer; + if (data) { + var arrData = JSON.parse(data); + if (arrData) { + var key = _.findWhere(arrData, {type: 'key'}).value; + if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) { + this.statusbar.fireEvent('sheet:move', [_.findWhere(arrData, {type: 'indexes'}).value, !copy, true, _.isNumber(index) ? index : this.api.asc_getWorksheetsCount()]); + Common.NotificationCenter.trigger('tabs:dragend', this); + } else { + var arrNames = _.findWhere(arrData, {type: 'names'}).value; + var newNames = this.generateSheetNames(false, undefined, arrNames); + var index = _.isNumber(index) ? index : this.api.asc_getWorksheetsCount(); + this.api.asc_EndMoveSheet(index, newNames, _.findWhere(arrData, {type: 'onlyoffice'}).value); + } + } + } + }, this), + 'tab:dragend': _.bind(function (cut) { + if (cut && !(Common.Utils.isIE && this.isDrop === false)) { + if (this.dropTabs.length > 0) { + var arr = []; + this.dropTabs.forEach(function (tab) { + arr.push(tab.sheetindex); + }); + this.api.asc_deleteWorksheet(arr); + } + } + this.dropTabs = undefined; + if (Common.Utils.isIE) { + this.isDrop = undefined; + this.dataTransfer = undefined; + } + Common.NotificationCenter.trigger('tabs:dragend', this); + }, this) + }); }, setApi: function(api) { @@ -389,11 +470,9 @@ define([ generateSheetNames: function (copy, arrIndexes, arrNames) { var me = this, names = []; - if (copy) { - var wc = this.api.asc_getWorksheetsCount(); - while (wc--) { - names.push(this.api.asc_getWorksheetName(wc).toLowerCase()); - } + var wc = this.api.asc_getWorksheetsCount(); + while (wc--) { + names.push(this.api.asc_getWorksheetName(wc).toLowerCase()); } var newNames = []; diff --git a/apps/spreadsheeteditor/main/app/view/Statusbar.js b/apps/spreadsheeteditor/main/app/view/Statusbar.js index 4e53d5f72c..e7c45a30a0 100644 --- a/apps/spreadsheeteditor/main/app/view/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/view/Statusbar.js @@ -204,103 +204,6 @@ define([ (me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles)) { me.fireEvent('sheet:changename'); } - }, this), - 'tab:dragstart': _.bind(function (dataTransfer, selectTabs) { - Common.Utils.isIE && (this.isDrop = false); - Common.UI.Menu.Manager.hideAll(); - this.api.asc_closeCellEditor(); - var arrTabs = [], - arrName = [], - me = this; - var wc = me.api.asc_getWorksheetsCount(), items = [], i = -1; - while (++i < wc) { - if (!this.api.asc_isWorksheetHidden(i)) { - items.push({ - value: me.api.asc_getWorksheetName(i), - inindex: i - }); - } - } - var arrSelectIndex = []; - selectTabs.forEach(function (item) { - arrSelectIndex.push(item.sheetindex); - }); - items.forEach(function (item) { - if (arrSelectIndex.indexOf(item.inindex) !== -1) { - arrTabs.push(item.inindex); - arrName.push(item.value); - } - }); - var stringSheet, arr = []; - stringSheet = this.api.asc_StartMoveSheet(_.clone(arrTabs)); - arr.push({type: 'onlyoffice', value: stringSheet}); - arr.push({type: 'indexes', value: arrTabs}); - arr.push({type: 'names', value: arrName}); - arr.push({type: 'key', value: Common.Utils.InternalSettings.get("sse-doc-info-key")}); - var json = JSON.stringify(arr); - if (!Common.Utils.isIE) { - dataTransfer.setData('onlyoffice', json); - } else { - dataTransfer.setData('text', 'sheet'); - this.dataTransfer = json; - } - this.dropTabs = selectTabs; - }, this), - 'tab:drop': _.bind(function (dataTransfer, index, copy) { - if (this.isEditFormula || (Common.Utils.isIE && this.dataTransfer === undefined)) return; - Common.Utils.isIE && (this.isDrop = true); - var data = !Common.Utils.isIE ? dataTransfer.getData('onlyoffice') : this.dataTransfer; - if (data) { - var arrData = JSON.parse(data); - if (arrData) { - var key = _.findWhere(arrData, {type: 'key'}).value; - if (Common.Utils.InternalSettings.get("sse-doc-info-key") === key) { - this.fireEvent('sheet:move', [_.findWhere(arrData, {type: 'indexes'}).value, !copy, true, _.isNumber(index) ? index : this.api.asc_getWorksheetsCount()]); - Common.NotificationCenter.trigger('tabs:dragend', this); - } else { - var names = [], wc = this.api.asc_getWorksheetsCount(); - while (wc--) { - names.push(this.api.asc_getWorksheetName(wc).toLowerCase()); - } - var newNames = []; - var arrNames = _.findWhere(arrData, {type: 'names'}).value; - arrNames.forEach(function (name) { - var ind = 1, - name = name; - var re = /^(.*)\((\d)\)$/.exec(name); - var first = re ? re[1] : name + ' '; - var arr = []; - newNames.length > 0 && newNames.forEach(function (item) { - arr.push(item.toLowerCase()); - }); - while (names.indexOf(name.toLowerCase()) !== -1 || arr.indexOf(name.toLowerCase()) !== -1) { - ind++; - name = first + '(' + ind + ')'; - } - newNames.push(name); - }); - var index = _.isNumber(index) ? index : this.api.asc_getWorksheetsCount(); - this.api.asc_EndMoveSheet(index, newNames, _.findWhere(arrData, {type: 'onlyoffice'}).value); - } - } - } - }, this), - 'tab:dragend': _.bind(function (cut) { - if (cut && !(Common.Utils.isIE && this.isDrop === false)) { - if (this.dropTabs.length > 0) { - var arr = []; - this.dropTabs.forEach(function (tab) { - arr.push(tab.sheetindex); - }); - me.api.asc_deleteWorksheet(arr); - } - } - this.dropTabs = undefined; - if (Common.Utils.isIE) { - this.isDrop = undefined; - this.dataTransfer = undefined; - } - Common.NotificationCenter.trigger('tabs:dragend', this); }, this) }); From 70d28285721a28e6cce63bc9125d93f2bbe7a9af Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Fri, 3 May 2024 13:48:59 +0300 Subject: [PATCH 10/11] [SSE] Fix copy move dialog --- .../main/app/controller/Statusbar.js | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index b9009d50c8..8f785b741a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -606,19 +606,21 @@ define([ if (btn == 'ok') { var arrBooks, arrNames; - if (workbook) { - if (workbook === 'new') - arrBooks = []; - else if (workbook !== 'current') - arrBooks = [workbook]; - if (workbook !== 'current') { - arrNames = me.generateSheetNames(copy, arrIndex); - } + if (workbook === 'new') + arrBooks = []; + else if (workbook !== 'current') + arrBooks = [workbook]; + if (workbook !== 'current') { + arrNames = []; + arrIndex.forEach(function (item) { + arrNames.push(me.api.asc_getWorksheetName(item)); + }); } if (!copy) { me.api.asc_moveWorksheet(i == -255 ? wc : i, arrIndex, arrNames, arrBooks); } else { - arrNames = me.generateSheetNames(copy, arrIndex); + if (!arrNames) + arrNames = me.generateSheetNames(copy, arrIndex); me.api.asc_copyWorksheet(i == -255 ? wc : i, arrNames, arrIndex, arrBooks); } } From 8a89835e71121487f270b4d8f4b3768e45e85191 Mon Sep 17 00:00:00 2001 From: "Julia.Svinareva" Date: Mon, 6 May 2024 14:46:01 +0300 Subject: [PATCH 11/11] [SSE] Fix copy move dialog --- apps/spreadsheeteditor/main/app/controller/Statusbar.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Statusbar.js b/apps/spreadsheeteditor/main/app/controller/Statusbar.js index 8f785b741a..33d07bb29e 100644 --- a/apps/spreadsheeteditor/main/app/controller/Statusbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Statusbar.js @@ -597,12 +597,14 @@ define([ return; } + var btn; me.copyDialog = new SSE.Views.Statusbar.CopyDialog({ title : me.statusbar.itemMoveOrCopy, sheets : items, spreadsheetName: me.api.asc_getDocumentName(), isDesktopApp: me.statusbar.mode.isDesktopApp, - handler : function(btn, i, copy, workbook) { + handler : function(result, i, copy, workbook) { + btn = result; if (btn == 'ok') { var arrBooks, arrNames; @@ -623,11 +625,14 @@ define([ arrNames = me.generateSheetNames(copy, arrIndex); me.api.asc_copyWorksheet(i == -255 ? wc : i, arrNames, arrIndex, arrBooks); } + } else { + me.api.asc_cancelMoveCopyWorksheet(); } me.api.asc_enableKeyEvents(true); } }); me.copyDialog.on('close', function () { + if (!btn) me.api.asc_cancelMoveCopyWorksheet(); me.copyDialog = undefined; }); me.copyDialog.show();