Commit af20ed60 authored by Julia Radzhabova's avatar Julia Radzhabova

Merge branch 'develop' into feature/de-plugins

# Conflicts:
#	apps/documenteditor/sdk_dev_scripts.js
parents 57e7d1dc f25358b3
/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
/**
* ColorPaletteExt.js
*
* Created by Julia Radzhabova on 07/21/15
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
*
*/
if (Common === undefined)
var Common = {};
define([
'common/main/lib/component/BaseView'
], function () { 'use strict';
Common.UI.ColorPaletteExt = Common.UI.BaseView.extend({
options: {
dynamiccolors: 10,
allowReselect: true,
cls: '',
style: ''
},
template:
_.template([
'<div class="palette-color-ext">',
'<% var me = this; %>',
'<% $(colors).each(function(num, item) { %>',
'<% if (me.isColor(item)) { %>',
'<div class="palette-color-item palette-color color-<%=item%>" style="background:#<%=item%>" hidefocus="on">',
'<em><span style="background:#<%=item%>;" unselectable="on">&#160;</span></em>',
'</div>',
'<% } else if (me.isTransparent(item)) { %>',
'<div class="palette-color-item color-<%=item%>" hidefocus="on">',
'<em><span unselectable="on">&#160;</span></em>',
'</div>',
'<% } else if (me.isEffect(item)) { %>',
'<div effectid="<%=item.effectId%>" effectvalue="<%=item.effectValue%>" class="palette-color-item palette-color-effect color-<%=item.color%>" style="background:#<%=item.color%>" hidefocus="on">',
'<em><span style="background:#<%=item.color%>;" unselectable="on">&#160;</span></em>',
'</div>',
'<% } %>',
'<% }); %>',
'</div>'].join('')),
colorRe: /(?:^|\s)color-(.{6})(?:\s|$)/,
selectedCls: 'selected',
initialize : function(options) {
Common.UI.BaseView.prototype.initialize.call(this, options);
this.id = this.options.id;
this.cls = this.options.cls;
this.style = this.options.style;
this.colors = this.options.colors || [];
this.value = this.options.value;
if (this.options.el)
this.render();
if (this.options.value)
this.select(this.options.value, true);
},
render: function (parentEl) {
var me = this;
if (!me.rendered) {
this.cmpEl = $(this.template({
id : this.id,
cls : this.cls,
style : this.style,
colors : this.colors
}));
if (parentEl) {
this.setElement(parentEl, false);
parentEl.html(this.cmpEl);
} else {
$(this.el).html(this.cmpEl);
}
this.cmpEl.on('click', _.bind(this.handleClick, this));
} else {
this.cmpEl = $(this.el);
}
me.rendered = true;
return this;
},
isColor: function(v) {
return typeof(v) == 'string' && (/[0-9A-F]{6}/).test(v);
},
isTransparent: function(v) {
return typeof(v) == 'string' && (v=='transparent');
},
isEffect: function(v) {
return (typeof(v) == 'object' && v.effectId !== undefined);
},
getColor: function() {
return this.value;
},
handleClick: function(e) {
var me = this;
var target = $(e.target).closest('div.palette-color-item');
var color, cmp;
if (target.length==0) return;
if (target.hasClass('color-transparent') ) {
$(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls);
target.addClass(me.selectedCls);
me.value = 'transparent';
me.trigger('select', me, 'transparent');
} else {
if (!/^[a-fA-F0-9]{6}$/.test(me.value) || _.indexOf(me.colors, me.value)<0 )
me.value = false;
$(me.el).find('div.' + me.selectedCls).removeClass(me.selectedCls);
target.addClass(me.selectedCls);
color = target[0].className.match(me.colorRe)[1];
if ( target.hasClass('palette-color-effect') ) {
var effectId = parseInt(target.attr('effectid'));
if (color) {
me.value = color.toUpperCase();
me.trigger('select', me, {color: color, effectId: effectId});
}
} else {
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
me.value = color;
me.trigger('select', me, color);
}
}
}
},
select: function(color, suppressEvent) {
var el = $(this.el);
el.find('div.' + this.selectedCls).removeClass(this.selectedCls);
if (!color) return;
if (typeof(color) == 'object' ) {
var effectEl;
if (color.effectId !== undefined) {
effectEl = el.find('div[effectid="'+color.effectId+'"]').first();
if (effectEl.length>0) {
effectEl.addClass(this.selectedCls);
this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
} else
this.value = false;
} else if (color.effectValue !== undefined) {
effectEl = el.find('div[effectvalue="'+color.effectValue+'"].color-' + color.color.toUpperCase()).first();
if (effectEl.length>0) {
effectEl.addClass(this.selectedCls);
this.value = effectEl[0].className.match(this.colorRe)[1].toUpperCase();
} else
this.value = false;
}
} else {
if (/#?[a-fA-F0-9]{6}/.test(color)) {
color = /#?([a-fA-F0-9]{6})/.exec(color)[1].toUpperCase();
this.value = color;
}
if (/^[a-fA-F0-9]{6}|transparent$/.test(color) && _.indexOf(this.colors, color)>=0 ) {
if (_.indexOf(this.colors, this.value)<0) this.value = false;
if (color != this.value || this.options.allowReselect) {
(color == 'transparent') ? el.find('div.color-transparent').addClass(this.selectedCls) : el.find('div.palette-color.color-' + color).first().addClass(this.selectedCls);
this.value = color;
if (suppressEvent !== true) {
this.fireEvent('select', this, color);
}
}
} else {
var co = el.find('#'+color).first();
if (co.length==0)
co = el.find('div[color="'+color+'"]').first();
if (co.length>0) {
co.addClass(this.selectedCls);
this.value = color.toUpperCase();
}
}
}
},
updateColors: function(effectcolors) {
if (effectcolors===undefined) return;
this.colors = effectcolors;
this.cmpEl = $(this.template({
id : this.id,
cls : this.cls,
style : this.style,
colors : this.colors
}));
$(this.el).html(this.cmpEl);
this.cmpEl.on('click', _.bind(this.handleClick, this));
},
clearSelection: function(suppressEvent) {
$(this.el).find('div.' + this.selectedCls).removeClass(this.selectedCls);
this.value = undefined;
}
});
});
\ No newline at end of file
...@@ -138,7 +138,7 @@ ...@@ -138,7 +138,7 @@
@common-controls-width: 100px; @common-controls-width: 100px;
.img-commonctrl, .img-commonctrl,
.theme-colorpalette .color-transparent, .dropdown-menu li .checked:before, .input-error:before { .theme-colorpalette .color-transparent, .palette-color-ext .color-transparent, .dropdown-menu li .checked:before, .input-error:before {
background: e(%("url(%s)",'@{common-image-path}/@{common-controls}')) no-repeat; background: e(%("url(%s)",'@{common-image-path}/@{common-controls}')) no-repeat;
@media @media
......
...@@ -10,4 +10,46 @@ ...@@ -10,4 +10,46 @@
.box-shadow(0 0 0 1px @primary); .box-shadow(0 0 0 1px @primary);
} }
} }
}
.palette-color-ext {
padding: 10px;
.palette-color-item {
padding: 0;
border: 1px solid #fff;
display: inline-block;
text-decoration: none;
-moz-outline: 0 none;
outline: 0 none;
cursor: pointer;
vertical-align: middle;
em {
border: none;
display: block;
span{
height: 12px;
width: 12px;
cursor: pointer;
display: block;
border: 1px solid rgba(0, 0, 0, 0.2);
}
}
&:hover, &.selected {
border-color: #000;
em span {
border-color: #fff;
}
}
}
.color-transparent {
background-position: @nocolor-offset-x @nocolor-offset-y;
em span {
border:solid 1px #C0C0C0;
}
}
} }
\ No newline at end of file
...@@ -98,6 +98,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat ...@@ -98,6 +98,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
this._nRatio = 1; this._nRatio = 1;
this._originalProps = this.options.imageProps; this._originalProps = this.options.imageProps;
this.sectionProps = this.options.sectionProps;
this.pageWidth = this.options.sectionProps ? this.options.sectionProps.get_W() : 210; this.pageWidth = this.options.sectionProps ? this.options.sectionProps.get_W() : 210;
this.pageHeight = this.options.sectionProps ? this.options.sectionProps.get_H() : 297; this.pageHeight = this.options.sectionProps ? this.options.sectionProps.get_H() : 297;
this._changedProps = null; this._changedProps = null;
...@@ -327,10 +328,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat ...@@ -327,10 +328,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
}, this)); }, this));
this._arrHRelativePc = [ this._arrHRelativePc = [
{displayValue: this.textLeftMargin, value: Asc.c_oAscRelativeFromH.LeftMargin}, {displayValue: this.textLeftMargin, value: Asc.c_oAscRelativeFromH.LeftMargin, size: this.sectionProps.get_LeftMargin()},
{displayValue: this.textMargin, value: Asc.c_oAscRelativeFromH.Margin}, {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromH.Margin, size: this.sectionProps.get_W() - this.sectionProps.get_LeftMargin() - this.sectionProps.get_RightMargin()},
{displayValue: this.textPage, value: Asc.c_oAscRelativeFromH.Page}, {displayValue: this.textPage, value: Asc.c_oAscRelativeFromH.Page, size: this.sectionProps.get_W()},
{displayValue: this.textRightMargin, value: Asc.c_oAscRelativeFromH.RightMargin} {displayValue: this.textRightMargin, value: Asc.c_oAscRelativeFromH.RightMargin, size: this.sectionProps.get_RightMargin()}
]; ];
this.cmbWidthPc = new Common.UI.ComboBox({ this.cmbWidthPc = new Common.UI.ComboBox({
...@@ -345,10 +346,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat ...@@ -345,10 +346,10 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
this.cmbWidthPc.on('selected', _.bind(this.onCmbWidthPcSelect, this)); this.cmbWidthPc.on('selected', _.bind(this.onCmbWidthPcSelect, this));
this._arrVRelativePc = [ this._arrVRelativePc = [
{displayValue: this.textMargin, value: Asc.c_oAscRelativeFromV.Margin}, {displayValue: this.textMargin, value: Asc.c_oAscRelativeFromV.Margin, size: this.sectionProps.get_H() - this.sectionProps.get_TopMargin() - this.sectionProps.get_BottomMargin()},
{displayValue: this.textBottomMargin, value: Asc.c_oAscRelativeFromV.BottomMargin}, {displayValue: this.textBottomMargin, value: Asc.c_oAscRelativeFromV.BottomMargin, size: this.sectionProps.get_BottomMargin()},
{displayValue: this.textPage, value: Asc.c_oAscRelativeFromV.Page}, {displayValue: this.textPage, value: Asc.c_oAscRelativeFromV.Page, size: this.sectionProps.get_H()},
{displayValue: this.textTopMargin, value: Asc.c_oAscRelativeFromV.TopMargin} {displayValue: this.textTopMargin, value: Asc.c_oAscRelativeFromV.TopMargin, size: this.sectionProps.get_TopMargin()}
]; ];
this.cmbHeightPc = new Common.UI.ComboBox({ this.cmbHeightPc = new Common.UI.ComboBox({
...@@ -1265,6 +1266,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat ...@@ -1265,6 +1266,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
for (i=0; i<this._arrHRelativePc.length; i++) { for (i=0; i<this._arrHRelativePc.length; i++) {
if (value == this._arrHRelativePc[i].value) { if (value == this._arrHRelativePc[i].value) {
this.cmbWidthPc.setValue(value); this.cmbWidthPc.setValue(value);
this.spnShapeWidth.setValue(Common.Utils.Metric.fnRecalcFromMM(this._arrHRelativePc[i].size * sizeRelH.get_Value()/100).toFixed(2), true);
this._state.ShapeWidthPcFrom = value; this._state.ShapeWidthPcFrom = value;
break; break;
} }
...@@ -1283,6 +1285,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat ...@@ -1283,6 +1285,7 @@ define([ 'text!documenteditor/main/app/template/ImageSettingsAdvanced.templat
for (i=0; i<this._arrVRelativePc.length; i++) { for (i=0; i<this._arrVRelativePc.length; i++) {
if (value == this._arrVRelativePc[i].value) { if (value == this._arrVRelativePc[i].value) {
this.cmbHeightPc.setValue(value); this.cmbHeightPc.setValue(value);
this.spnShapeHeight.setValue(Common.Utils.Metric.fnRecalcFromMM(this._arrVRelativePc[i].size * sizeRelV.get_Value()/100).toFixed(2), true);
this._state.ShapeHeightPcFrom = value; this._state.ShapeHeightPcFrom = value;
break; break;
} }
......
...@@ -142,7 +142,7 @@ var sdk_dev_scrpipts = [ ...@@ -142,7 +142,7 @@ var sdk_dev_scrpipts = [
"../../../../sdkjs/word/Private/MailMerge.js", "../../../../sdkjs/word/Private/MailMerge.js",
"../../../../sdkjs/word/Private/TrackRevisions.js", "../../../../sdkjs/word/Private/TrackRevisions.js",
"../../../../sdkjs/common/applyDocumentChanges.js", "../../../../sdkjs/common/applyDocumentChanges.js",
"../../../../sdkjs/common/Drawings/Format/OleObject.js", "../../../../sdkjs/common/Drawings/Format/OleObject.js",
"../../../../sdkjs/common/clipboard_base.js", "../../../../sdkjs/common/clipboard_base.js",
"../../../../sdkjs/common/plugins.js", "../../../../sdkjs/common/plugins.js",
"../../../../sdkjs/word/apiBuilder.js" "../../../../sdkjs/word/apiBuilder.js"
......
...@@ -152,6 +152,8 @@ define([ ...@@ -152,6 +152,8 @@ define([
view.pmiInsertCells.menu.on('item:click', _.bind(me.onInsertCells, me)); view.pmiInsertCells.menu.on('item:click', _.bind(me.onInsertCells, me));
view.pmiDeleteCells.menu.on('item:click', _.bind(me.onDeleteCells, me)); view.pmiDeleteCells.menu.on('item:click', _.bind(me.onDeleteCells, me));
view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me)); view.pmiSortCells.menu.on('item:click', _.bind(me.onSortCells, me));
view.pmiFilterCells.menu.on('item:click', _.bind(me.onFilterCells, me));
view.pmiReapply.on('click', _.bind(me.onReapply, me));
view.pmiClear.menu.on('item:click', _.bind(me.onClear, me)); view.pmiClear.menu.on('item:click', _.bind(me.onClear, me));
view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me)); view.pmiSelectTable.menu.on('item:click', _.bind(me.onSelectTable, me));
view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me)); view.pmiInsertTable.menu.on('item:click', _.bind(me.onInsertTable, me));
...@@ -336,13 +338,48 @@ define([ ...@@ -336,13 +338,48 @@ define([
onSortCells: function(menu, item) { onSortCells: function(menu, item) {
if (this.api) { if (this.api) {
this.api.asc_sortColFilter(item.value, ''); this.api.asc_sortColFilter(item.value, '', undefined, (item.value==Asc.c_oAscSortOptions.ByColorFill) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor);
Common.NotificationCenter.trigger('edit:complete', this.documentHolder); Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells'); Common.component.Analytics.trackEvent('DocumentHolder', 'Sort Cells');
} }
}, },
onFilterCells: function(menu, item) {
if (this.api) {
var autoFilterObject = new Asc.AutoFiltersOptions(),
filterObj = new Asc.AutoFilterObj();
if (item.value>0) {
filterObj.asc_setFilter(new Asc.ColorFilter());
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.ColorFilter);
var colorFilter = filterObj.asc_getFilter();
colorFilter.asc_setCellColor((item.value==1) ? null : false);
colorFilter.asc_setCColor((item.value==1) ? this.documentHolder.ssMenu.cellColor : this.documentHolder.ssMenu.fontColor);
} else {
filterObj.asc_setFilter(new Asc.CustomFilters());
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters);
var customFilter = filterObj.asc_getFilter();
customFilter.asc_setCustomFilters([new Asc.CustomFilter()]);
customFilter.asc_setAnd(true);
var customFilters = customFilter.asc_getCustomFilters();
customFilters[0].asc_setOperator(Asc.c_oAscCustomAutoFilter.equals);
// customFilters[0].asc_setVal('');
}
autoFilterObject.asc_setFilterObj(filterObj);
this.api.asc_applyAutoFilterByType(autoFilterObject);
Common.NotificationCenter.trigger('edit:complete', this.documentHolder);
Common.component.Analytics.trackEvent('DocumentHolder', 'Filter Cells');
}
},
onReapply: function() {
this.api.asc_reapplyAutoFilter(this.documentHolder.ssMenu.formatTableName);
},
onClear: function(menu, item) { onClear: function(menu, item) {
if (this.api) { if (this.api) {
this.api.asc_emptyCells(item.value); this.api.asc_emptyCells(item.value);
...@@ -1181,6 +1218,8 @@ define([ ...@@ -1181,6 +1218,8 @@ define([
formatTableInfo = cellinfo.asc_getFormatTableInfo(), formatTableInfo = cellinfo.asc_getFormatTableInfo(),
isintable = (formatTableInfo !== null); isintable = (formatTableInfo !== null);
documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null; documentHolder.ssMenu.formatTableName = (isintable) ? formatTableInfo.asc_getTableName() : null;
documentHolder.ssMenu.cellColor = cellinfo.asc_getFill().asc_getColor();
documentHolder.ssMenu.fontColor = cellinfo.asc_getFont().asc_getColor();
documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu); documentHolder.pmiInsertEntire.setVisible(isrowmenu||iscolmenu);
documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft); documentHolder.pmiInsertEntire.setCaption((isrowmenu) ? this.textInsertTop : this.textInsertLeft);
...@@ -1190,7 +1229,10 @@ define([ ...@@ -1190,7 +1229,10 @@ define([
documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiSelectTable.setVisible(iscellmenu && !iscelledit && isintable);
documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiInsertTable.setVisible(iscellmenu && !iscelledit && isintable);
documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable); documentHolder.pmiDeleteTable.setVisible(iscellmenu && !iscelledit && isintable);
documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit && !isintable); documentHolder.pmiSortCells.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
documentHolder.pmiFilterCells.setVisible((iscellmenu||cansort) && !iscelledit);
documentHolder.pmiReapply.setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
documentHolder.ssMenu.items[12].setVisible((iscellmenu||isallmenu||cansort) && !iscelledit);
documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc); documentHolder.pmiInsFunction.setVisible(iscellmenu||insfunc);
documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit); documentHolder.pmiAddNamedRange.setVisible(iscellmenu && !iscelledit);
...@@ -1218,7 +1260,7 @@ define([ ...@@ -1218,7 +1260,7 @@ define([
documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes); documentHolder.pmiFreezePanes.setCaption(this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? documentHolder.textUnFreezePanes : documentHolder.textFreezePanes);
/** coauthoring begin **/ /** coauthoring begin **/
documentHolder.ssMenu.items[13].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); documentHolder.ssMenu.items[16].setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments); documentHolder.pmiAddComment.setVisible(iscellmenu && !iscelledit && this.permissions.canCoAuthoring && this.permissions.canComments);
/** coauthoring end **/ /** coauthoring end **/
documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc); documentHolder.pmiCellMenuSeparator.setVisible(iscellmenu || isrowmenu || iscolmenu || isallmenu || insfunc);
...@@ -1236,17 +1278,20 @@ define([ ...@@ -1236,17 +1278,20 @@ define([
documentHolder.pmiClear.menu.items[3].setVisible(!this.permissions.isEditDiagram); documentHolder.pmiClear.menu.items[3].setVisible(!this.permissions.isEditDiagram);
documentHolder.pmiClear.menu.items[4].setVisible(!this.permissions.isEditDiagram); documentHolder.pmiClear.menu.items[4].setVisible(!this.permissions.isEditDiagram);
var filterInfo = cellinfo.asc_getAutoFilterInfo(); var filterInfo = cellinfo.asc_getAutoFilterInfo(),
filterInfo = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false; isApplyAutoFilter = (filterInfo) ? filterInfo.asc_getIsApplyAutoFilter() : false;
documentHolder.pmiInsertCells.menu.items[0].setDisabled(filterInfo); filterInfo = (filterInfo) ? filterInfo.asc_getIsAutoFilter() : null;
documentHolder.pmiDeleteCells.menu.items[0].setDisabled(filterInfo); documentHolder.pmiInsertCells.menu.items[0].setDisabled(isApplyAutoFilter);
documentHolder.pmiInsertCells.menu.items[1].setDisabled(filterInfo); documentHolder.pmiDeleteCells.menu.items[0].setDisabled(isApplyAutoFilter);
documentHolder.pmiDeleteCells.menu.items[1].setDisabled(filterInfo); documentHolder.pmiInsertCells.menu.items[1].setDisabled(isApplyAutoFilter);
documentHolder.pmiDeleteCells.menu.items[1].setDisabled(isApplyAutoFilter);
_.each(documentHolder.ssMenu.items, function(item) { _.each(documentHolder.ssMenu.items, function(item) {
item.setDisabled(isCellLocked); item.setDisabled(isCellLocked);
}); });
documentHolder.pmiCopy.setDisabled(false); documentHolder.pmiCopy.setDisabled(false);
documentHolder.pmiSortCells.setDisabled(isCellLocked || (filterInfo==null));
documentHolder.pmiReapply.setDisabled(isCellLocked || (isApplyAutoFilter!==true));
if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event); if (showMenu) this.showPopupMenu(documentHolder.ssMenu, {}, event);
} else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) { } else if (this.permissions.isEditDiagram && seltype == Asc.c_oAscSelectionType.RangeChartText) {
if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return; if (!showMenu && !documentHolder.textInShapeMenu.isVisible()) return;
......
...@@ -206,10 +206,10 @@ define([ ...@@ -206,10 +206,10 @@ define([
toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this)); toolbar.btnInsertText.on('click', _.bind(this.onBtnInsertTextClick, this));
toolbar.btnInsertText.menu.on('item:click', _.bind(this.onInsertTextClick, this)); toolbar.btnInsertText.menu.on('item:click', _.bind(this.onInsertTextClick, this));
toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this)); toolbar.btnInsertShape.menu.on('hide:after', _.bind(this.onInsertShapeHide, this));
toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, 'ascending')); toolbar.btnSortDown.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending));
toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, 'descending')); toolbar.btnSortUp.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
toolbar.mnuitemSortAZ.on('click', _.bind(this.onSortType, this, 'ascending')); toolbar.mnuitemSortAZ.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending));
toolbar.mnuitemSortZA.on('click', _.bind(this.onSortType, this, 'descending')); toolbar.mnuitemSortZA.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.btnSetAutofilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.mnuitemAutoFilter.on('click', _.bind(this.onAutoFilter, this)); toolbar.mnuitemAutoFilter.on('click', _.bind(this.onAutoFilter, this));
toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this)); toolbar.btnClearAutofilter.on('click', _.bind(this.onClearFilter, this));
......
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
*/ */
define([ define([
'common/main/lib/component/Window' 'common/main/lib/component/Window',
'common/main/lib/component/ColorPaletteExt'
], function () { ], function () {
'use strict'; 'use strict';
...@@ -66,29 +67,22 @@ define([ ...@@ -66,29 +67,22 @@ define([
this.template = options.template || [ this.template = options.template || [
'<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="box" style="height:' + (_options.height - 85) + 'px;">',
'<div class="content-panel" >', '<div class="content-panel" >',
'<label class="header">', t.textShowRows, '</label>',
'<label class="header">', t.textShowRows, '</label>', '<div style="margin-top:15px;">',
'<div id="id-search-begin-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>',
'<div style="margin-top:15px;">', '<div id="id-sd-cell-search-begin" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>',
'<div id="id-search-begin-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>', '</div>',
'<div id="id-sd-cell-search-begin" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>', '<div>',
'</div>', '<div id="id-and-radio" class="padding-small" style="display: inline-block; margin-top:10px;"></div>',
'<div id="id-or-radio" class="padding-small" style="display: inline-block; margin-left:25px;"></div>',
'<div>', '</div>',
'<div id="id-and-radio" class="padding-small" style="display: inline-block; margin-top:10px;"></div>', '<div style="margin-top:10px;">',
'<div id="id-or-radio" class="padding-small" style="display: inline-block; margin-left:25px;"></div>', '<div id="id-search-end-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>',
'</div>', '<div id="id-sd-cell-search-end" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>',
'</div>',
'<div style="margin-top:10px;">',
'<div id="id-search-end-digital-combo" class="input-group-nr" style="vertical-align:top;width:225px;display:inline-block;"></div>',
'<div id="id-sd-cell-search-end" class="" style="width:225px;display:inline-block;margin-left:18px;"></div>',
'</div>',
'</div>', '</div>',
'</div>', '</div>',
'<div class="separator horizontal" style="width:100%"></div>', '<div class="separator horizontal" style="width:100%"></div>',
'<div class="footer right" style="margin-left:-15px;">', '<div class="footer right" style="margin-left:-15px;">',
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">', t.okButtonText, '</button>', '<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">', t.okButtonText, '</button>',
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>', '<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
...@@ -97,6 +91,7 @@ define([ ...@@ -97,6 +91,7 @@ define([
this.api = options.api; this.api = options.api;
this.handler = options.handler; this.handler = options.handler;
this.type = options.type || 'number';
_options.tpl = _.template(this.template, _options); _options.tpl = _.template(this.template, _options);
...@@ -104,38 +99,40 @@ define([ ...@@ -104,38 +99,40 @@ define([
}, },
render: function () { render: function () {
Common.UI.Window.prototype.render.call(this); Common.UI.Window.prototype.render.call(this);
var conditions = [ this.conditions = [
{value: Asc.c_oAscCustomAutoFilter.equals, displayValue: this.capCondition1}, {value: Asc.c_oAscCustomAutoFilter.equals, displayValue: this.capCondition1},
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, displayValue: this.capCondition2}, {value: Asc.c_oAscCustomAutoFilter.doesNotEqual, displayValue: this.capCondition2},
{value: Asc.c_oAscCustomAutoFilter.isGreaterThan, displayValue: this.capCondition3}, {value: Asc.c_oAscCustomAutoFilter.isGreaterThan, displayValue: this.capCondition3},
{value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, displayValue: this.capCondition4}, {value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, displayValue: this.capCondition4},
{value: Asc.c_oAscCustomAutoFilter.isLessThan, displayValue: this.capCondition5}, {value: Asc.c_oAscCustomAutoFilter.isLessThan, displayValue: this.capCondition5},
{value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, displayValue: this.capCondition6}, {value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, displayValue: this.capCondition6}
];
if (this.type=='text') this.conditions = this.conditions.concat([
{value: Asc.c_oAscCustomAutoFilter.beginsWith, displayValue: this.capCondition7}, {value: Asc.c_oAscCustomAutoFilter.beginsWith, displayValue: this.capCondition7},
{value: Asc.c_oAscCustomAutoFilter.doesNotBeginWith, displayValue: this.capCondition8}, {value: Asc.c_oAscCustomAutoFilter.doesNotBeginWith, displayValue: this.capCondition8},
{value: Asc.c_oAscCustomAutoFilter.endsWith, displayValue: this.capCondition9}, {value: Asc.c_oAscCustomAutoFilter.endsWith, displayValue: this.capCondition9},
{value: Asc.c_oAscCustomAutoFilter.doesNotEndWith, displayValue: this.capCondition10}, {value: Asc.c_oAscCustomAutoFilter.doesNotEndWith, displayValue: this.capCondition10},
{value: Asc.c_oAscCustomAutoFilter.contains, displayValue: this.capCondition11}, {value: Asc.c_oAscCustomAutoFilter.contains, displayValue: this.capCondition11},
{value: Asc.c_oAscCustomAutoFilter.doesNotContain, displayValue: this.capCondition12} {value: Asc.c_oAscCustomAutoFilter.doesNotContain, displayValue: this.capCondition12}
]; ]);
this.cmbCondition1 = new Common.UI.ComboBox({ this.cmbCondition1 = new Common.UI.ComboBox({
el : $('#id-search-begin-digital-combo', this.$window), el : $('#id-search-begin-digital-combo', this.$window),
menuStyle : 'min-width: 225px;', menuStyle : 'min-width: 225px;',
cls : 'input-group-nr', cls : 'input-group-nr',
data : conditions, data : this.conditions,
editable : false editable : false
}); });
this.cmbCondition1.setValue(Asc.c_oAscCustomAutoFilter.equals); this.cmbCondition1.setValue(Asc.c_oAscCustomAutoFilter.equals);
conditions.splice(0, 0, {value: 0, displayValue: this.textNoFilter}); this.conditions.splice(0, 0, {value: 0, displayValue: this.textNoFilter});
this.cmbCondition2 = new Common.UI.ComboBox({ this.cmbCondition2 = new Common.UI.ComboBox({
el : $('#id-search-end-digital-combo', this.$window), el : $('#id-search-end-digital-combo', this.$window),
menuStyle : 'min-width: 225px;', menuStyle : 'min-width: 225px;',
cls : 'input-group-nr', cls : 'input-group-nr',
data : conditions, data : this.conditions,
editable : false editable : false
}); });
this.cmbCondition2.setValue(0); this.cmbCondition2.setValue(0);
...@@ -262,7 +259,7 @@ define([ ...@@ -262,7 +259,7 @@ define([
customFilters[1].asc_setVal(this.txtValue2.getValue()); customFilters[1].asc_setVal(this.txtValue2.getValue());
} }
this.api.asc_applyAutoFilter('digitalFilter', this.properties); this.api.asc_applyAutoFilter(this.properties);
} }
}, },
...@@ -295,14 +292,187 @@ define([ ...@@ -295,14 +292,187 @@ define([
}, SSE.Views.DigitalFilterDialog || {})); }, SSE.Views.DigitalFilterDialog || {}));
SSE.Views.Top10FilterDialog = Common.UI.Window.extend(_.extend({
initialize: function (options) {
var t = this, _options = {};
_.extend(_options, {
width : 318,
height : 160,
contentWidth : 180,
header : true,
cls : 'filter-dlg',
contentTemplate : '',
title : t.txtTitle,
items : []
}, options);
this.template = options.template || [
'<div class="box" style="height:' + (_options.height - 85) + 'px;">',
'<div class="content-panel" >',
'<div style="margin-right:15px; display: inline-block; vertical-align: middle;">',
'<label class="input-label">', t.textType, '</label>',
'<div id="id-top10-type-combo" style=""></div>',
'</div>',
'<div style="margin-right:15px; display: inline-block; vertical-align: middle;">',
'<label class="input-label"></label>',
'<div id="id-top10-count-spin" class="input-group-nr" style=""></div>',
'</div>',
'<div style="display: inline-block; vertical-align: middle;">',
'<label class="input-label"></label>',
'<div id="id-top10-item-combo" class="input-group-nr" style=""></div>',
'</div>',
'</div>',
'</div>',
'<div class="separator horizontal" style="width:100%"></div>',
'<div class="footer center">',
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right:10px;">', t.okButtonText, '</button>',
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
'</div>'
].join('');
this.api = options.api;
this.handler = options.handler;
_options.tpl = _.template(this.template, _options);
Common.UI.Window.prototype.initialize.call(this, _options);
},
render: function () {
Common.UI.Window.prototype.render.call(this);
this.cmbType = new Common.UI.ComboBox({
el : $('#id-top10-type-combo', this.$window),
style : 'width: 85px;',
menuStyle : 'min-width: 85px;',
cls : 'input-group-nr',
data : [
{ value: true, displayValue: this.txtTop },
{ value: false, displayValue: this.txtBottom }
],
editable : false
});
this.cmbType.setValue(true);
this.cmbItem = new Common.UI.ComboBox({
el : $('#id-top10-item-combo', this.$window),
style : 'width: 85px;',
menuStyle : 'min-width: 85px;',
cls : 'input-group-nr',
data : [
{ value: false, displayValue: this.txtItems },
{ value: true, displayValue: this.txtPercent }
],
editable : false
});
this.cmbItem.setValue(false);
this.cmbItem.on('selected', _.bind(function(combo, record) {
this.spnCount.setDefaultUnit(record.value ? '%' : '');
}, this));
this.spnCount = new Common.UI.MetricSpinner({
el: $('#id-top10-count-spin'),
step: 1,
width: 85,
defaultUnit : "",
value: '10',
maxValue: 500,
minValue: 1
});
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.loadDefaults();
},
show: function () {
Common.UI.Window.prototype.show.call(this);
var me = this;
_.defer(function () {
if (me.txtValue1) {
me.txtValue1.focus();
}
}, 500);
},
close: function () {
if (this.api) {
this.api.asc_enableKeyEvents(true);
}
Common.UI.Window.prototype.close.call(this);
},
onBtnClick: function (event) {
if (event.currentTarget.attributes && event.currentTarget.attributes.result) {
if ('ok' === event.currentTarget.attributes.result.value) {
this.save();
}
this.close();
}
},
setSettings: function (properties) {
this.properties = properties;
},
loadDefaults: function () {
if (this.properties) {
var filterObj = this.properties.asc_getFilterObj();
if (filterObj.asc_getType() == Asc.c_oAscAutoFilterTypes.Top10) {
var top10Filter = filterObj.asc_getFilter(),
type = top10Filter.asc_getTop(),
percent = top10Filter.asc_getPercent();
this.cmbType.setValue(type || type===null);
this.cmbItem.setValue(percent || percent===null);
this.spnCount.setDefaultUnit((percent || percent===null) ? '%' : '');
this.spnCount.setValue(top10Filter.asc_getVal());
}
}
},
save: function () {
if (this.api && this.properties) {
var filterObj = this.properties.asc_getFilterObj();
filterObj.asc_setFilter(new Asc.Top10());
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.Top10);
var top10Filter = filterObj.asc_getFilter();
top10Filter.asc_setTop(this.cmbType.getValue());
top10Filter.asc_setPercent(this.cmbItem.getValue());
top10Filter.asc_setVal(this.spnCount.getNumberValue());
this.api.asc_applyAutoFilter(this.properties);
}
},
onPrimary: function() {
this.save();
this.close();
return false;
},
cancelButtonText : "Cancel",
okButtonText : 'OK',
txtTitle : "Top 10 AutoFilter",
textType : 'Show',
txtTop : 'Top',
txtBottom : 'Bottom',
txtItems : 'Item',
txtPercent : 'Percent'
}, SSE.Views.Top10FilterDialog || {}));
SSE.Views.AutoFilterDialog = Common.UI.Window.extend(_.extend({ SSE.Views.AutoFilterDialog = Common.UI.Window.extend(_.extend({
initialize: function (options) { initialize: function (options) {
var t = this, _options = {}; var t = this, _options = {};
_.extend(_options, { _.extend(_options, {
width : 270, width : 423,
height : 450, height : 301,
contentWidth : 400, contentWidth : 400,
header : true, header : true,
cls : 'filter-dlg', cls : 'filter-dlg',
...@@ -312,32 +482,30 @@ define([ ...@@ -312,32 +482,30 @@ define([
}, options); }, options);
this.template = options.template || [ this.template = options.template || [
'<div class="box" style="height:' + (_options.height - 85) + 'px;">', '<div class="box" style="height:' + (_options.height - 36) + 'px;">',
'<div class="content-panel">', '<div class="content-panel" style="width: 250px;">',
'<div class="">', '<div class="">',
'<div id="id-btn-sort-down" class="btn-placeholder border"></div>', '<div id="id-sd-cell-search" style="height:22px; margin-bottom:10px;"></div>',
'<div id="id-btn-sort-up" class="btn-placeholder border"></div>', '<div class="border-values" style="">',
'<div id="id-checkbox-custom-filter" style="max-width:50px;margin-left:50px;display:inline-block;"></div>',
'<button class="btn normal dlg-btn primary" result="custom" id="id-btn-custom-filter" style="min-width:120px;">',
t.btnCustomFilter,
'</button>',
'<div id="id-sd-cell-search" class="input-row" style="margin-bottom:10px;"></div>',
'<div class="border-values" style="margin-top:45px;">',
'<div id="id-dlg-filter-values" class="combo-values"/>', '<div id="id-dlg-filter-values" class="combo-values"/>',
'</div>', '</div>',
'</div>', '</div>',
'<div class="footer center">',
'<div id="id-apply-filter" style="display: inline-block;"></div>',
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
'</div>',
'</div>',
'<div class="separator"/>',
'<div class="menu-panel" style="width: 170px;">',
'<div id="menu-container-filters" style=""><div class="dropdown-toggle" data-toggle="dropdown"></div></div>',
'</div>', '</div>',
'</div>',
'<div class="separator horizontal"></div>',
'<div class="footer center">',
'<div id="id-apply-filter" style="display: inline-block;"></div>',
'<button class="btn normal dlg-btn" result="cancel">', t.cancelButtonText, '</button>',
'</div>' '</div>'
].join(''); ].join('');
this.api = options.api; this.api = options.api;
this.handler = options.handler; this.handler = options.handler;
this.throughIndexes = []; this.throughIndexes = [];
this.filteredIndexes = [];
_options.tpl = _.template(this.template, _options); _options.tpl = _.template(this.template, _options);
...@@ -364,45 +532,190 @@ define([ ...@@ -364,45 +532,190 @@ define([
this.btnOk.on('click', _.bind(this.onApplyFilter, this)); this.btnOk.on('click', _.bind(this.onApplyFilter, this));
} }
this.btnSortDown = new Common.UI.Button({ this.miSortLow2High = new Common.UI.MenuItem({
cls: 'btn-toolbar border', caption : this.txtSortLow2High,
iconCls: 'btn-icon btn-sort-down', toggleGroup : 'menufiltersort',
pressed : true, checkable : true,
enableToggle: true, checked : false
allowDepress: false
}); });
if (this.btnSortDown) { this.miSortLow2High.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Ascending));
this.btnSortDown.render($('#id-btn-sort-down', this.$window));
this.btnSortDown.on('click', _.bind(this.onSortType, this, 'ascending'));
}
this.btnSortUp = new Common.UI.Button({ this.miSortHigh2Low = new Common.UI.MenuItem({
cls: 'btn-toolbar border', caption : this.txtSortHigh2Low,
iconCls: 'btn-icon btn-sort-up', toggleGroup : 'menufiltersort',
pressed : true, checkable : true,
enableToggle: true, checked : false
allowDepress: false });
this.miSortHigh2Low.on('click', _.bind(this.onSortType, this, Asc.c_oAscSortOptions.Descending));
this.miSortCellColor = new Common.UI.MenuItem({
caption : this.txtSortCellColor,
toggleGroup : 'menufiltersort',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
style: 'min-width: inherit; padding: 0px;',
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="filter-dlg-sort-cells-color" style="max-width: 147px; max-height: 120px;"></div>') }
]
})
});
this.miSortFontColor = new Common.UI.MenuItem({
caption : this.txtSortFontColor,
toggleGroup : 'menufiltersort',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
style: 'min-width: inherit; padding: 0px;',
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="filter-dlg-sort-font-color" style="max-width: 147px; max-height: 120px;"></div>') }
]
})
}); });
if (this.btnSortUp) { this.miNumFilter = new Common.UI.MenuItem({
this.btnSortUp.render($('#id-btn-sort-up', this.$window)); caption : this.txtNumFilter,
this.btnSortUp.on('click', _.bind(this.onSortType, this, 'descending')); toggleGroup : 'menufilterfilter',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{value: Asc.c_oAscCustomAutoFilter.equals, caption: this.txtEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, caption: this.txtNotEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.isGreaterThan, caption: this.txtGreater, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo, caption: this.txtGreaterEquals,checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.isLessThan, caption: this.txtLess, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo, caption: this.txtLessEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: -2, caption: this.txtBetween, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.top10, caption: this.txtTop10, checkable: true, type: Asc.c_oAscAutoFilterTypes.Top10},
{value: Asc.c_oAscDynamicAutoFilter.aboveAverage, caption: this.txtAboveAve, checkable: true, type: Asc.c_oAscAutoFilterTypes.DynamicFilter},
{value: Asc.c_oAscDynamicAutoFilter.belowAverage, caption: this.txtBelowAve, checkable: true, type: Asc.c_oAscAutoFilterTypes.DynamicFilter},
{value: -1, caption: this.btnCustomFilter + '...', checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters}
]
})
});
var items = this.miNumFilter.menu.items;
for (var i=0; i<items.length; i++) {
items[i].on('click', _.bind((items[i].options.type == Asc.c_oAscAutoFilterTypes.CustomFilters) ? this.onNumCustomFilterItemClick :
((items[i].options.type == Asc.c_oAscAutoFilterTypes.DynamicFilter) ? this.onNumDynamicFilterItemClick : this.onTop10FilterItemClick ), this));
} }
this.chCustomFilter = new Common.UI.CheckBox({ this.miTextFilter = new Common.UI.MenuItem({
el: $('#id-checkbox-custom-filter', this.$window) caption : this.txtTextFilter,
toggleGroup : 'menufilterfilter',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{value: Asc.c_oAscCustomAutoFilter.equals, caption: this.txtEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.doesNotEqual, caption: this.txtNotEquals, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.beginsWith, caption: this.txtBegins, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.doesNotBeginWith, caption: this.txtNotBegins, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.endsWith, caption: this.txtEnds, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.doesNotEndWith, caption: this.txtNotEnds, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.contains, caption: this.txtContains, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: Asc.c_oAscCustomAutoFilter.doesNotContain, caption: this.txtNotContains, checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters},
{value: -1, caption: this.btnCustomFilter + '...', checkable: true, type: Asc.c_oAscAutoFilterTypes.CustomFilters}
]
})
});
this.miTextFilter.menu.on('item:click', _.bind(this.onTextFilterMenuClick, this));
this.miFilterCellColor = new Common.UI.MenuItem({
caption : this.txtFilterCellColor,
toggleGroup : 'menufilterfilter',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
style: 'min-width: inherit; padding: 0px;',
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="filter-dlg-filter-cells-color" style="max-width: 147px; max-height: 120px;"></div>') }
]
})
});
this.miFilterFontColor = new Common.UI.MenuItem({
caption : this.txtFilterFontColor,
toggleGroup : 'menufilterfilter',
checkable : true,
checked : false,
menu : new Common.UI.Menu({
style: 'min-width: inherit; padding: 0px;',
menuAlign: 'tl-tr',
items: [
{ template: _.template('<div id="filter-dlg-filter-font-color" style="max-width: 147px; max-height: 120px;"></div>') }
]
})
});
this.miClear = new Common.UI.MenuItem({
caption : this.txtClear,
checkable : false
}); });
this.chCustomFilter.setDisabled(true); this.miClear.on('click', _.bind(this.onClear, this));
this.btnCustomFilter = new Common.UI.Button({ this.miReapply = new Common.UI.MenuItem({
el : $('#id-btn-custom-filter', this.$window) caption : this.txtReapply,
}).on('click', _.bind(this.onShowCustomFilterDialog, this)); checkable : false
});
this.miReapply.on('click', _.bind(this.onReapply, this));
this.filtersMenu = new Common.UI.Menu({
items: [
this.miSortLow2High,
this.miSortHigh2Low,
this.miSortCellColor,
this.miSortFontColor,
{caption : '--'},
this.miNumFilter,
this.miTextFilter,
this.miFilterCellColor,
this.miFilterFontColor,
this.miClear,
{caption : '--'},
this.miReapply
]
});
// Prepare menu container
var menuContainer = this.$window.find('#menu-container-filters');
this.filtersMenu.render(menuContainer);
this.filtersMenu.cmpEl.attr({tabindex: "-1"});
this.mnuSortColorCellsPicker = new Common.UI.ColorPaletteExt({
el: $('#filter-dlg-sort-cells-color'),
colors: []
});
this.mnuSortColorCellsPicker.on('select', _.bind(this.onSortColorSelect, this, Asc.c_oAscSortOptions.ByColorFill));
this.mnuSortColorFontPicker = new Common.UI.ColorPaletteExt({
el: $('#filter-dlg-sort-font-color'),
colors: []
});
this.mnuSortColorFontPicker.on('select', _.bind(this.onSortColorSelect, this, Asc.c_oAscSortOptions.ByColorFont));
this.mnuFilterColorCellsPicker = new Common.UI.ColorPaletteExt({
el: $('#filter-dlg-filter-cells-color'),
colors: []
});
this.mnuFilterColorCellsPicker.on('select', _.bind(this.onFilterColorSelect, this, true));
this.mnuFilterColorFontPicker = new Common.UI.ColorPaletteExt({
el: $('#filter-dlg-filter-font-color'),
colors: []
});
this.mnuFilterColorFontPicker.on('select', _.bind(this.onFilterColorSelect, this, false));
this.input = new Common.UI.InputField({ this.input = new Common.UI.InputField({
el : $('#id-sd-cell-search', this.$window), el : $('#id-sd-cell-search', this.$window),
allowBlank : true, allowBlank : true,
placeHolder : this.txtEmpty, placeHolder : this.txtEmpty,
style : 'margin-top: 10px;',
validateOnChange : true, validateOnChange : true,
validation : function () { return true; } validation : function () { return true; }
}).on ('changing', function (input, value) { }).on ('changing', function (input, value) {
...@@ -439,6 +752,8 @@ define([ ...@@ -439,6 +752,8 @@ define([
this.cellsList.store.comparator = function(item1, item2) { this.cellsList.store.comparator = function(item1, item2) {
if ('0' == item1.get('groupid')) return -1; if ('0' == item1.get('groupid')) return -1;
if ('0' == item2.get('groupid')) return 1; if ('0' == item2.get('groupid')) return 1;
if ('2' == item1.get('groupid')) return -1;
if ('2' == item2.get('groupid')) return 1;
var n1 = item1.get('intval'), var n1 = item1.get('intval'),
n2 = item2.get('intval'), n2 = item2.get('intval'),
...@@ -453,7 +768,8 @@ define([ ...@@ -453,7 +768,8 @@ define([
this.cellsList.onKeyDown = _.bind(this.onListKeyDown, this); this.cellsList.onKeyDown = _.bind(this.onListKeyDown, this);
} }
this.setupListCells(); this.setupDataCells();
this._setDefaults();
}, },
show: function () { show: function () {
...@@ -480,6 +796,7 @@ define([ ...@@ -480,6 +796,7 @@ define([
this.close(); this.close();
} }
}, },
onSortType: function (type) { onSortType: function (type) {
if (this.api && this.configTo) { if (this.api && this.configTo) {
this.api.asc_sortColFilter(type, this.configTo.asc_getCellId(), this.configTo.asc_getDisplayName()); this.api.asc_sortColFilter(type, this.configTo.asc_getCellId(), this.configTo.asc_getDisplayName());
...@@ -487,9 +804,89 @@ define([ ...@@ -487,9 +804,89 @@ define([
this.close(); this.close();
}, },
onShowCustomFilterDialog: function () {
onNumCustomFilterItemClick: function(item) {
var filterObj = this.configTo.asc_getFilterObj(),
value1 = '', value2 = '',
cond1 = Asc.c_oAscCustomAutoFilter.equals,
cond2 = 0, isAnd = true;
if (filterObj.asc_getType() == Asc.c_oAscAutoFilterTypes.CustomFilters) {
var customFilter = filterObj.asc_getFilter(),
customFilters = customFilter.asc_getCustomFilters();
isAnd = (customFilter.asc_getAnd());
cond1 = customFilters[0].asc_getOperator();
cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0);
value1 = (null === customFilters[0].asc_getVal() ? '' : customFilters[0].asc_getVal());
value2 = ((customFilters.length>1) ? (null === customFilters[1].asc_getVal() ? '' : customFilters[1].asc_getVal()) : '');
}
if (item.value!==-1) {
var newCustomFilter = new Asc.CustomFilters();
newCustomFilter.asc_setCustomFilters((item.value == -2) ? [new Asc.CustomFilter(), new Asc.CustomFilter()]: [new Asc.CustomFilter()]);
var newCustomFilters = newCustomFilter.asc_getCustomFilters();
newCustomFilter.asc_setAnd(true);
newCustomFilters[0].asc_setOperator((item.value == -2) ? Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo : item.value);
if (item.value == -2) {
newCustomFilters[0].asc_setVal((cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo) ? value1 : '');
newCustomFilters[1].asc_setOperator(Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo);
newCustomFilters[1].asc_setVal((cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo) ? value2 : '');
} else {
newCustomFilters[0].asc_setVal((item.value == cond1) ? value1 : '');
}
filterObj.asc_setFilter(newCustomFilter);
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters);
}
var me = this,
dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({api:this.api, type: 'number'}).on({
'close': function() {
me.close();
}
});
this.close();
dlgDigitalFilter.setSettings(this.configTo);
dlgDigitalFilter.show();
},
onTextFilterMenuClick: function(menu, item) {
var filterObj = this.configTo.asc_getFilterObj(),
value1 = '', value2 = '',
cond1 = Asc.c_oAscCustomAutoFilter.equals,
cond2 = 0, isAnd = true;
if (filterObj.asc_getType() == Asc.c_oAscAutoFilterTypes.CustomFilters) {
var customFilter = filterObj.asc_getFilter(),
customFilters = customFilter.asc_getCustomFilters();
isAnd = (customFilter.asc_getAnd());
cond1 = customFilters[0].asc_getOperator();
cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0);
value1 = (null === customFilters[0].asc_getVal() ? '' : customFilters[0].asc_getVal());
value2 = ((customFilters.length>1) ? (null === customFilters[1].asc_getVal() ? '' : customFilters[1].asc_getVal()) : '');
}
if (item.value!==-1) {
var newCustomFilter = new Asc.CustomFilters();
newCustomFilter.asc_setCustomFilters([new Asc.CustomFilter()]);
var newCustomFilters = newCustomFilter.asc_getCustomFilters();
newCustomFilter.asc_setAnd(true);
newCustomFilters[0].asc_setOperator(item.value);
newCustomFilters[0].asc_setVal((item.value == cond1) ? value1 : '');
filterObj.asc_setFilter(newCustomFilter);
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.CustomFilters);
}
var me = this, var me = this,
dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({api:this.api}).on({ dlgDigitalFilter = new SSE.Views.DigitalFilterDialog({api:this.api, type: 'text'}).on({
'close': function() { 'close': function() {
me.close(); me.close();
} }
...@@ -500,6 +897,58 @@ define([ ...@@ -500,6 +897,58 @@ define([
dlgDigitalFilter.setSettings(this.configTo); dlgDigitalFilter.setSettings(this.configTo);
dlgDigitalFilter.show(); dlgDigitalFilter.show();
}, },
onNumDynamicFilterItemClick: function(item) {
var filterObj = this.configTo.asc_getFilterObj();
if (filterObj.asc_getType() !== Asc.c_oAscAutoFilterTypes.DynamicFilter) {
filterObj.asc_setFilter(new Asc.DynamicFilter());
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.DynamicFilter);
}
filterObj.asc_getFilter().asc_setType(item.value);
this.api.asc_applyAutoFilter(this.configTo);
this.close();
},
onTop10FilterItemClick: function(menu, item) {
var me = this,
dlgTop10Filter = new SSE.Views.Top10FilterDialog({api:this.api}).on({
'close': function() {
me.close();
}
});
this.close();
dlgTop10Filter.setSettings(this.configTo);
dlgTop10Filter.show();
},
onFilterColorSelect: function(isCellColor, picker, color) {
var filterObj = this.configTo.asc_getFilterObj();
if (filterObj.asc_getType() !== Asc.c_oAscAutoFilterTypes.ColorFilter) {
filterObj.asc_setFilter(new Asc.ColorFilter());
filterObj.asc_setType(Asc.c_oAscAutoFilterTypes.ColorFilter);
}
var colorFilter = filterObj.asc_getFilter();
colorFilter.asc_setCellColor(isCellColor ? null : false);
colorFilter.asc_setCColor((isCellColor && color == 'transparent' || !isCellColor && color == '#000000') ? null : Common.Utils.ThemeColor.getRgbColor(color));
this.api.asc_applyAutoFilter(this.configTo);
this.close();
},
onSortColorSelect: function(type, picker, color) {
if (this.api && this.configTo) {
var isCellColor = (type == Asc.c_oAscSortOptions.ByColorFill);
this.api.asc_sortColFilter(type, this.configTo.asc_getCellId(), this.configTo.asc_getDisplayName(), (isCellColor && color == 'transparent' || !isCellColor && color == '#000000') ? null : Common.Utils.ThemeColor.getRgbColor(color));
}
this.close();
},
onCellCheck: function (listView, itemView, record) { onCellCheck: function (listView, itemView, record) {
if (this.checkCellTrigerBlock) if (this.checkCellTrigerBlock)
return; return;
...@@ -549,21 +998,23 @@ define([ ...@@ -549,21 +998,23 @@ define([
if (record && listView) { if (record && listView) {
listView.isSuspendEvents = true; listView.isSuspendEvents = true;
var check = !record.get('check'); var check = !record.get('check'),
if ('1' !== record.get('groupid')) { me = this,
var arr = this.configTo.asc_getValues(); idxs = (me.filter) ? me.filteredIndexes : me.throughIndexes;
if ('0' == record.get('groupid')) {
this.cells.each(function(cell) { this.cells.each(function(cell) {
cell.set('check', check); if ('2' !== cell.get('groupid')) {
if (cell.get('throughIndex')>0) cell.set('check', check);
arr[parseInt(cell.get('throughIndex'))-1].asc_setVisible(check); if (cell.get('throughIndex')>1)
idxs[parseInt(cell.get('throughIndex'))] = check;
}
}); });
} else { } else {
record.set('check', check); record.set('check', check);
this.configTo.asc_getValues()[parseInt(record.get('throughIndex'))-1].asc_setVisible(check); idxs[parseInt(record.get('throughIndex'))] = check;
} }
this.btnOk.setDisabled(false); this.btnOk.setDisabled(false);
this.chCustomFilter.setValue(false);
this.configTo.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters); this.configTo.asc_getFilterObj().asc_setType(Asc.c_oAscAutoFilterTypes.Filters);
listView.isSuspendEvents = false; listView.isSuspendEvents = false;
...@@ -571,91 +1022,132 @@ define([ ...@@ -571,91 +1022,132 @@ define([
} }
}, },
onClear: function() {
if (this.api && this.configTo)
this.api.asc_clearFilterColumn(this.configTo.asc_getCellId(), this.configTo.asc_getDisplayName());
this.close();
},
onReapply: function() {
if (this.api && this.configTo)
this.api.asc_reapplyAutoFilter(this.config.asc_getDisplayName());
this.close();
},
setSettings: function (config) { setSettings: function (config) {
this.config = config; this.config = config;
this.configTo = config; this.configTo = config;
}, },
setupListCells: function () {
// TODO: рефакторинг, использовать setupDataCells(); _setDefaults: function() {
this.initialFilterType = this.configTo.asc_getFilterObj().asc_getType();
var filterObj = this.configTo.asc_getFilterObj(),
isCustomFilter = (this.initialFilterType === Asc.c_oAscAutoFilterTypes.CustomFilters),
isDynamicFilter = (this.initialFilterType === Asc.c_oAscAutoFilterTypes.DynamicFilter),
isTop10 = (this.initialFilterType === Asc.c_oAscAutoFilterTypes.Top10),
isTextFilter = this.configTo.asc_getIsTextFilter(),
colorsFill = this.configTo.asc_getColorsFill(),
colorsFont = this.configTo.asc_getColorsFont(),
sort = this.configTo.asc_getSortState(),
sortColor = this.configTo.asc_getSortColor();
if (sortColor) sortColor = Common.Utils.ThemeColor.getHexColor(sortColor.get_r(), sortColor.get_g(), sortColor.get_b()).toLocaleUpperCase();
this.miTextFilter.setVisible(isTextFilter);
this.miNumFilter.setVisible(!isTextFilter);
this.miTextFilter.setChecked(isCustomFilter && isTextFilter, true);
this.miNumFilter.setChecked((isCustomFilter || isDynamicFilter || isTop10) && !isTextFilter, true);
this.miSortLow2High.setChecked(sort == Asc.c_oAscSortOptions.Ascending, true);
this.miSortHigh2Low.setChecked(sort == Asc.c_oAscSortOptions.Descending, true);
var hasColors = (colorsFont && colorsFont.length>0);
this.miSortFontColor.setVisible(hasColors);
this.miFilterFontColor.setVisible(hasColors);
if (hasColors) {
var colors = [];
colorsFont.forEach(function(item, index) {
if (item)
colors.push(Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase());
else
colors.push('000000');
});
this.mnuSortColorFontPicker.updateColors(colors);
this.mnuFilterColorFontPicker.updateColors(colors);
function isNumeric(value) { this.miFilterFontColor.setChecked(false, true);
return !isNaN(parseFloat(value)) && isFinite(value); this.miSortFontColor.setChecked(sort == Asc.c_oAscSortOptions.ByColorFont, true);
if (sort == Asc.c_oAscSortOptions.ByColorFont)
this.mnuSortColorFontPicker.select((sortColor) ? sortColor : '000000', true);
} }
var me = this, isnumber, value, index = 0, haveUnselectedCell = false, hasColors = (colorsFill && colorsFill.length>0);
throughIndex = 1, this.miSortCellColor.setVisible(hasColors);
isCustomFilter = (this.configTo.asc_getFilterObj().asc_getType() === Asc.c_oAscAutoFilterTypes.CustomFilters); this.miFilterCellColor.setVisible(hasColors);
if (hasColors) {
if (_.isUndefined(this.config)) { var colors = [];
return; colorsFill.forEach(function(item, index) {
if (item)
colors.push(Common.Utils.ThemeColor.getHexColor(item.get_r(), item.get_g(), item.get_b()).toLocaleUpperCase());
else
colors.push('transparent');
});
this.mnuSortColorCellsPicker.updateColors(colors);
this.mnuFilterColorCellsPicker.updateColors(colors);
this.miFilterCellColor.setChecked(false, true);
this.miSortCellColor.setChecked(sort == Asc.c_oAscSortOptions.ByColorFill, true);
if (sort == Asc.c_oAscSortOptions.ByColorFill)
this.mnuSortColorCellsPicker.select((sortColor) ? sortColor : 'transparent', true);
} }
this.filterExcludeCells.reset();
var arr = [];
arr.push(new Common.UI.DataViewModel({
id : ++index,
selected : false,
allowSelected : true,
value : this.textSelectAll,
groupid : '0',
check : true,
throughIndex : 0
}));
this.throughIndexes.push(true);
this.config.asc_getValues().forEach(function (item) {
value = item.asc_getText();
isnumber = isNumeric(value);
arr.push(new Common.UI.DataViewModel({
id : ++index,
selected : false,
allowSelected : true,
cellvalue : value,
value : isnumber ? value : (value.length > 0 ? value: me.textEmptyItem),
intval : isnumber ? parseFloat(value) : undefined,
strval : !isnumber ? value : '',
groupid : '1',
check : item.asc_getVisible(),
throughIndex : throughIndex
}));
if (!item.asc_getVisible()) {
haveUnselectedCell = true;
}
me.throughIndexes.push(item.asc_getVisible()); if (isCustomFilter) {
var customFilter = filterObj.asc_getFilter(),
++throughIndex; customFilters = customFilter.asc_getCustomFilters(),
}); isAnd = (customFilter.asc_getAnd()),
cond1 = customFilters[0].asc_getOperator(),
me.cells.reset(arr); cond2 = ((customFilters.length>1) ? (customFilters[1].asc_getOperator() || 0) : 0),
items = (isTextFilter) ? this.miTextFilter.menu.items : this.miNumFilter.menu.items,
this.checkCellTrigerBlock = true; isCustomConditions = true;
this.cells.at(0).set('check', !haveUnselectedCell);
this.checkCellTrigerBlock = undefined; if (customFilters.length==1)
items.forEach(function(item){
this.btnSortDown.toggle(false, false); var checked = (item.options.type == Asc.c_oAscAutoFilterTypes.CustomFilters) && (item.value == cond1);
this.btnSortUp.toggle(false, false); item.setChecked(checked, true);
if (checked) isCustomConditions = false;
//TODO: установка всех значений для UI в отдельный метод });
else if (!isTextFilter && (cond1 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo ||
var sort = this.config.asc_getSortState(); cond1 == Asc.c_oAscCustomAutoFilter.isLessThanOrEqualTo && cond2 == Asc.c_oAscCustomAutoFilter.isGreaterThanOrEqualTo)){
if (sort) { items[7].setChecked(true, true); // between filter
if ('ascending' === sort) { isCustomConditions = false;
this.btnSortDown.toggle(true, false);
} else {
this.btnSortUp.toggle(true, false);
} }
if (isCustomConditions)
items[items.length-1].setChecked(true, true);
} else if (this.initialFilterType === Asc.c_oAscAutoFilterTypes.ColorFilter) {
var colorFilter = filterObj.asc_getFilter(),
filterColor = colorFilter.asc_getCColor();
if (filterColor)
filterColor = Common.Utils.ThemeColor.getHexColor(filterColor.get_r(), filterColor.get_g(), filterColor.get_b()).toLocaleUpperCase();
if ( colorFilter.asc_getCellColor()===null ) { // cell color
this.miFilterCellColor.setChecked(true, true);
this.mnuFilterColorCellsPicker.select((filterColor) ? filterColor : 'transparent', true);
} else if (colorFilter.asc_getCellColor()===false) { // font color
this.miFilterFontColor.setChecked(true, true);
this.mnuFilterColorFontPicker.select((filterColor) ? filterColor : '000000', true);
}
} else if (isDynamicFilter || isTop10) {
var dynType = (isDynamicFilter) ? filterObj.asc_getFilter().asc_getType() : null,
items = this.miNumFilter.menu.items;
items.forEach(function(item){
item.setChecked(isDynamicFilter && (item.options.type == Asc.c_oAscAutoFilterTypes.DynamicFilter) && (item.value == dynType) ||
isTop10 && (item.options.type == Asc.c_oAscAutoFilterTypes.Top10), true);
});
} }
this.chCustomFilter.setValue(isCustomFilter); this.miClear.setDisabled(this.initialFilterType === Asc.c_oAscAutoFilterTypes.None);
this.miReapply.setDisabled(this.initialFilterType === Asc.c_oAscAutoFilterTypes.None);
this.btnOk.setDisabled(isCustomFilter); this.btnOk.setDisabled(isCustomFilter);
this.cellsList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true});
this.config = undefined;
}, },
setupDataCells: function() { setupDataCells: function() {
...@@ -664,31 +1156,12 @@ define([ ...@@ -664,31 +1156,12 @@ define([
} }
var me = this, var me = this,
isnumber, isnumber, value,
value, index = 0, throughIndex = 2,
index = 0,
applyfilter = true, applyfilter = true,
throughIndex = 1; haveUnselectedCell = false,
arr = [], arrEx = [],
this.cells.forEach(function (item) { idxs = (me.filter) ? me.filteredIndexes : me.throughIndexes;
value = item.get('check');
if (_.isUndefined(value)) value = false;
me.throughIndexes[parseInt(item.get('throughIndex'))] = item.get('check');
});
var arr = [], arrEx = [];
if (!me.filter) {
arr.push(new Common.UI.DataViewModel({
id : ++index,
selected : false,
allowSelected : true,
value : this.textSelectAll,
groupid : '0',
check : me.throughIndexes[0],
throughIndex : 0
}));
}
this.configTo.asc_getValues().forEach(function (item) { this.configTo.asc_getValues().forEach(function (item) {
value = item.asc_getText(); value = item.asc_getText();
...@@ -699,7 +1172,9 @@ define([ ...@@ -699,7 +1172,9 @@ define([
if (null === value.match(me.filter)) { if (null === value.match(me.filter)) {
applyfilter = false; applyfilter = false;
} }
} idxs[throughIndex] = applyfilter;
} else if (idxs[throughIndex]==undefined)
idxs[throughIndex] = item.asc_getVisible();
if (applyfilter) { if (applyfilter) {
arr.push(new Common.UI.DataViewModel({ arr.push(new Common.UI.DataViewModel({
...@@ -711,9 +1186,12 @@ define([ ...@@ -711,9 +1186,12 @@ define([
intval : isnumber ? parseFloat(value) : undefined, intval : isnumber ? parseFloat(value) : undefined,
strval : !isnumber ? value : '', strval : !isnumber ? value : '',
groupid : '1', groupid : '1',
check : me.throughIndexes[throughIndex], check : idxs[throughIndex],
throughIndex : throughIndex throughIndex : throughIndex
})); }));
if (!idxs[throughIndex]) {
haveUnselectedCell = true;
}
} else { } else {
arrEx.push(new Common.UI.DataViewModel({ arrEx.push(new Common.UI.DataViewModel({
cellvalue : value cellvalue : value
...@@ -722,11 +1200,40 @@ define([ ...@@ -722,11 +1200,40 @@ define([
++throughIndex; ++throughIndex;
}); });
if (me.filter || idxs[0]==undefined)
idxs[0] = true;
if (!me.filter || arr.length>0)
arr.unshift(new Common.UI.DataViewModel({
id : ++index,
selected : false,
allowSelected : true,
value : (me.filter) ? this.textSelectAllResults : this.textSelectAll,
groupid : '0',
check : idxs[0],
throughIndex : 0
}));
if (me.filter && arr.length>1) {
if (idxs[1]==undefined)
idxs[1] = false;
arr.splice(1, 0, new Common.UI.DataViewModel({
id : ++index,
selected : false,
allowSelected : true,
value : this.textAddSelection,
groupid : '2',
check : idxs[1],
throughIndex : 1
}));
}
this.cells.reset(arr); this.cells.reset(arr);
this.filterExcludeCells.reset(arrEx); this.filterExcludeCells.reset(arrEx);
if (this.cells.length) { if (this.cells.length) {
this.chCustomFilter.setValue(this.configTo.asc_getFilterObj().asc_getType() === Asc.c_oAscAutoFilterTypes.CustomFilters); this.checkCellTrigerBlock = true;
this.cells.at(0).set('check', !haveUnselectedCell);
this.checkCellTrigerBlock = undefined;
} }
this.cellsList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true}); this.cellsList.scroller.update({minScrollbarLength : 40, alwaysVisibleY: true, suppressScrollX: true});
...@@ -736,13 +1243,15 @@ define([ ...@@ -736,13 +1243,15 @@ define([
var me = this, isValid= false; var me = this, isValid= false;
if (this.cells) { if (this.cells) {
this.cells.forEach(function(item){ if (this.filter && this.filteredIndexes[1])
if ('1' === item.get('groupid')) { isValid = true;
if (item.get('check')) { else
this.cells.forEach(function(item){
if ('1' == item.get('groupid') && item.get('check')) {
isValid = true; isValid = true;
return true;
} }
} });
});
} }
if (!isValid) { if (!isValid) {
...@@ -759,8 +1268,35 @@ define([ ...@@ -759,8 +1268,35 @@ define([
return isValid; return isValid;
}, },
save: function () { save: function () {
if (this.api && this.configTo && this.cells && this.filterExcludeCells) if (this.api && this.configTo && this.cells && this.filterExcludeCells) {
this.api.asc_applyAutoFilter('mainFilter', this.configTo); var arr = this.configTo.asc_getValues(),
isValid = false;
if (this.filter && this.filteredIndexes[1]) {
if (this.initialFilterType === Asc.c_oAscAutoFilterTypes.CustomFilters) {
arr.forEach(function(item, index) {
item.asc_setVisible(true);
});
}
this.cells.each(function(cell) {
if ('1' == cell.get('groupid')) {
arr[parseInt(cell.get('throughIndex'))-2].asc_setVisible(cell.get('check'));
}
});
arr.forEach(function(item, index) {
if (item.asc_getVisible()) {
isValid = true;
return true;
}
});
} else {
var idxs = (this.filter) ? this.filteredIndexes : this.throughIndexes;
arr.forEach(function(item, index) {
item.asc_setVisible(idxs[index+2]);
});
isValid = true;
}
if (isValid) this.api.asc_applyAutoFilter(this.configTo);
}
}, },
onPrimary: function() { onPrimary: function() {
...@@ -777,7 +1313,35 @@ define([ ...@@ -777,7 +1313,35 @@ define([
textWarning : 'Warning', textWarning : 'Warning',
cancelButtonText : 'Cancel', cancelButtonText : 'Cancel',
textEmptyItem : '{Blanks}', textEmptyItem : '{Blanks}',
txtEmpty : 'Enter cell\'s filter' txtEmpty : 'Enter cell\'s filter',
txtSortLow2High : 'Sort Lowest to Highest',
txtSortHigh2Low : 'Sort Highest to Lowest',
txtSortCellColor : 'Sort by cells color',
txtSortFontColor : 'Sort by font color',
txtNumFilter : 'Number filter',
txtTextFilter : 'Text filter',
txtFilterCellColor : 'Filter by cells color',
txtFilterFontColor : 'Filter by font color',
txtClear : 'Clear',
txtReapply : 'Reapply',
txtEquals : "Equals...",
txtNotEquals : "Does not equal...",
txtGreater : "Greater than...",
txtGreaterEquals : "Greater than or equal to...",
txtLess : "Less than...",
txtLessEquals : "Less than or equal to...",
txtBetween : 'Between...',
txtTop10 : 'Top 10',
txtAboveAve : 'Above average',
txtBelowAve : 'Below average',
txtBegins : "Begins with...",
txtNotBegins : "Does not begin with...",
txtEnds : "Ends with...",
txtNotEnds : "Does not end with...",
txtContains : "Contains...",
txtNotContains : "Does not contain...",
textSelectAllResults: 'Select All Search Results',
textAddSelection : 'Add current selection to filter'
}, SSE.Views.AutoFilterDialog || {})); }, SSE.Views.AutoFilterDialog || {}));
}); });
\ No newline at end of file
...@@ -230,15 +230,44 @@ define([ ...@@ -230,15 +230,44 @@ define([
items: [ items: [
{ {
caption : me.txtAscending, caption : me.txtAscending,
value : 'ascending' value : Asc.c_oAscSortOptions.Ascending
},{ },{
caption : me.txtDescending, caption : me.txtDescending,
value : 'descending' value : Asc.c_oAscSortOptions.Descending
},{
caption : me.txtSortCellColor,
value : Asc.c_oAscSortOptions.ByColorFill
},{
caption : me.txtSortFontColor,
value : Asc.c_oAscSortOptions.ByColorFont
} }
] ]
}) })
}); });
me.pmiFilterCells = new Common.UI.MenuItem({
caption : me.txtFilter,
menu : new Common.UI.Menu({
menuAlign : 'tl-tr',
items: [
{
caption : me.txtFilterValue,
value : 0
},{
caption : me.txtFilterCellColor,
value : 1
},{
caption : me.txtFilterFontColor,
value : 2
}
]
})
});
me.pmiReapply = new Common.UI.MenuItem({
caption : me.txtReapply
});
me.pmiInsFunction = new Common.UI.MenuItem({ me.pmiInsFunction = new Common.UI.MenuItem({
caption : me.txtFormula caption : me.txtFormula
}); });
...@@ -319,7 +348,10 @@ define([ ...@@ -319,7 +348,10 @@ define([
me.pmiDeleteCells, me.pmiDeleteCells,
me.pmiDeleteTable, me.pmiDeleteTable,
me.pmiClear, me.pmiClear,
{caption: '--'},
me.pmiSortCells, me.pmiSortCells,
me.pmiFilterCells,
me.pmiReapply,
{caption: '--'}, {caption: '--'},
me.pmiAddComment, me.pmiAddComment,
me.pmiCellMenuSeparator, me.pmiCellMenuSeparator,
...@@ -629,7 +661,13 @@ define([ ...@@ -629,7 +661,13 @@ define([
insertColumnRightText : 'Insert Column Right', insertColumnRightText : 'Insert Column Right',
deleteRowText : 'Delete Row', deleteRowText : 'Delete Row',
deleteColumnText : 'Delete Column', deleteColumnText : 'Delete Column',
deleteTableText : 'Delete Table' deleteTableText : 'Delete Table',
txtFilter: 'Filter',
txtFilterValue: 'Filter by Selected cell\'s value',
txtFilterCellColor: 'Filter by cell\'s color',
txtFilterFontColor: 'Filter by font color',
txtReapply: 'Reapply',
txtSortCellColor: 'Selected Cell Color on top',
txtSortFontColor: 'Selected Font Color on top'
}, SSE.Views.DocumentHolder || {})); }, SSE.Views.DocumentHolder || {}));
}); });
\ No newline at end of file
...@@ -1454,13 +1454,13 @@ define([ ...@@ -1454,13 +1454,13 @@ define([
caption : me.txtSortAZ, caption : me.txtSortAZ,
iconCls : 'mnu-sort-asc', iconCls : 'mnu-sort-asc',
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.coAuth, _set.ruleFilter], lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.coAuth, _set.ruleFilter],
value : 'ascending' value : Asc.c_oAscSortOptions.Ascending
}), }),
me.mnuitemSortZA = new Common.UI.MenuItem({ me.mnuitemSortZA = new Common.UI.MenuItem({
caption : me.txtSortZA, caption : me.txtSortZA,
iconCls : 'mnu-sort-desc', iconCls : 'mnu-sort-desc',
lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.coAuth, _set.ruleFilter], lock : [_set.selChart, _set.selChartText, _set.selShape, _set.selShapeText, _set.selImage, _set.coAuth, _set.ruleFilter],
value : 'descending' value : Asc.c_oAscSortOptions.Descending
}), }),
me.mnuitemAutoFilter = new Common.UI.MenuItem({ me.mnuitemAutoFilter = new Common.UI.MenuItem({
caption : me.txtFilter, caption : me.txtFilter,
......
...@@ -245,6 +245,34 @@ ...@@ -245,6 +245,34 @@
"SSE.Views.AutoFilterDialog.txtEmpty": "Enter cell filter", "SSE.Views.AutoFilterDialog.txtEmpty": "Enter cell filter",
"SSE.Views.AutoFilterDialog.txtTitle": "Filter", "SSE.Views.AutoFilterDialog.txtTitle": "Filter",
"SSE.Views.AutoFilterDialog.warnNoSelected": "You must choose at least one value", "SSE.Views.AutoFilterDialog.warnNoSelected": "You must choose at least one value",
"SSE.Views.AutoFilterDialog.txtSortLow2High": "Sort Lowest to Highest",
"SSE.Views.AutoFilterDialog.txtSortHigh2Low": "Sort Highest to Lowest",
"SSE.Views.AutoFilterDialog.txtSortCellColor": "Sort by cells color",
"SSE.Views.AutoFilterDialog.txtSortFontColor": "Sort by font color",
"SSE.Views.AutoFilterDialog.txtNumFilter": "Number filter",
"SSE.Views.AutoFilterDialog.txtTextFilter": "Text filter",
"SSE.Views.AutoFilterDialog.txtFilterCellColor": "Filter by cells color",
"SSE.Views.AutoFilterDialog.txtFilterFontColor": "Filter by font color",
"SSE.Views.AutoFilterDialog.txtClear": "Clear",
"SSE.Views.AutoFilterDialog.txtReapply": "Reapply",
"SSE.Views.AutoFilterDialog.txtEquals": "Equals...",
"SSE.Views.AutoFilterDialog.txtNotEquals": "Does not equal...",
"SSE.Views.AutoFilterDialog.txtGreater": "Greater than...",
"SSE.Views.AutoFilterDialog.txtGreaterEquals": "Greater than or equal to...",
"SSE.Views.AutoFilterDialog.txtLess": "Less than...",
"SSE.Views.AutoFilterDialog.txtLessEquals": "Less than or equal to...",
"SSE.Views.AutoFilterDialog.txtBetween": "Between...",
"SSE.Views.AutoFilterDialog.txtTop10": "Top 10",
"SSE.Views.AutoFilterDialog.txtAboveAve": "Above average",
"SSE.Views.AutoFilterDialog.txtBelowAve": "Below average",
"SSE.Views.AutoFilterDialog.txtBegins": "Begins with...",
"SSE.Views.AutoFilterDialog.txtNotBegins": "Does not begin with...",
"SSE.Views.AutoFilterDialog.txtEnds": "Ends with...",
"SSE.Views.AutoFilterDialog.txtNotEnds": "Does not end with...",
"SSE.Views.AutoFilterDialog.txtContains": "Contains...",
"SSE.Views.AutoFilterDialog.txtNotContains": "Does not contain...",
"SSE.Views.AutoFilterDialog.textSelectAllResults": "Select All Search Results",
"SSE.Views.AutoFilterDialog.textAddSelection": "Add current selection to filter",
"SSE.Views.CellEditor.textManager": "Name Manager", "SSE.Views.CellEditor.textManager": "Name Manager",
"SSE.Views.CellEditor.tipFormula": "Insert Function", "SSE.Views.CellEditor.tipFormula": "Insert Function",
"SSE.Views.CellRangeDialog.errorMaxRows": "ERROR! The maximum number of data series per chart is 255", "SSE.Views.CellRangeDialog.errorMaxRows": "ERROR! The maximum number of data series per chart is 255",
...@@ -458,6 +486,13 @@ ...@@ -458,6 +486,13 @@
"SSE.Views.DocumentHolder.deleteRowText": "Delete Row", "SSE.Views.DocumentHolder.deleteRowText": "Delete Row",
"SSE.Views.DocumentHolder.deleteColumnText": "Delete Column", "SSE.Views.DocumentHolder.deleteColumnText": "Delete Column",
"SSE.Views.DocumentHolder.deleteTableText": "Delete Table", "SSE.Views.DocumentHolder.deleteTableText": "Delete Table",
"SSE.Views.DocumentHolder.txtFilter": "Filter",
"SSE.Views.DocumentHolder.txtFilterValue": "Filter by Selected cell's value",
"SSE.Views.DocumentHolder.txtFilterCellColor": "Filter by cell's color",
"SSE.Views.DocumentHolder.txtFilterFontColor": "Filter by font color",
"SSE.Views.DocumentHolder.txtReapply": "Reapply",
"SSE.Views.DocumentHolder.txtSortCellColor": "Selected Cell Color on top",
"SSE.Views.DocumentHolder.txtSortFontColor": "Selected Font Color on top",
"SSE.Views.FileMenu.btnBackCaption": "Go to Documents", "SSE.Views.FileMenu.btnBackCaption": "Go to Documents",
"SSE.Views.FileMenu.btnCreateNewCaption": "Create New", "SSE.Views.FileMenu.btnCreateNewCaption": "Create New",
"SSE.Views.FileMenu.btnDownloadCaption": "Download as...", "SSE.Views.FileMenu.btnDownloadCaption": "Download as...",
...@@ -1087,5 +1122,13 @@ ...@@ -1087,5 +1122,13 @@
"SSE.Views.Toolbar.txtText": "Text", "SSE.Views.Toolbar.txtText": "Text",
"SSE.Views.Toolbar.txtTime": "Time", "SSE.Views.Toolbar.txtTime": "Time",
"SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells", "SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells",
"SSE.Views.Toolbar.txtYen": "¥ Yen" "SSE.Views.Toolbar.txtYen": "¥ Yen",
"SSE.Views.Top10FilterDialog.cancelButtonText": "Cancel",
"SSE.Views.Top10FilterDialog.okButtonText": "OK",
"SSE.Views.Top10FilterDialog.txtTitle": "Top 10 AutoFilter",
"SSE.Views.Top10FilterDialog.textType": "Show",
"SSE.Views.Top10FilterDialog.txtTop": "Top",
"SSE.Views.Top10FilterDialog.txtBottom": "Bottom",
"SSE.Views.Top10FilterDialog.txtItems": "Item",
"SSE.Views.Top10FilterDialog.txtPercent": "Percent"
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.combo-values { .combo-values {
width: 100%; width: 100%;
height: 265px; height: 162px;
overflow: hidden; overflow: hidden;
.list-item { .list-item {
...@@ -53,6 +53,16 @@ ...@@ -53,6 +53,16 @@
} }
} }
#menu-container-filters > .dropdown-menu {
position: inherit !important;
left: 0 !important;
top: 0 !important;
width: 100%;
display: inline-block;
.box-shadow(none);
border: none;
}
.btn-placeholder { .btn-placeholder {
// background-color: red; // background-color: red;
display: inline-block; display: inline-block;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment