-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SSE] Add show detail dialog for pivot table
- Loading branch information
1 parent
0a5fa2d
commit 710e7af
Showing
2 changed files
with
187 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
apps/spreadsheeteditor/main/app/view/PivotShowDetailDialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
/* | ||
* (c) Copyright Ascensio System SIA 2010-2023 | ||
* | ||
* 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 20A-6 Ernesta Birznieka-Upish | ||
* 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 | ||
* | ||
*/ | ||
/** | ||
* | ||
* PivotShowDetailDialog.js | ||
* | ||
* Created by Alexey.Koshelev on 13.08.23 | ||
* Copyright (c) 2023 Ascensio System SIA. All rights reserved. | ||
* | ||
*/ | ||
|
||
define([ | ||
'common/main/lib/view/AdvancedSettingsWindow', | ||
'common/main/lib/component/ListView' | ||
], function () { | ||
'use strict'; | ||
|
||
SSE.Views = SSE.Views || {}; | ||
|
||
SSE.Views.PivotShowDetailDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ | ||
options: { | ||
alias: 'PivotShowDetailDialog', | ||
contentWidth: 300, | ||
height: 282 | ||
}, | ||
|
||
initialize: function (options) { | ||
var me = this; | ||
|
||
_.extend(this.options, { | ||
title: this.txtTitle, | ||
template: [ | ||
'<div class="box" style="height:' + (me.options.height - 85) + 'px;">', | ||
'<div class="content-panel" style="padding: 0;"><div class="inner-content">', | ||
'<div class="settings-panel active">', | ||
'<table cols="1" style="width: 100%;">', | ||
'<tr>', | ||
'<td class="padding-small">', | ||
'<label class="input-label">', me.textDescription,'</label>', | ||
'<div id="pivot-show-detail-list" class="range-tableview" style="width:100%; height: 165px;"></div>', | ||
'</td>', | ||
'</tr>', | ||
'</table>', | ||
'</div></div>', | ||
'</div>', | ||
'</div>' | ||
].join('') | ||
}, options); | ||
|
||
this.handler = options.handler; | ||
this.items = options.items || []; | ||
|
||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); | ||
}, | ||
render: function () { | ||
Common.Views.AdvancedSettingsWindow.prototype.render.call(this); | ||
|
||
this.rangeList = new Common.UI.ListView({ | ||
el: $('#pivot-show-detail-list', this.$window), | ||
store: new Common.UI.DataViewStore(), | ||
simpleAddMode: true, | ||
cls: 'dbl-clickable', | ||
itemTemplate: _.template([ | ||
'<div style="pointer-events:none;">', | ||
'<div id="<%= id %>" class="list-item" style="width: 100%;display:inline-block;">', | ||
'<div class="padding-right-5" style="width:186px;"><%= Common.Utils.String.htmlEncode(name) %></div>', | ||
'</div>', | ||
'</div>' | ||
].join('')) | ||
}); | ||
this.rangeList.on('item:dblclick', _.bind(this.onDblClickFunction, this)); | ||
this.rangeList.on('entervalue', _.bind(this.onPrimary, this)); | ||
|
||
this.afterRender(); | ||
}, | ||
|
||
afterRender: function() { | ||
this._setDefaults(); | ||
}, | ||
|
||
_setDefaults: function () { | ||
if(this.items) { | ||
var me = this; | ||
this.rangeList.store.reset(this.items); | ||
if (this.rangeList.store.length>0) | ||
this.rangeList.selectByIndex(0); | ||
this.rangeList.scroller.update({alwaysVisibleY: true}); | ||
_.delay(function () { | ||
me.rangeList.focus(); | ||
}, 100, this); | ||
} | ||
}, | ||
|
||
getSettings: function() { | ||
var rec = this.rangeList.getSelectedRec(); | ||
return (rec) ? {index: rec.get('index'), name: rec.get('name')}: null; | ||
}, | ||
|
||
onPrimary: function() { | ||
this.handler && this.handler.call(this, 'ok', this.getSettings()); | ||
this.close(); | ||
return false; | ||
}, | ||
|
||
onDlgBtnClick: function(event) { | ||
var state = event.currentTarget.attributes['result'].value; | ||
this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); | ||
this.close(); | ||
}, | ||
|
||
onDblClickFunction: function () { | ||
this.handler && this.handler.call(this, 'ok', this.getSettings()); | ||
this.close(); | ||
}, | ||
|
||
txtTitle: 'Show Detail', | ||
textDescription: 'Choose the field containing the detail you want to show:' | ||
}, SSE.Views.PivotShowDetailDialog || {})); | ||
}); |