Skip to content

Commit 3c98b18

Browse files
author
minjk-bl
committed
Reshape fix
1 parent f95bd5a commit 3c98b18

File tree

2 files changed

+23
-16
lines changed

2 files changed

+23
-16
lines changed

src/common/component/vpMultiSelector.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ define([
5858
// configuration
5959
this.config = config;
6060

61-
var { mode, type, parent, selectedList=[], includeList=[] } = config;
61+
var { mode, type, parent, selectedList=[], includeList=[], excludeList=[] } = config;
6262
this.mode = mode;
6363
this.parent = parent;
6464
this.selectedList = selectedList;
6565
this.includeList = includeList;
66+
this.excludeList = excludeList;
6667

6768
this.dataList = [];
6869
this.pointer = { start: -1, end: -1 };
@@ -84,12 +85,13 @@ define([
8485
}
8586

8687
_executeCallback(dataList) {
87-
this.dataList = dataList;
8888
if (this.includeList && this.includeList.length > 0) {
89-
this.dataList = dataList.filter(data => this.includeList.includes(data.code));
90-
} else {
91-
this.dataList = dataList;
89+
dataList = dataList.filter(data => this.includeList.includes(data.code));
9290
}
91+
if (this.excludeList && this.excludeList.length > 0) {
92+
dataList = dataList.filter(data => !this.excludeList.includes(data.code));
93+
}
94+
this.dataList = dataList;
9395

9496
// load
9597
this.load();

src/common/vpReshape.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -354,29 +354,29 @@ define([
354354
/**
355355
* Render column selector using ColumnSelector module
356356
* @param {Array<string>} previousList previous selected columns
357-
* @param {Array<string>} includeList columns to include
357+
* @param {Array<string>} excludeList columns to exclude
358358
*/
359-
renderColumnSelector(targetVariable, previousList, includeList) {
359+
renderColumnSelector(targetVariable, previousList, excludeList) {
360360
this.popup.ColSelector = new vpMultiSelector(
361361
this._wrapSelector('.' + APP_POPUP_BODY),
362-
{ mode: 'columns', parent: targetVariable, selectedList: previousList, includeList: includeList }
362+
{ mode: 'columns', parent: targetVariable, selectedList: previousList, excludeList: excludeList }
363363
);
364364
}
365365

366366
/**
367367
* Open Inner popup page for column selection
368368
* @param {Object} targetSelector
369369
* @param {string} title
370-
* @param {Array<string>} includeList
370+
* @param {Array<string>} excludeList
371371
*/
372-
openInnerPopup(targetVariable, targetSelector, title='Select columns', includeList=[]) {
372+
openInnerPopup(targetVariable, targetSelector, title='Select columns', excludeList=[]) {
373373
this.popup.targetVariable = targetVariable;
374374
this.popup.targetSelector = targetSelector;
375375
var previousList = this.popup.targetSelector.data('list');
376376
if (previousList) {
377377
previousList = previousList.map(col => col.code)
378378
}
379-
this.renderColumnSelector(targetVariable, previousList, includeList);
379+
this.renderColumnSelector(targetVariable, previousList, excludeList);
380380

381381
// set title
382382
$(this._wrapSelector('.' + APP_POPUP_BOX + ' .' + APP_TITLE)).text(title);
@@ -508,7 +508,8 @@ define([
508508
// index select button event
509509
$(document).on('click', this._wrapSelector('#vp_rsIndexSelect'), function() {
510510
var targetVariable = [ that.state.variable ];
511-
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsIndex')), 'Select columns');
511+
var excludeList = [ ...that.state.pivot.columns, ...that.state.pivot.values ].map(obj => obj.code);
512+
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsIndex')), 'Select columns', excludeList);
512513
});
513514

514515
// columns change event
@@ -520,7 +521,8 @@ define([
520521
// columns select button event
521522
$(document).on('click', this._wrapSelector('#vp_rsColumnsSelect'), function() {
522523
var targetVariable = [ that.state.variable ];
523-
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsColumns')), 'Select columns');
524+
var excludeList = [ ...that.state.pivot.index, ...that.state.pivot.values ].map(obj => obj.code);
525+
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsColumns')), 'Select columns', excludeList);
524526
});
525527

526528
// values change event
@@ -532,7 +534,8 @@ define([
532534
// values select button event
533535
$(document).on('click', this._wrapSelector('#vp_rsValuesSelect'), function() {
534536
var targetVariable = [ that.state.variable ];
535-
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsValues')), 'Select columns');
537+
var excludeList = [ ...that.state.pivot.index, ...that.state.pivot.columns ].map(obj => obj.code);
538+
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsValues')), 'Select columns', excludeList);
536539
});
537540

538541
// id vars change event
@@ -544,7 +547,8 @@ define([
544547
// id vars select button event
545548
$(document).on('click', this._wrapSelector('#vp_rsIdVarsSelect'), function() {
546549
var targetVariable = [ that.state.variable ];
547-
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsIdVars')), 'Select columns');
550+
var excludeList = that.state.melt.valueVars.map(obj => obj.code);
551+
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsIdVars')), 'Select columns', excludeList);
548552
});
549553

550554
// value vars change event
@@ -556,7 +560,8 @@ define([
556560
// value vars select button event
557561
$(document).on('click', this._wrapSelector('#vp_rsValueVarsSelect'), function() {
558562
var targetVariable = [ that.state.variable ];
559-
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsValueVars')), 'Select columns');
563+
var excludeList = that.state.melt.idVars.map(obj => obj.code);
564+
that.openInnerPopup(targetVariable, $(that._wrapSelector('#vp_rsValueVars')), 'Select columns', excludeList);
560565
});
561566

562567
// allocateTo event

0 commit comments

Comments
 (0)