2020-04-14 11:58:40 +00:00
/ *
*
* ( c ) Copyright Ascensio System SIA 2010 - 2020
*
* 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
*
* /
/ * *
2020-05-26 14:14:58 +00:00
* SlicerSettingsAdvanced . js
2020-04-14 11:58:40 +00:00
*
* Created by Julia Radzhabova on 14.04 . 2020
* Copyright ( c ) 2018 Ascensio System SIA . All rights reserved .
*
* /
2020-05-26 14:14:58 +00:00
define ( [ 'text!spreadsheeteditor/main/app/template/SlicerSettingsAdvanced.template' ,
2020-04-14 11:58:40 +00:00
'common/main/lib/view/AdvancedSettingsWindow' ,
'common/main/lib/component/MetricSpinner' ,
'common/main/lib/component/CheckBox' ,
'common/main/lib/component/RadioBox' ,
'common/main/lib/component/ComboDataView'
] , function ( contentTemplate ) {
'use strict' ;
2020-05-26 14:14:58 +00:00
SSE . Views . SlicerSettingsAdvanced = Common . Views . AdvancedSettingsWindow . extend ( _ . extend ( {
2020-04-14 11:58:40 +00:00
options : {
contentWidth : 330 ,
height : 435 ,
toggleGroup : 'slicer-adv-settings-group' ,
storageName : 'sse-slicer-settings-adv-category'
} ,
initialize : function ( options ) {
var me = this ;
_ . extend ( this . options , {
title : this . textTitle ,
items : [
{ panelId : 'id-adv-slicer-style' , panelCaption : this . strStyleSize } ,
{ panelId : 'id-adv-slicer-sorting' , panelCaption : this . strSorting } ,
2020-05-26 14:14:58 +00:00
{ panelId : 'id-adv-slicer-references' , panelCaption : this . strReferences } ,
2020-05-27 17:20:08 +00:00
{ panelId : 'id-adv-slicer-snap' , panelCaption : this . textSnap } ,
{ panelId : 'id-adv-slicer-alttext' , panelCaption : this . textAlt }
2020-04-14 11:58:40 +00:00
] ,
contentTemplate : _ . template ( contentTemplate ) ( {
scope : this
} )
} , options ) ;
2020-08-18 13:23:52 +00:00
this . options . handler = function ( result , value ) {
if ( result != 'ok' || this . isNameValid ( ) ) {
if ( options . handler )
options . handler . call ( this , result , value ) ;
return ;
}
return true ;
} ;
2020-04-14 11:58:40 +00:00
Common . Views . AdvancedSettingsWindow . prototype . initialize . call ( this , this . options ) ;
this . _changedProps = null ;
this . _noApply = true ;
this . spinners = [ ] ;
2020-05-28 14:59:49 +00:00
this . _nRatio = 1 ;
2020-04-14 11:58:40 +00:00
2020-05-27 13:33:34 +00:00
this . _originalProps = this . options . imageProps ;
2020-04-14 11:58:40 +00:00
} ,
render : function ( ) {
Common . Views . AdvancedSettingsWindow . prototype . render . call ( this ) ;
var me = this ;
// Style & Size
this . inputHeader = new Common . UI . InputField ( {
el : $ ( '#sliceradv-text-header' ) ,
2020-08-18 13:23:52 +00:00
allowBlank : true ,
2020-04-14 11:58:40 +00:00
style : 'width: 178px;'
2020-05-26 14:14:58 +00:00
} ) . on ( 'changed:after' , function ( ) {
me . isCaptionChanged = true ;
2020-04-14 11:58:40 +00:00
} ) ;
this . chHeader = new Common . UI . CheckBox ( {
el : $ ( '#sliceradv-checkbox-header' ) ,
labelText : this . strShowHeader
} ) ;
this . chHeader . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
if ( this . _changedProps ) {
2020-05-26 14:14:58 +00:00
this . _changedProps . asc _setShowCaption ( field . getValue ( ) == 'checked' ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
2020-05-26 20:26:36 +00:00
this . btnSlicerStyle = new Common . UI . Button ( {
parentEl : $ ( '#sliceradv-btn-style' ) ,
2020-05-27 15:34:15 +00:00
cls : 'btn-large-dataview sheet-template-slicer' ,
iconCls : 'icon-template-slicer' ,
2020-05-26 20:26:36 +00:00
menu : new Common . UI . Menu ( {
2020-05-27 15:34:15 +00:00
style : 'width: 333px;' ,
2020-05-27 20:28:27 +00:00
additionalAlign : this . menuAddAlign ,
2020-05-26 20:26:36 +00:00
items : [
2020-05-27 15:34:15 +00:00
{ template : _ . template ( '<div id="sliceradv-menu-style" class="menu-slicer-template" style="margin: 5px 5px 5px 10px;"></div>' ) }
2020-05-26 20:26:36 +00:00
]
} )
2020-04-14 11:58:40 +00:00
} ) ;
2020-05-26 20:26:36 +00:00
this . mnuSlicerPicker = new Common . UI . DataView ( {
el : $ ( '#sliceradv-menu-style' ) ,
parentMenu : this . btnSlicerStyle . menu ,
restoreHeight : 325 ,
groups : new Common . UI . DataViewGroupStore ( ) ,
store : new Common . UI . DataViewStore ( ) ,
2020-05-27 15:34:15 +00:00
itemTemplate : _ . template ( '<div id="<%= id %>" class="item"><img src="<%= imageUrl %>" height="49" width="36"></div>' ) ,
2020-05-26 20:26:36 +00:00
style : 'max-height: 325px;'
2020-04-14 11:58:40 +00:00
} ) ;
2020-05-26 20:26:36 +00:00
this . mnuSlicerPicker . on ( 'item:click' , _ . bind ( this . onSelectSlicerStyle , this , this . btnSlicerStyle ) ) ;
2020-04-14 11:58:40 +00:00
this . numWidth = new Common . UI . MetricSpinner ( {
el : $ ( '#sliceradv-spin-width' ) ,
step : . 1 ,
width : 85 ,
defaultUnit : "cm" ,
defaultValue : 0 ,
value : '0 cm' ,
maxValue : 5963.9 ,
minValue : 0
} ) ;
this . numWidth . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
2020-05-28 14:59:49 +00:00
if ( this . btnRatio . pressed ) {
var w = field . getNumberValue ( ) ;
var h = w / this . _nRatio ;
if ( h > this . numHeight . options . maxValue ) {
h = this . numHeight . options . maxValue ;
w = h * this . _nRatio ;
this . numWidth . setValue ( w , true ) ;
}
this . numHeight . setValue ( h , true ) ;
}
2020-05-26 14:14:58 +00:00
if ( this . _originalProps ) {
2020-05-28 14:59:49 +00:00
this . _originalProps . put _Width ( Common . Utils . Metric . fnRecalcToMM ( field . getNumberValue ( ) ) ) ;
this . _originalProps . put _Height ( Common . Utils . Metric . fnRecalcToMM ( this . numHeight . getNumberValue ( ) ) ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . spinners . push ( this . numWidth ) ;
this . numHeight = new Common . UI . MetricSpinner ( {
el : $ ( '#sliceradv-spin-height' ) ,
step : . 1 ,
width : 85 ,
defaultUnit : "cm" ,
defaultValue : 0 ,
value : '0 cm' ,
maxValue : 5963.9 ,
minValue : 0
} ) ;
this . numHeight . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
2020-05-28 14:59:49 +00:00
var h = field . getNumberValue ( ) , w = null ;
if ( this . btnRatio . pressed ) {
w = h * this . _nRatio ;
if ( w > this . numWidth . options . maxValue ) {
w = this . numWidth . options . maxValue ;
h = w / this . _nRatio ;
this . numHeight . setValue ( h , true ) ;
}
this . numWidth . setValue ( w , true ) ;
}
2020-05-26 14:14:58 +00:00
if ( this . _originalProps ) {
2020-05-28 14:59:49 +00:00
this . _originalProps . put _Width ( Common . Utils . Metric . fnRecalcToMM ( this . numWidth . getNumberValue ( ) ) ) ;
this . _originalProps . put _Height ( Common . Utils . Metric . fnRecalcToMM ( field . getNumberValue ( ) ) ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . spinners . push ( this . numHeight ) ;
2020-05-28 14:59:49 +00:00
this . btnRatio = new Common . UI . Button ( {
parentEl : $ ( '#sliceradv-button-ratio' ) ,
cls : 'btn-toolbar' ,
iconCls : 'toolbar__icon advanced-btn-ratio' ,
style : 'margin-bottom: 1px;' ,
enableToggle : true ,
hint : this . textKeepRatio
} ) ;
this . btnRatio . on ( 'click' , _ . bind ( function ( btn , e ) {
if ( btn . pressed && this . numHeight . getNumberValue ( ) > 0 ) {
this . _nRatio = this . numWidth . getNumberValue ( ) / this . numHeight . getNumberValue ( ) ;
}
if ( this . _originalProps ) {
this . _originalProps . asc _putLockAspect ( btn . pressed ) ;
}
} , this ) ) ;
2020-04-14 11:58:40 +00:00
this . numColHeight = new Common . UI . MetricSpinner ( {
el : $ ( '#sliceradv-spin-col-height' ) ,
step : . 1 ,
width : 85 ,
defaultUnit : "cm" ,
defaultValue : 0 ,
value : '0 cm' ,
maxValue : 5963.9 ,
minValue : 0
} ) ;
this . numColHeight . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
var numval = field . getNumberValue ( ) ;
if ( this . _changedProps ) {
2020-05-26 14:14:58 +00:00
this . _changedProps . asc _setRowHeight ( Common . Utils . Metric . fnRecalcToMM ( numval ) * 36000 ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . spinners . push ( this . numColHeight ) ;
this . numCols = new Common . UI . MetricSpinner ( {
el : $ ( '#sliceradv-spin-columns' ) ,
step : 1 ,
width : 85 ,
defaultUnit : "" ,
defaultValue : 1 ,
value : '1' ,
allowDecimal : false ,
maxValue : 20000 ,
2020-05-28 10:58:38 +00:00
minValue : 1
2020-04-14 11:58:40 +00:00
} ) ;
this . numCols . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
var numval = field . getNumberValue ( ) ;
if ( this . _changedProps ) {
2020-05-26 14:14:58 +00:00
this . _changedProps . asc _setColumnCount ( numval ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
// Sorting & Filtering
this . radioAsc = new Common . UI . RadioBox ( {
el : $ ( '#sliceradv-radio-asc' ) ,
name : 'asc-radio-sliceradv-sort' ,
labelText : this . textAsc ,
checked : true
} ) ;
this . radioAsc . on ( 'change' , _ . bind ( function ( field , newValue , eOpts ) {
if ( newValue ) {
2020-05-26 14:14:58 +00:00
if ( this . _changedProps ) {
this . _changedProps . asc _setSortOrder ( Asc . ST _tabularSlicerCacheSortOrder . Ascending ) ;
}
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . radioDesc = new Common . UI . RadioBox ( {
el : $ ( '#sliceradv-radio-desc' ) ,
name : 'asc-radio-sliceradv-sort' ,
labelText : this . textDesc ,
checked : false
} ) ;
this . radioDesc . on ( 'change' , _ . bind ( function ( field , newValue , eOpts ) {
if ( newValue ) {
2020-05-26 14:14:58 +00:00
if ( this . _changedProps ) {
this . _changedProps . asc _setSortOrder ( Asc . ST _tabularSlicerCacheSortOrder . Descending ) ;
}
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . chHideNoData = new Common . UI . CheckBox ( {
el : $ ( '#sliceradv-check-hide-nodata' ) ,
labelText : this . strHideNoData
} ) ;
this . chHideNoData . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
var checked = ( field . getValue ( ) == 'checked' ) ;
this . chIndNoData . setDisabled ( checked ) ;
this . chShowNoData . setDisabled ( checked || ( this . chIndNoData . getValue ( ) != 'checked' ) ) ;
this . chShowDel . setDisabled ( checked ) ;
if ( this . _changedProps ) {
2020-05-26 14:14:58 +00:00
this . _changedProps . asc _setHideItemsWithNoData ( checked ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . chIndNoData = new Common . UI . CheckBox ( {
el : $ ( '#sliceradv-check-indicate-nodata' ) ,
labelText : this . strIndNoData
} ) ;
this . chIndNoData . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
var checked = ( field . getValue ( ) == 'checked' ) ;
this . chShowNoData . setDisabled ( ! checked ) ;
if ( this . _changedProps ) {
2020-05-26 14:14:58 +00:00
this . _changedProps . asc _setIndicateItemsWithNoData ( checked ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . chShowNoData = new Common . UI . CheckBox ( {
el : $ ( '#sliceradv-check-show-nodata-last' ) ,
disabled : true ,
labelText : this . strShowNoData
} ) ;
this . chShowNoData . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
if ( this . _changedProps ) {
2020-05-28 16:01:50 +00:00
this . _changedProps . asc _setShowItemsWithNoDataLast ( field . getValue ( ) == 'checked' ) ;
2020-04-14 11:58:40 +00:00
}
} , this ) ) ;
this . chShowDel = new Common . UI . CheckBox ( {
el : $ ( '#sliceradv-check-show-deleted' ) ,
labelText : this . strShowDel
} ) ;
this . chShowDel . on ( 'change' , _ . bind ( function ( field , newValue , oldValue , eOpts ) {
if ( this . _changedProps ) {
// this._changedProps.asc_putStrikeout(field.getValue()=='checked');
}
} , this ) ) ;
// References
this . inputName = new Common . UI . InputField ( {
el : $ ( '#sliceradv-text-name' ) ,
allowBlank : false ,
blankError : me . txtEmpty ,
style : 'width: 178px;'
2020-05-26 14:14:58 +00:00
} ) . on ( 'changed:after' , function ( ) {
me . isNameChanged = true ;
2020-04-14 11:58:40 +00:00
} ) ;
this . lblSource = $ ( '#sliceradv-lbl-source' ) ;
this . lblFormula = $ ( '#sliceradv-lbl-formula' ) ;
2020-05-27 17:20:08 +00:00
// Snapping
this . radioTwoCell = new Common . UI . RadioBox ( {
el : $ ( '#slicer-advanced-radio-twocell' ) ,
name : 'asc-radio-snap' ,
labelText : this . textTwoCell ,
value : AscCommon . c _oAscCellAnchorType . cellanchorTwoCell
} ) ;
this . radioTwoCell . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
this . radioOneCell = new Common . UI . RadioBox ( {
el : $ ( '#slicer-advanced-radio-onecell' ) ,
name : 'asc-radio-snap' ,
labelText : this . textOneCell ,
value : AscCommon . c _oAscCellAnchorType . cellanchorOneCell
} ) ;
this . radioOneCell . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
this . radioAbsolute = new Common . UI . RadioBox ( {
el : $ ( '#slicer-advanced-radio-absolute' ) ,
name : 'asc-radio-snap' ,
labelText : this . textAbsolute ,
value : AscCommon . c _oAscCellAnchorType . cellanchorAbsolute
} ) ;
this . radioAbsolute . on ( 'change' , _ . bind ( this . onRadioSnapChange , this ) ) ;
2020-05-26 14:14:58 +00:00
// Alt Text
this . inputAltTitle = new Common . UI . InputField ( {
el : $ ( '#sliceradv-alt-title' ) ,
allowBlank : true ,
validateOnBlur : false ,
style : 'width: 100%;'
} ) . on ( 'changed:after' , function ( ) {
me . isAltTitleChanged = true ;
} ) ;
this . textareaAltDescription = this . $window . find ( 'textarea' ) ;
this . textareaAltDescription . keydown ( function ( event ) {
if ( event . keyCode == Common . UI . Keys . RETURN ) {
event . stopPropagation ( ) ;
}
me . isAltDescChanged = true ;
} ) ;
2020-04-14 11:58:40 +00:00
this . afterRender ( ) ;
} ,
2020-10-14 10:43:44 +00:00
getFocusedComponents : function ( ) {
return [
2021-04-13 22:12:59 +00:00
this . inputHeader , this . chHeader , this . numWidth , this . numHeight , this . numCols , this . numColHeight , // 0 tab
2021-04-14 15:16:27 +00:00
this . radioAsc , this . radioDesc , this . chHideNoData , this . chIndNoData , this . chShowNoData , // 1 tab
2020-10-14 10:43:44 +00:00
this . inputName , // 2 tab
2021-04-14 15:16:27 +00:00
this . radioTwoCell , this . radioOneCell , this . radioAbsolute , // 3 tab
2020-10-14 10:43:44 +00:00
this . inputAltTitle , this . textareaAltDescription // 4 tab
] ;
} ,
onCategoryClick : function ( btn , index ) {
Common . Views . AdvancedSettingsWindow . prototype . onCategoryClick . call ( this , btn , index ) ;
var me = this ;
setTimeout ( function ( ) {
switch ( index ) {
case 0 :
me . inputHeader . focus ( ) ;
break ;
2021-04-13 22:12:59 +00:00
case 1 :
me . chHideNoData . focus ( ) ;
break ;
2020-10-14 10:43:44 +00:00
case 2 :
me . inputName . focus ( ) ;
break ;
2021-04-14 15:16:27 +00:00
case 3 :
me . radioTwoCell . focus ( ) ;
break ;
2020-10-14 10:43:44 +00:00
case 4 :
me . inputAltTitle . focus ( ) ;
break ;
}
} , 10 ) ;
} ,
2020-04-14 11:58:40 +00:00
getSettings : function ( ) {
2020-05-26 14:14:58 +00:00
if ( this . isCaptionChanged )
this . _changedProps . asc _setCaption ( this . inputHeader . getValue ( ) ) ;
if ( this . isNameChanged )
this . _changedProps . asc _setName ( this . inputName . getValue ( ) ) ;
if ( this . isAltTitleChanged )
this . _originalProps . asc _putTitle ( this . inputAltTitle . getValue ( ) ) ;
if ( this . isAltDescChanged )
this . _originalProps . asc _putDescription ( this . textareaAltDescription . val ( ) ) ;
2020-05-27 13:33:34 +00:00
return { imageProps : this . _originalProps } ;
2020-04-14 11:58:40 +00:00
} ,
_setDefaults : function ( props ) {
2020-05-25 17:25:16 +00:00
if ( props ) {
var value = props . asc _getWidth ( ) ;
this . numWidth . setValue ( ( value !== null ) ? Common . Utils . Metric . fnRecalcFromMM ( value ) . toFixed ( 2 ) : '' , true ) ;
value = props . asc _getHeight ( ) ;
this . numHeight . setValue ( ( value !== null ) ? Common . Utils . Metric . fnRecalcFromMM ( value ) . toFixed ( 2 ) : '' , true ) ;
2020-04-14 11:58:40 +00:00
2020-05-28 14:59:49 +00:00
if ( props . asc _getHeight ( ) > 0 )
this . _nRatio = props . asc _getWidth ( ) / props . asc _getHeight ( ) ;
value = props . asc _getLockAspect ( ) ;
this . btnRatio . toggle ( value ) ;
2020-05-26 14:14:58 +00:00
value = props . asc _getTitle ( ) ;
this . inputAltTitle . setValue ( value ? value : '' ) ;
value = props . asc _getDescription ( ) ;
this . textareaAltDescription . val ( value ? value : '' ) ;
2020-05-27 17:20:08 +00:00
value = props . asc _getAnchor ( ) ;
switch ( value ) {
case AscCommon . c _oAscCellAnchorType . cellanchorTwoCell :
this . radioTwoCell . setValue ( true , true ) ;
break ;
case AscCommon . c _oAscCellAnchorType . cellanchorOneCell :
this . radioOneCell . setValue ( true , true ) ;
break ;
case AscCommon . c _oAscCellAnchorType . cellanchorAbsolute :
this . radioAbsolute . setValue ( true , true ) ;
break ;
}
2020-05-25 17:25:16 +00:00
var slicerprops = props . asc _getSlicerProperties ( ) ;
if ( slicerprops ) {
this . _noApply = true ;
2020-04-14 11:58:40 +00:00
2020-05-25 17:25:16 +00:00
this . numCols . setValue ( slicerprops . asc _getColumnCount ( ) , true ) ;
2020-05-26 14:14:58 +00:00
this . numColHeight . setValue ( Common . Utils . Metric . fnRecalcFromMM ( slicerprops . asc _getRowHeight ( ) / 36000 ) . toFixed ( 2 ) , true ) ;
2020-04-14 11:58:40 +00:00
2020-05-26 14:14:58 +00:00
this . inputHeader . setValue ( slicerprops . asc _getCaption ( ) , true ) ;
var checked = slicerprops . asc _getShowCaption ( ) ;
this . chHeader . setValue ( checked !== null && checked !== undefined ? checked : 'indeterminate' , true ) ;
2020-04-14 11:58:40 +00:00
2020-05-25 17:25:16 +00:00
// depends of data type
2020-05-26 14:14:58 +00:00
this . radioAsc . setCaption ( this . textAsc + ' (' + this . textAZ + ')' ) ;
this . radioDesc . setCaption ( this . textDesc + ' (' + this . textZA + ')' ) ;
( slicerprops . asc _getSortOrder ( ) == Asc . ST _tabularSlicerCacheSortOrder . Ascending ) ? this . radioAsc . setValue ( true , true ) : this . radioDesc . setValue ( true , true ) ;
checked = slicerprops . asc _getIndicateItemsWithNoData ( ) ;
this . chIndNoData . setValue ( checked !== null && checked !== undefined ? checked : 'indeterminate' , true ) ;
checked = slicerprops . asc _getShowItemsWithNoDataLast ( ) ;
this . chShowNoData . setValue ( checked !== null && checked !== undefined ? checked : 'indeterminate' , true ) ;
checked = slicerprops . asc _getHideItemsWithNoData ( ) ;
this . chHideNoData . setValue ( checked !== null && checked !== undefined ? checked : 'indeterminate' , true ) ;
this . chIndNoData . setDisabled ( checked ) ;
this . chShowNoData . setDisabled ( checked || ( this . chIndNoData . getValue ( ) != 'checked' ) ) ;
this . chShowDel . setDisabled ( checked ) ;
2020-05-25 17:25:16 +00:00
2020-08-20 10:24:48 +00:00
value = slicerprops . asc _getName ( ) ;
this . inputName . setValue ( value !== null && value !== undefined ? value : '' ) ;
this . inputName . setDisabled ( value === null || value === undefined ) ;
2020-05-26 14:14:58 +00:00
this . lblSource . text ( slicerprops . asc _getSourceName ( ) ) ;
this . lblFormula . text ( slicerprops . asc _getNameInFormulas ( ) ) ;
2020-05-25 17:25:16 +00:00
2020-05-26 20:26:36 +00:00
value = slicerprops . asc _getStyle ( ) ;
2020-05-27 15:34:15 +00:00
var rec = this . mnuSlicerPicker . store . findWhere ( { type : value } ) ;
2020-05-27 20:28:27 +00:00
if ( ! rec && this . mnuSlicerPicker . store . length > 0 ) {
2020-05-27 15:34:15 +00:00
rec = this . mnuSlicerPicker . store . at ( 0 ) ;
}
2020-05-27 20:28:27 +00:00
if ( rec ) {
this . btnSlicerStyle . suspendEvents ( ) ;
this . mnuSlicerPicker . selectRecord ( rec , true ) ;
this . btnSlicerStyle . resumeEvents ( ) ;
this . $window . find ( '.icon-template-slicer' ) . css ( { 'background-image' : 'url(' + rec . get ( "imageUrl" ) + ')' , 'height' : '49px' , 'width' : '36px' , 'background-position' : 'center' , 'background-size' : 'cover' } ) ;
} else
this . $window . find ( '.icon-template-slicer' ) . css ( { 'height' : '49px' , 'width' : '36px' , 'background-position' : 'center' , 'background-size' : 'cover' } ) ;
2020-05-26 20:26:36 +00:00
2020-05-25 17:25:16 +00:00
this . _noApply = false ;
this . _changedProps = slicerprops ;
}
2020-04-14 11:58:40 +00:00
}
} ,
updateMetricUnit : function ( ) {
if ( this . spinners ) {
for ( var i = 0 ; i < this . spinners . length ; i ++ ) {
var spinner = this . spinners [ i ] ;
spinner . setDefaultUnit ( Common . Utils . Metric . getCurrentMetricName ( ) ) ;
}
}
} ,
afterRender : function ( ) {
this . updateMetricUnit ( ) ;
2020-05-27 15:34:15 +00:00
this . onInitStyles ( this . options . styles ) ;
2020-04-14 11:58:40 +00:00
this . _setDefaults ( this . _originalProps ) ;
if ( this . storageName ) {
var value = Common . localStorage . getItem ( this . storageName ) ;
this . setActiveCategory ( ( value !== null ) ? parseInt ( value ) : 0 ) ;
}
} ,
2020-05-26 20:26:36 +00:00
onInitStyles : function ( Templates ) {
2020-05-27 20:28:27 +00:00
var arr = [ ] ;
2020-05-27 15:34:15 +00:00
Templates && _ . each ( Templates , function ( template ) {
2020-05-26 20:26:36 +00:00
arr . push ( {
id : Common . UI . getId ( ) ,
2020-05-27 15:34:15 +00:00
type : template . asc _getName ( ) ,
2020-05-26 20:26:36 +00:00
imageUrl : template . asc _getImage ( ) ,
allowSelected : true ,
selected : false
} ) ;
} ) ;
this . mnuSlicerPicker . store . reset ( arr ) ;
2020-05-27 20:28:27 +00:00
this . btnSlicerStyle . setDisabled ( this . mnuSlicerPicker . store . length < 1 ) ;
2020-05-26 20:26:36 +00:00
} ,
2020-05-27 15:34:15 +00:00
onSelectSlicerStyle : function ( btn , picker , itemView , record ) {
2020-04-14 11:58:40 +00:00
if ( this . _noApply ) return ;
if ( this . _changedProps ) {
2020-05-26 20:26:36 +00:00
this . _changedProps . asc _setStyle ( record . get ( 'type' ) ) ;
2020-04-14 11:58:40 +00:00
}
2020-05-27 20:28:27 +00:00
this . $window . find ( '.icon-template-slicer' ) . css ( { 'background-image' : 'url(' + record . get ( "imageUrl" ) + ')' , 'height' : '49px' , 'width' : '36px' , 'background-position' : 'center' , 'background-size' : 'cover' } ) ;
2020-04-14 11:58:40 +00:00
} ,
2020-05-27 17:20:08 +00:00
onRadioSnapChange : function ( field , newValue , eOpts ) {
if ( newValue && this . _originalProps ) {
this . _originalProps . asc _putAnchor ( field . options . value ) ;
}
} ,
2020-08-18 13:23:52 +00:00
isNameValid : function ( ) {
if ( this . isNameChanged && _ . isEmpty ( this . inputName . getValue ( ) ) ) {
this . setActiveCategory ( 2 ) ;
this . inputName . cmpEl . find ( 'input' ) . focus ( ) ;
return false ;
}
return true ;
} ,
2020-05-26 14:27:49 +00:00
textTitle : 'Slicer - Advanced Settings' ,
2020-04-14 11:58:40 +00:00
textHeader : 'Header' ,
strStyle : 'Style' ,
strSize : 'Size' ,
strWidth : 'Width' ,
strHeight : 'Height' ,
strButtons : 'Buttons' ,
strColumns : 'Columns' ,
textSort : 'Sort' ,
textSourceName : 'Source name' ,
textFormulaName : 'Name to use in formulas' ,
textName : 'Name' ,
strStyleSize : 'Style & Size' ,
strSorting : 'Sorting & Filtering' ,
strReferences : 'References' ,
txtEmpty : 'This field is required' ,
strShowHeader : 'Display header' ,
textAsc : 'Ascending' ,
textDesc : 'Descending' ,
textAZ : 'A to Z' ,
textZA : 'Z to A' ,
textOldNew : 'oldest to newest' ,
textNewOld : 'newest to oldest' ,
textSmallLarge : 'smallest to largest' ,
textLargeSmall : 'largest to smallest' ,
strHideNoData : 'Hide items with no data' ,
strIndNoData : 'Visually indicate items with no data' ,
strShowNoData : 'Show items with no data last' ,
2020-05-26 14:14:58 +00:00
strShowDel : 'Show items deleted from the data source' ,
textAlt : 'Alternative Text' ,
textAltTitle : 'Title' ,
textAltDescription : 'Description' ,
textAltTip : 'The alternative text-based representation of the visual object information, which will be read to the people with vision or cognitive impairments to help them better understand what information there is in the image, autoshape, chart or table.' ,
2020-05-27 17:20:08 +00:00
textSnap : 'Cell Snapping' ,
textAbsolute : 'Don\'t move or size with cells' ,
textOneCell : 'Move but don\'t size with cells' ,
2020-05-28 14:59:49 +00:00
textTwoCell : 'Move and size with cells' ,
textKeepRatio : 'Constant Proportions'
2020-04-14 11:58:40 +00:00
2020-05-26 14:14:58 +00:00
} , SSE . Views . SlicerSettingsAdvanced || { } ) ) ;
2020-04-14 11:58:40 +00:00
} ) ;