2019-05-30 10:15:49 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2019
*
* This program is a free software product . You can redistribute it and / or
* modify it under the terms of the GNU Affero General Public License ( AGPL )
* version 3 as published by the Free Software Foundation . In accordance with
* Section 7 ( a ) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non - infringement
* of any third - party rights .
*
* This program is distributed WITHOUT ANY WARRANTY ; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . For
* details , see the GNU AGPL at : http : //www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at 20 A - 12 Ernesta Birznieka - Upisha
* street , Riga , Latvia , EU , LV - 1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices , as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7 ( b ) of the License you must retain the original Product
* logo when distributing the program . Pursuant to Section 7 ( e ) we decline to
* grant you any rights under trademark law for use of our trademarks .
*
* All the Product ' s GUI elements , including illustrations and icon sets , as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution - ShareAlike 4.0 International . See the License
* terms at http : //creativecommons.org/licenses/by-sa/4.0/legalcode
*
* /
/ * *
* DataTab . js
*
* Created by Julia Radzhabova on 30.05 . 2019
* Copyright ( c ) 2019 Ascensio System SIA . All rights reserved .
*
* /
define ( [
'core' ,
'spreadsheeteditor/main/app/view/DataTab' ,
2020-04-07 12:48:45 +00:00
'spreadsheeteditor/main/app/view/SortDialog' ,
2020-10-15 11:09:23 +00:00
'spreadsheeteditor/main/app/view/RemoveDuplicatesDialog' ,
2020-11-11 20:55:11 +00:00
'spreadsheeteditor/main/app/view/DataValidationDialog' ,
2022-07-26 12:04:14 +00:00
'spreadsheeteditor/main/app/view/ExternalLinksDlg' ,
2022-12-08 15:29:30 +00:00
'spreadsheeteditor/main/app/view/ImportFromXmlDialog' ,
2020-10-15 11:09:23 +00:00
'common/main/lib/view/OptionsDialog'
2019-05-30 10:15:49 +00:00
] , function ( ) {
'use strict' ;
SSE . Controllers . DataTab = Backbone . Controller . extend ( _ . extend ( {
models : [ ] ,
collections : [
] ,
views : [
'DataTab'
] ,
sdkViewName : '#id_main' ,
initialize : function ( ) {
2019-05-30 12:52:25 +00:00
this . _state = {
2019-07-25 07:14:45 +00:00
CSVOptions : new Asc . asc _CTextOptions ( 0 , 4 , '' )
2019-05-30 12:52:25 +00:00
} ;
2022-11-14 16:50:51 +00:00
this . externalData = {
stackRequests : [ ] ,
stackResponse : [ ] ,
callback : undefined ,
isUpdating : false ,
linkStatus : { }
} ;
2019-05-30 10:15:49 +00:00
} ,
onLaunch : function ( ) {
} ,
setApi : function ( api ) {
if ( api ) {
this . api = api ;
this . api . asc _registerCallback ( 'asc_onSelectionChanged' , _ . bind ( this . onSelectionChanged , this ) ) ;
2019-08-06 13:12:07 +00:00
this . api . asc _registerCallback ( 'asc_onWorksheetLocked' , _ . bind ( this . onWorksheetLocked , this ) ) ;
2021-06-25 15:29:17 +00:00
this . api . asc _registerCallback ( 'asc_onChangeProtectWorkbook' , _ . bind ( this . onChangeProtectWorkbook , this ) ) ;
2019-05-30 10:15:49 +00:00
this . api . asc _registerCallback ( 'asc_onCoAuthoringDisconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
Common . NotificationCenter . on ( 'api:disconnect' , _ . bind ( this . onCoAuthoringDisconnect , this ) ) ;
2021-07-17 21:22:55 +00:00
Common . NotificationCenter . on ( 'protect:wslock' , _ . bind ( this . onChangeProtectSheet , this ) ) ;
Common . NotificationCenter . on ( 'document:ready' , _ . bind ( this . onDocumentReady , this ) ) ;
2019-05-30 10:15:49 +00:00
}
return this ;
} ,
setConfig : function ( config ) {
this . toolbar = config . toolbar ;
this . view = this . createView ( 'DataTab' , {
toolbar : this . toolbar . toolbar
} ) ;
2019-08-28 14:19:53 +00:00
this . addListeners ( {
'DataTab' : {
'data:group' : this . onGroup ,
'data:ungroup' : this . onUngroup ,
'data:tocolumns' : this . onTextToColumn ,
'data:show' : this . onShowClick ,
'data:hide' : this . onHideClick ,
2019-10-01 11:20:52 +00:00
'data:groupsettings' : this . onGroupSettings ,
2020-04-07 12:48:45 +00:00
'data:sortcustom' : this . onCustomSort ,
2020-11-11 20:55:11 +00:00
'data:remduplicates' : this . onRemoveDuplicates ,
2021-03-19 14:00:05 +00:00
'data:datavalidation' : this . onDataValidation ,
2022-07-26 12:04:14 +00:00
'data:fromtext' : this . onDataFromText ,
'data:externallinks' : this . onExternalLinks
2019-08-28 14:19:53 +00:00
} ,
'Statusbar' : {
'sheet:changed' : this . onApiSheetChanged
}
} ) ;
2020-04-13 09:45:11 +00:00
Common . NotificationCenter . on ( 'data:remduplicates' , _ . bind ( this . onRemoveDuplicates , this ) ) ;
2020-11-26 21:25:44 +00:00
Common . NotificationCenter . on ( 'data:sortcustom' , _ . bind ( this . onCustomSort , this ) ) ;
2022-11-14 16:50:51 +00:00
if ( this . toolbar . mode . canRequestReferenceData && this . api ) {
// this.api.asc_registerCallback('asc_onNeedUpdateExternalReferenceOnOpen', _.bind(this.onNeedUpdateExternalReferenceOnOpen, this));
this . api . asc _registerCallback ( 'asc_onStartUpdateExternalReference' , _ . bind ( this . onStartUpdateExternalReference , this ) ) ;
this . api . asc _registerCallback ( 'asc_onUpdateExternalReference' , _ . bind ( this . onUpdateExternalReference , this ) ) ;
this . api . asc _registerCallback ( 'asc_onErrorUpdateExternalReference' , _ . bind ( this . onErrorUpdateExternalReference , this ) ) ;
Common . Gateway . on ( 'setreferencedata' , _ . bind ( this . setReferenceData , this ) ) ;
}
2019-05-30 10:15:49 +00:00
} ,
SetDisabled : function ( state ) {
this . view && this . view . SetDisabled ( state ) ;
} ,
getView : function ( name ) {
return ! name && this . view ?
this . view : Backbone . Controller . prototype . getView . call ( this , name ) ;
} ,
onCoAuthoringDisconnect : function ( ) {
this . SetDisabled ( true ) ;
} ,
onSelectionChanged : function ( info ) {
2019-05-30 12:52:25 +00:00
if ( ! this . toolbar . editMode || ! this . view ) return ;
2019-05-30 10:15:49 +00:00
// special disable conditions
2021-12-29 16:41:15 +00:00
Common . Utils . lockControls ( Common . enumLock . multiselectCols , info . asc _getSelectedColsCount ( ) > 1 , { array : [ this . view . btnTextToColumns ] } ) ;
Common . Utils . lockControls ( Common . enumLock . multiselect , info . asc _getMultiselect ( ) , { array : [ this . view . btnTextToColumns ] } ) ;
2019-05-30 10:15:49 +00:00
} ,
onUngroup : function ( type ) {
2019-06-05 12:26:29 +00:00
var me = this ;
2019-05-30 10:15:49 +00:00
if ( type == 'rows' ) {
2019-06-05 12:26:29 +00:00
( me . api . asc _checkAddGroup ( true ) !== undefined ) && me . api . asc _ungroup ( true )
2019-05-30 10:15:49 +00:00
} else if ( type == 'columns' ) {
2019-06-05 12:26:29 +00:00
( me . api . asc _checkAddGroup ( true ) !== undefined ) && me . api . asc _ungroup ( false )
2019-05-30 10:15:49 +00:00
} else if ( type == 'clear' ) {
me . api . asc _clearOutline ( ) ;
2019-06-05 11:19:33 +00:00
} else {
2019-06-05 12:26:29 +00:00
var val = me . api . asc _checkAddGroup ( true ) ;
2019-06-05 11:19:33 +00:00
if ( val === null ) {
2020-10-15 11:09:23 +00:00
( new Common . Views . OptionsDialog ( {
2019-06-05 11:19:33 +00:00
title : me . view . capBtnUngroup ,
2020-10-15 11:09:23 +00:00
items : [
{ caption : this . textRows , value : true , checked : true } ,
{ caption : this . textColumns , value : false , checked : false }
] ,
2019-06-05 11:19:33 +00:00
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . asc _ungroup ( dlg . getSettings ( ) ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
2019-05-30 10:15:49 +00:00
}
2019-06-05 11:19:33 +00:00
} ) ) . show ( ) ;
} else if ( val !== undefined ) //undefined - error, true - rows, false - columns
me . api . asc _ungroup ( val ) ;
}
2019-05-30 10:15:49 +00:00
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
} ,
2019-08-08 07:48:27 +00:00
onGroup : function ( type , checked ) {
if ( type == 'rows' ) {
( this . api . asc _checkAddGroup ( ) !== undefined ) && this . api . asc _group ( true )
} else if ( type == 'columns' ) {
( this . api . asc _checkAddGroup ( ) !== undefined ) && this . api . asc _group ( false )
} else if ( type == 'below' ) {
this . api . asc _setGroupSummary ( checked , false ) ;
} else if ( type == 'right' ) {
this . api . asc _setGroupSummary ( checked , true ) ;
} else {
var me = this ,
val = me . api . asc _checkAddGroup ( ) ;
if ( val === null ) {
2020-10-15 11:09:23 +00:00
( new Common . Views . OptionsDialog ( {
2019-08-08 07:48:27 +00:00
title : me . view . capBtnGroup ,
2020-10-15 11:09:23 +00:00
items : [
{ caption : this . textRows , value : true , checked : true } ,
{ caption : this . textColumns , value : false , checked : false }
] ,
2019-08-08 07:48:27 +00:00
handler : function ( dlg , result ) {
if ( result == 'ok' ) {
me . api . asc _group ( dlg . getSettings ( ) ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
2019-05-30 10:15:49 +00:00
}
2019-08-08 07:48:27 +00:00
} ) ) . show ( ) ;
} else if ( val !== undefined ) //undefined - error, true - rows, false - columns
me . api . asc _group ( val ) ;
}
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} ,
onGroupSettings : function ( menu ) {
var value = this . api . asc _getGroupSummaryBelow ( ) ;
menu . items [ 3 ] . setChecked ( ! ! value , true ) ;
value = this . api . asc _getGroupSummaryRight ( ) ;
menu . items [ 4 ] . setChecked ( ! ! value , true ) ;
2019-05-30 12:52:25 +00:00
} ,
onTextToColumn : function ( ) {
this . api . asc _TextImport ( this . _state . CSVOptions , _ . bind ( this . onTextToColumnCallback , this ) , false ) ;
} ,
onTextToColumnCallback : function ( data ) {
if ( ! data || ! data . length ) return ;
var me = this ;
( new Common . Views . OpenDialog ( {
title : me . textWizard ,
closable : true ,
type : Common . Utils . importTextType . Columns ,
preview : true ,
previewData : data ,
settings : me . _state . CSVOptions ,
api : me . api ,
2021-03-23 13:55:20 +00:00
handler : function ( result , settings ) {
if ( result == 'ok' && me . api ) {
me . api . asc _TextToColumns ( settings . textOptions ) ;
2019-05-30 12:52:25 +00:00
}
}
} ) ) . show ( ) ;
} ,
2021-03-19 14:00:05 +00:00
onDataFromText : function ( type ) {
var me = this ;
if ( type === 'file' ) {
if ( this . api )
this . api . asc _TextFromFileOrUrl ( this . _state . CSVOptions , _ . bind ( this . onDataFromTextCallback , this ) ) ;
Common . NotificationCenter . trigger ( 'edit:complete' , this . toolbar ) ;
} else if ( type === 'url' ) {
( new Common . Views . ImageFromUrlDialog ( {
2021-07-20 15:43:04 +00:00
title : me . txtUrlTitle ,
2021-03-19 14:00:05 +00:00
handler : function ( result , value ) {
if ( result == 'ok' ) {
if ( me . api ) {
var checkUrl = value . replace ( /\s/g , '' ) ;
if ( ! _ . isEmpty ( checkUrl ) ) {
me . api . asc _TextFromFileOrUrl ( me . _state . CSVOptions , _ . bind ( me . onDataFromTextCallback , me ) , checkUrl ) ;
} else {
Common . UI . warning ( {
msg : me . textEmptyUrl
} ) ;
}
}
Common . NotificationCenter . trigger ( 'edit:complete' , me . toolbar ) ;
}
}
} ) ) . show ( ) ;
} else if ( type === 'storage' ) {
// Common.NotificationCenter.trigger('storage:data-load', 'add');
2022-12-08 15:29:30 +00:00
} else if ( type === 'xml' ) {
this . api && this . api . asc _ImportXmlStart ( _ . bind ( this . onDataFromXMLCallback , this ) ) ;
2021-03-19 14:00:05 +00:00
}
} ,
2021-03-23 08:43:12 +00:00
onDataFromTextCallback : function ( advOptions ) {
2021-03-19 14:00:05 +00:00
var me = this ;
( new Common . Views . OpenDialog ( {
2021-03-22 14:18:32 +00:00
title : me . txtImportWizard ,
2021-03-19 14:00:05 +00:00
closable : true ,
type : Common . Utils . importTextType . Data ,
2021-03-23 08:43:12 +00:00
preview : advOptions . asc _getData ( ) ,
2021-03-22 13:45:42 +00:00
settings : advOptions ? advOptions . asc _getRecommendedSettings ( ) : me . _state . CSVOptions ,
codepages : advOptions ? advOptions . asc _getCodePages ( ) : null ,
2021-03-19 14:00:05 +00:00
api : me . api ,
2021-03-23 13:55:20 +00:00
handler : function ( result , settings ) {
if ( result == 'ok' && me . api ) {
me . api . asc _TextToColumns ( settings . textOptions , settings . data , settings . range ) ;
2021-03-19 14:00:05 +00:00
}
}
} ) ) . show ( ) ;
} ,
2022-12-08 15:29:30 +00:00
onDataFromXMLCallback : function ( fileContent ) {
if ( ! fileContent ) return ;
var me = this ;
( new SSE . Views . ImportFromXmlDialog ( {
api : me . api ,
handler : function ( result , settings ) {
if ( result == 'ok' && settings ) {
if ( settings . destination )
2022-12-09 09:36:38 +00:00
me . api . asc _ImportXmlEnd ( fileContent , settings . destination , me . api . asc _getWorksheetName ( me . api . asc _getActiveWorksheetIndex ( ) ) ) ;
2022-12-08 15:29:30 +00:00
else
2022-12-09 09:36:38 +00:00
me . api . asc _ImportXmlEnd ( fileContent , null , me . createSheetName ( ) ) ;
2022-12-08 15:29:30 +00:00
}
Common . NotificationCenter . trigger ( 'edit:complete' , me ) ;
}
} ) ) . show ( ) ;
} ,
createSheetName : function ( ) {
var items = [ ] , wc = this . api . asc _getWorksheetsCount ( ) ;
while ( wc -- ) {
items . push ( this . api . asc _getWorksheetName ( wc ) . toLowerCase ( ) ) ;
}
var index = 0 , name ;
while ( ++ index < 1000 ) {
name = this . strSheet + index ;
if ( items . indexOf ( name . toLowerCase ( ) ) < 0 ) break ;
}
return name ;
} ,
2019-05-30 14:51:11 +00:00
onShowClick : function ( ) {
2019-05-31 07:59:38 +00:00
this . api . asc _changeGroupDetails ( true ) ;
2019-05-30 14:51:11 +00:00
} ,
onHideClick : function ( ) {
2019-05-31 07:59:38 +00:00
this . api . asc _changeGroupDetails ( false ) ;
2019-05-30 14:51:11 +00:00
} ,
2019-10-01 11:20:52 +00:00
onCustomSort : function ( ) {
2021-08-10 21:24:12 +00:00
Common . NotificationCenter . trigger ( 'protect:check' , this . onCustomSortCallback , this ) ;
} ,
onCustomSortCallback : function ( ) {
2019-10-01 11:20:52 +00:00
var me = this ;
2019-10-05 11:20:38 +00:00
if ( this . api ) {
var res = this . api . asc _sortCellsRangeExpand ( ) ;
2021-08-10 21:24:12 +00:00
switch ( res ) {
case Asc . c _oAscSelectionSortExpand . showExpandMessage :
var config = {
width : 500 ,
title : this . toolbar . txtSorting ,
msg : this . toolbar . txtExpandSort ,
buttons : [ { caption : this . toolbar . txtExpand , primary : true , value : 'expand' } ,
{ caption : this . toolbar . txtSortSelected , primary : true , value : 'sort' } ,
'cancel' ] ,
callback : function ( btn ) {
if ( btn == 'expand' || btn == 'sort' ) {
setTimeout ( function ( ) {
me . showCustomSort ( btn == 'expand' ) ;
} , 1 ) ;
}
2019-10-05 11:20:38 +00:00
}
2021-08-10 21:24:12 +00:00
} ;
Common . UI . alert ( config ) ;
break ;
case Asc . c _oAscSelectionSortExpand . showLockMessage :
var config = {
width : 500 ,
title : this . toolbar . txtSorting ,
msg : this . toolbar . txtLockSort ,
buttons : [ 'yes' , 'no' ] ,
primary : 'yes' ,
callback : function ( btn ) {
( btn == 'yes' ) && setTimeout ( function ( ) {
me . showCustomSort ( false ) ;
} , 1 ) ;
}
} ;
Common . UI . alert ( config ) ;
break ;
case Asc . c _oAscSelectionSortExpand . expandAndNotShowMessage :
case Asc . c _oAscSelectionSortExpand . notExpandAndNotShowMessage :
me . showCustomSort ( res === Asc . c _oAscSelectionSortExpand . expandAndNotShowMessage ) ;
break ;
}
2019-10-05 11:20:38 +00:00
}
} ,
showCustomSort : function ( expand ) {
var me = this ,
props = me . api . asc _getSortProps ( expand ) ;
// props = new Asc.CSortProperties();
if ( props ) {
( new SSE . Views . SortDialog ( {
props : props ,
api : me . api ,
2019-10-10 11:46:39 +00:00
handler : function ( result , settings ) {
2019-12-26 13:27:59 +00:00
if ( me && me . api ) {
me . api . asc _setSortProps ( settings , result != 'ok' ) ;
2019-10-05 11:20:38 +00:00
}
}
} ) ) . show ( ) ;
}
2019-10-01 11:20:52 +00:00
} ,
2020-04-07 12:48:45 +00:00
onRemoveDuplicates : function ( ) {
var me = this ;
if ( this . api ) {
var res = this . api . asc _sortCellsRangeExpand ( ) ;
2021-08-10 21:24:12 +00:00
if ( res === Asc . c _oAscSelectionSortExpand . showExpandMessage ) {
2020-04-07 12:48:45 +00:00
var config = {
width : 500 ,
title : this . txtRemDuplicates ,
msg : this . txtExpandRemDuplicates ,
buttons : [ { caption : this . txtExpand , primary : true , value : 'expand' } ,
{ caption : this . txtRemSelected , primary : true , value : 'remove' } ,
'cancel' ] ,
callback : function ( btn ) {
if ( btn == 'expand' || btn == 'remove' ) {
setTimeout ( function ( ) {
me . showRemDuplicates ( btn == 'expand' ) ;
} , 1 ) ;
}
}
} ;
Common . UI . alert ( config ) ;
2021-08-10 21:24:12 +00:00
} else if ( res !== Asc . c _oAscSelectionSortExpand . showLockMessage )
me . showRemDuplicates ( res === Asc . c _oAscSelectionSortExpand . expandAndNotShowMessage ) ;
2020-04-07 12:48:45 +00:00
}
} ,
showRemDuplicates : function ( expand ) {
var me = this ,
props = me . api . asc _getRemoveDuplicates ( expand ) ;
if ( props ) {
( new SSE . Views . RemoveDuplicatesDialog ( {
props : props ,
api : me . api ,
handler : function ( result , settings ) {
if ( me && me . api ) {
me . api . asc _setRemoveDuplicates ( settings , result != 'ok' ) ;
}
}
} ) ) . show ( ) ;
}
} ,
2020-11-11 20:55:11 +00:00
onDataValidation : function ( ) {
var me = this ;
if ( this . api ) {
var res = this . api . asc _getDataValidationProps ( ) ;
if ( typeof res !== 'object' ) {
var config = {
maxwidth : 500 ,
title : this . txtDataValidation ,
2020-12-04 09:34:27 +00:00
msg : res === Asc . c _oAscError . ID . MoreOneTypeDataValidate ? this . txtRemoveDataValidation : this . txtExtendDataValidation ,
buttons : res === Asc . c _oAscError . ID . MoreOneTypeDataValidate ? [ 'ok' , 'cancel' ] : [ 'yes' , 'no' , 'cancel' ] ,
primary : res === Asc . c _oAscError . ID . MoreOneTypeDataValidate ? 'ok' : [ 'yes' , 'no' ] ,
2020-11-11 20:55:11 +00:00
callback : function ( btn ) {
if ( btn == 'yes' || btn == 'no' || btn == 'ok' ) {
setTimeout ( function ( ) {
2020-11-12 08:30:05 +00:00
var props = me . api . asc _getDataValidationProps ( ( btn == 'ok' ) ? null : ( btn == 'yes' ) ) ;
2020-11-11 20:55:11 +00:00
me . showDataValidation ( props ) ;
} , 1 ) ;
}
}
} ;
Common . UI . alert ( config ) ;
} else
me . showDataValidation ( res ) ;
}
} ,
showDataValidation : function ( props ) {
var me = this ;
if ( props ) {
( new SSE . Views . DataValidationDialog ( {
title : this . txtDataValidation ,
props : props ,
api : me . api ,
handler : function ( result , settings ) {
if ( me && me . api && result == 'ok' ) {
me . api . asc _setDataValidation ( settings ) ;
}
}
} ) ) . show ( ) ;
}
} ,
2022-07-26 12:04:14 +00:00
onExternalLinks : function ( ) {
2022-11-14 16:50:51 +00:00
var me = this ;
this . externalLinksDlg = ( new SSE . Views . ExternalLinksDlg ( {
2022-07-26 12:04:14 +00:00
api : this . api ,
2022-11-14 16:50:51 +00:00
isUpdating : this . externalData . isUpdating ,
2022-07-26 12:04:14 +00:00
handler : function ( result ) {
Common . NotificationCenter . trigger ( 'edit:complete' ) ;
}
2022-11-14 16:50:51 +00:00
} ) ) ;
this . externalLinksDlg . on ( 'close' , function ( win ) {
me . externalLinksDlg = null ;
} )
this . externalLinksDlg . show ( )
} ,
onUpdateExternalReference : function ( arr , callback ) {
if ( this . toolbar . mode . isEdit && this . toolbar . editMode ) {
var me = this ;
me . externalData = {
stackRequests : [ ] ,
stackResponse : [ ] ,
callback : undefined ,
isUpdating : false ,
linkStatus : { }
} ;
arr && arr . length > 0 && arr . forEach ( function ( item ) {
var data ;
switch ( item . asc _getType ( ) ) {
case Asc . c _oAscExternalReferenceType . link :
data = { link : item . asc _getData ( ) } ;
break ;
case Asc . c _oAscExternalReferenceType . path :
data = { path : item . asc _getData ( ) } ;
break ;
case Asc . c _oAscExternalReferenceType . referenceData :
data = { referenceData : item . asc _getData ( ) } ;
break ;
}
2022-11-18 13:54:51 +00:00
data && me . externalData . stackRequests . push ( { data : data , id : item . asc _getId ( ) , isExternal : item . asc _isExternalLink ( ) } ) ;
2022-11-14 16:50:51 +00:00
} ) ;
me . externalData . callback = callback ;
me . requestReferenceData ( ) ;
}
} ,
requestReferenceData : function ( ) {
if ( this . externalData . stackRequests . length > 0 ) {
var item = this . externalData . stackRequests . shift ( ) ;
this . externalData . linkStatus . id = item . id ;
2022-11-18 13:54:51 +00:00
this . externalData . linkStatus . isExternal = item . isExternal ;
2022-11-14 16:50:51 +00:00
Common . Gateway . requestReferenceData ( item . data ) ;
}
} ,
setReferenceData : function ( data ) {
if ( this . toolbar . mode . isEdit && this . toolbar . editMode ) {
if ( data ) {
this . externalData . stackResponse . push ( data ) ;
2022-11-18 13:54:51 +00:00
this . externalData . linkStatus . result = this . externalData . linkStatus . isExternal ? '' : data . error || '' ;
2022-11-14 16:50:51 +00:00
if ( this . externalLinksDlg ) {
this . externalLinksDlg . setLinkStatus ( this . externalData . linkStatus . id , this . externalData . linkStatus . result ) ;
}
}
if ( this . externalData . stackRequests . length > 0 )
this . requestReferenceData ( ) ;
else if ( this . externalData . callback )
this . externalData . callback ( this . externalData . stackResponse ) ;
}
} ,
onStartUpdateExternalReference : function ( status ) {
this . externalData . isUpdating = status ;
if ( this . externalLinksDlg ) {
this . externalLinksDlg . setIsUpdating ( status ) ;
}
} ,
onNeedUpdateExternalReferenceOnOpen : function ( ) {
var links = this . api . asc _getExternalReferences ( ) ;
links && ( links . length > 0 ) && this . api . asc _updateExternalReferences ( links ) ;
} ,
onErrorUpdateExternalReference : function ( id ) {
if ( this . externalLinksDlg ) {
this . externalLinksDlg . setLinkStatus ( id , this . txtErrorExternalLink ) ;
}
2022-07-26 12:04:14 +00:00
} ,
2019-08-06 13:12:07 +00:00
onWorksheetLocked : function ( index , locked ) {
if ( index == this . api . asc _getActiveWorksheetIndex ( ) ) {
2021-12-29 16:41:15 +00:00
Common . Utils . lockControls ( Common . enumLock . sheetLock , locked , { array : this . view . btnsSortDown . concat ( this . view . btnsSortUp , this . view . btnCustomSort , this . view . btnGroup , this . view . btnUngroup ) } ) ;
2019-08-06 13:12:07 +00:00
}
} ,
2021-06-25 15:29:17 +00:00
onChangeProtectWorkbook : function ( ) {
2022-07-26 12:04:14 +00:00
Common . Utils . lockControls ( Common . enumLock . wbLock , this . api . asc _isProtectedWorkbook ( ) , { array : [ this . view . btnDataFromText , this . view . btnExternalLinks ] } ) ;
2021-06-25 15:29:17 +00:00
} ,
2019-08-28 14:19:53 +00:00
onApiSheetChanged : function ( ) {
2022-03-11 10:58:15 +00:00
if ( ! this . toolbar . mode || ! this . toolbar . mode . isEdit || this . toolbar . mode . isEditDiagram || this . toolbar . mode . isEditMailMerge || this . toolbar . mode . isEditOle ) return ;
2019-08-28 14:19:53 +00:00
var currentSheet = this . api . asc _getActiveWorksheetIndex ( ) ;
this . onWorksheetLocked ( currentSheet , this . api . asc _isWorksheetLockedOrDeleted ( currentSheet ) ) ;
} ,
2021-07-17 21:22:55 +00:00
onChangeProtectSheet : function ( props ) {
if ( ! props ) {
var wbprotect = this . getApplication ( ) . getController ( 'WBProtection' ) ;
props = wbprotect ? wbprotect . getWSProps ( ) : null ;
}
2021-12-29 16:41:15 +00:00
props && props . wsProps && Common . Utils . lockControls ( Common . enumLock [ 'Sort' ] , props . wsProps [ 'Sort' ] , { array : this . view . btnsSortDown . concat ( this . view . btnsSortUp , this . view . btnCustomSort ) } ) ;
2021-07-17 21:22:55 +00:00
} ,
onDocumentReady : function ( ) {
this . onChangeProtectSheet ( ) ;
} ,
2020-04-07 12:48:45 +00:00
textWizard : 'Text to Columns Wizard' ,
txtRemDuplicates : 'Remove Duplicates' ,
txtExpandRemDuplicates : 'The data next to the selection will not be removed. Do you want to expand the selection to include the adjacent data or continue with the currently selected cells only?' ,
txtExpand : 'Expand' ,
2020-10-15 11:09:23 +00:00
txtRemSelected : 'Remove in selected' ,
textRows : 'Rows' ,
2020-11-11 20:55:11 +00:00
textColumns : 'Columns' ,
txtDataValidation : 'Data Validation' ,
txtExtendDataValidation : 'The selection contains some cells without Data Validation settings.<br>Do you want to extend Data Validation to these cells?' ,
2021-03-19 14:00:05 +00:00
txtRemoveDataValidation : 'The selection contains more than one type of validation.<br>Erase current settings and continue?' ,
2021-03-22 14:18:32 +00:00
textEmptyUrl : 'You need to specify URL.' ,
2021-07-20 15:43:04 +00:00
txtImportWizard : 'Text Import Wizard' ,
2022-11-14 16:50:51 +00:00
txtUrlTitle : 'Paste a data URL' ,
2022-12-08 15:29:30 +00:00
txtErrorExternalLink : 'Error: updating is failed' ,
2022-12-09 07:27:15 +00:00
strSheet : 'Sheet'
2019-05-30 10:15:49 +00:00
} , SSE . Controllers . DataTab || { } ) ) ;
} ) ;