Skip to content

Commit 8bcc288

Browse files
author
minjk-bl
committed
Change variable selector to SuggestInput
1 parent 15d06e4 commit 8bcc288

File tree

7 files changed

+152
-73
lines changed

7 files changed

+152
-73
lines changed

js/com/component/PopupComponent.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,16 @@ define([
502502
if (!packageButton) {
503503
$(this.wrapSelector('#popupPackage')).hide();
504504
}
505+
if (installButton || importButton || packageButton) {
506+
// resize height
507+
$(this.wrapSelector('.vp-popup-content')).css({
508+
'height': 'calc(100% - 30px)'
509+
});
510+
} else {
511+
$(this.wrapSelector('.vp-popup-content')).css({
512+
'height': '100%'
513+
});
514+
}
505515

506516
// codeview & dataview button hide/show
507517
if (!codeview) {
@@ -520,7 +530,7 @@ define([
520530
if(!footer) {
521531
$(this.wrapSelector('.vp-popup-footer')).hide();
522532
// set body wider
523-
$(this.wrapSelector('.vp-popup-content')).css({
533+
$(this.wrapSelector('.vp-popup-body')).css({
524534
'height': 'calc(100% - 30px)'
525535
})
526536
}

js/m_apps/Bind.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ define([
1818
'vp_base/js/com/com_util',
1919
'vp_base/js/com/com_String',
2020
'vp_base/js/com/component/PopupComponent',
21+
'vp_base/js/com/component/SuggestInput',
2122
'vp_base/js/com/component/MultiSelector'
22-
], function(bindHtml, bindCss, com_util, com_String, PopupComponent, MultiSelector) {
23+
], function(bindHtml, bindCss, com_util, com_String, PopupComponent, SuggestInput, MultiSelector) {
2324

2425
/**
2526
* Bind
@@ -382,19 +383,31 @@ define([
382383
* @param {string} defaultValue previous value
383384
*/
384385
renderVariableList(id, varList, defaultValue='') {
385-
var tag = new com_String();
386-
tag.appendFormatLine('<select id="{0}">', id);
387-
varList.forEach(vObj => {
388-
// varName, varType
389-
var label = vObj.varName;
390-
tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
391-
, vObj.varName, vObj.varType
392-
, defaultValue == vObj.varName?'selected':''
393-
, label);
394-
});
395-
tag.appendLine('</select>'); // VP_VS_VARIABLES
386+
// var tag = new com_String();
387+
// tag.appendFormatLine('<select id="{0}">', id);
388+
// varList.forEach(vObj => {
389+
// // varName, varType
390+
// var label = vObj.varName;
391+
// tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
392+
// , vObj.varName, vObj.varType
393+
// , defaultValue == vObj.varName?'selected':''
394+
// , label);
395+
// });
396+
// tag.appendLine('</select>'); // VP_VS_VARIABLES
397+
// $(this.wrapSelector('#' + id)).replaceWith(function() {
398+
// return tag.toString();
399+
// });
400+
let mappedList = varList.map(obj => { return { label: obj.varName, value: obj.varName, dtype: obj.varType } });
401+
402+
var variableInput = new SuggestInput();
403+
variableInput.setComponentID(id);
404+
variableInput.addClass('vp-state');
405+
variableInput.setPlaceholder('Select variable');
406+
variableInput.setSuggestList(function () { return mappedList; });
407+
variableInput.setNormalFilter(true);
408+
variableInput.setValue(defaultValue);
396409
$(this.wrapSelector('#' + id)).replaceWith(function() {
397-
return tag.toString();
410+
return variableInput.toTagString();
398411
});
399412
}
400413

js/m_apps/Frame.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -499,19 +499,21 @@ define([
499499
}
500500

501501
renderVariableList(varList, defaultValue='') {
502-
var tag = new com_String();
503-
tag.appendFormatLine('<select id="{0}">', 'vp_feVariable');
504-
varList.forEach(vObj => {
505-
// varName, varType
506-
var label = vObj.varName;
507-
tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
508-
, vObj.varName, vObj.varType
509-
, defaultValue == vObj.varName?'selected':''
510-
, label);
502+
let mappedList = varList.map(obj => { return { label: obj.varName, value: obj.varName, dtype: obj.varType } });
503+
504+
var variableInput = new SuggestInput();
505+
variableInput.setComponentID('vp_feVariable');
506+
variableInput.addClass('vp-state');
507+
variableInput.setPlaceholder('Select variable');
508+
variableInput.setSuggestList(function () { return mappedList; });
509+
variableInput.setSelectEvent(function (value) {
510+
$(this.wrapSelector()).val(value);
511+
$(this.wrapSelector()).trigger('change');
511512
});
512-
tag.appendLine('</select>'); // VP_VS_VARIABLES
513+
variableInput.setNormalFilter(true);
514+
variableInput.setValue(defaultValue);
513515
$(this.wrapSelector('#vp_feVariable')).replaceWith(function() {
514-
return tag.toString();
516+
return variableInput.toTagString();
515517
});
516518
}
517519

js/m_apps/Groupby.js

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ define([
1818
'vp_base/js/com/com_String',
1919
'vp_base/js/com/com_util',
2020
'vp_base/js/com/component/PopupComponent',
21+
'vp_base/js/com/component/SuggestInput',
2122
'vp_base/js/com/component/MultiSelector'
22-
], function(gbHtml, gbCss, com_String, com_util, PopupComponent, MultiSelector) {
23+
], function(gbHtml, gbCss, com_String, com_util, PopupComponent, SuggestInput, MultiSelector) {
2324

2425
/**
2526
* Groupby
@@ -374,18 +375,29 @@ define([
374375
* @param {string} defaultValue previous value
375376
*/
376377
templateForVariableList(varList, defaultValue='') {
377-
var tag = new com_String();
378-
tag.appendFormatLine('<select id="{0}">', 'vp_gbVariable');
379-
varList.forEach(vObj => {
380-
// varName, varType
381-
var label = vObj.varName;
382-
tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
383-
, vObj.varName, vObj.varType
384-
, defaultValue == vObj.varName?'selected':''
385-
, label);
386-
});
387-
tag.appendLine('</select>'); // VP_VS_VARIABLES
388-
return tag.toString();
378+
// var tag = new com_String();
379+
// tag.appendFormatLine('<select id="{0}">', 'vp_gbVariable');
380+
// varList.forEach(vObj => {
381+
// // varName, varType
382+
// var label = vObj.varName;
383+
// tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
384+
// , vObj.varName, vObj.varType
385+
// , defaultValue == vObj.varName?'selected':''
386+
// , label);
387+
// });
388+
// tag.appendLine('</select>'); // VP_VS_VARIABLES
389+
// return tag.toString();
390+
let mappedList = varList.map(obj => { return { label: obj.varName, value: obj.varName, dtype: obj.varType } });
391+
392+
var variableInput = new SuggestInput();
393+
variableInput.setComponentID('vp_gbVariable');
394+
variableInput.addClass('vp-state');
395+
variableInput.setPlaceholder('Select variable');
396+
variableInput.setSuggestList(function () { return mappedList; });
397+
variableInput.setNormalFilter(true);
398+
variableInput.setValue(defaultValue);
399+
400+
return variableInput.toTagString();
389401
}
390402

391403
/**

js/m_apps/Profiling.js

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ define([
1818
'vp_base/js/com/com_String',
1919
'vp_base/js/com/com_interface',
2020
'vp_base/js/com/component/PopupComponent',
21+
'vp_base/js/com/component/SuggestInput',
2122
'vp_base/js/com/component/FileNavigation'
22-
], function(proHTML, proCss, com_String, com_interface, PopupComponent, FileNavigation) {
23+
], function(proHTML, proCss, com_String, com_interface, PopupComponent, SuggestInput, FileNavigation) {
2324

2425
const PROFILE_TYPE = {
2526
NONE: -1,
@@ -44,7 +45,7 @@ define([
4445
this.config.codeview = false;
4546
this.config.dataview = false;
4647
this.config.runButton = false;
47-
this.config.size = { width: 500, height: 430 };
48+
this.config.size = { width: 500, height: 500 };
4849

4950
this.selectedReport = '';
5051
}
@@ -167,7 +168,7 @@ define([
167168
// render variable list
168169
// replace
169170
$(that.wrapSelector('#vp_pfVariable')).replaceWith(function() {
170-
return that.renderVariableList(varList);
171+
return that.templateForVariableList(varList);
171172
});
172173
$(that.wrapSelector('#vp_pfVariable')).trigger('change');
173174
} catch (ex) {
@@ -176,20 +177,35 @@ define([
176177
});
177178
}
178179

179-
renderVariableList(varList) {
180-
var tag = new com_String();
180+
templateForVariableList(varList) {
181181
var beforeValue = $(this.wrapSelector('#vp_pfVariable')).val();
182-
tag.appendFormatLine('<select id="{0}" class="vp-select vp-pf-select">', 'vp_pfVariable');
183-
varList.forEach(vObj => {
184-
// varName, varType
185-
var label = vObj.varName;
186-
tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
187-
, vObj.varName, vObj.varType
188-
, beforeValue == vObj.varName?'selected':''
189-
, label);
190-
});
191-
tag.appendLine('</select>'); // VP_VS_VARIABLES
192-
return tag.toString();
182+
if (beforeValue == null) {
183+
beforeValue = '';
184+
}
185+
// var tag = new com_String();
186+
// tag.appendFormatLine('<select id="{0}" class="vp-select vp-pf-select">', 'vp_pfVariable');
187+
// varList.forEach(vObj => {
188+
// // varName, varType
189+
// var label = vObj.varName;
190+
// tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
191+
// , vObj.varName, vObj.varType
192+
// , beforeValue == vObj.varName?'selected':''
193+
// , label);
194+
// });
195+
// tag.appendLine('</select>'); // VP_VS_VARIABLES
196+
// return tag.toString();
197+
198+
let mappedList = varList.map(obj => { return { label: obj.varName, value: obj.varName, dtype: obj.varType } });
199+
200+
var variableInput = new SuggestInput();
201+
variableInput.setComponentID('vp_pfVariable');
202+
variableInput.addClass('vp-pf-select');
203+
variableInput.setPlaceholder('Select variable');
204+
variableInput.setSuggestList(function () { return mappedList; });
205+
variableInput.setNormalFilter(true);
206+
variableInput.setValue(beforeValue);
207+
208+
return variableInput.toTagString();
193209
}
194210

195211
/**

js/m_apps/Reshape.js

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ define([
1818
'vp_base/js/com/com_String',
1919
'vp_base/js/com/com_util',
2020
'vp_base/js/com/component/PopupComponent',
21+
'vp_base/js/com/component/SuggestInput',
2122
'vp_base/js/com/component/MultiSelector'
22-
], function(reshapeHtml, reshapeCss, com_String, com_util, PopupComponent, MultiSelector) {
23+
], function(reshapeHtml, reshapeCss, com_String, com_util, PopupComponent, SuggestInput, MultiSelector) {
2324

2425
/**
2526
* Reshape
@@ -310,19 +311,31 @@ define([
310311
* @param {string} defaultValue previous value
311312
*/
312313
renderVariableList(id, varList, defaultValue='') {
313-
var tag = new com_String();
314-
tag.appendFormatLine('<select id="{0}">', id);
315-
varList.forEach(vObj => {
316-
// varName, varType
317-
var label = vObj.varName;
318-
tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
319-
, vObj.varName, vObj.varType
320-
, defaultValue == vObj.varName?'selected':''
321-
, label);
322-
});
323-
tag.appendLine('</select>'); // VP_VS_VARIABLES
314+
// var tag = new com_String();
315+
// tag.appendFormatLine('<select id="{0}">', id);
316+
// varList.forEach(vObj => {
317+
// // varName, varType
318+
// var label = vObj.varName;
319+
// tag.appendFormatLine('<option value="{0}" data-type="{1}" {2}>{3}</option>'
320+
// , vObj.varName, vObj.varType
321+
// , defaultValue == vObj.varName?'selected':''
322+
// , label);
323+
// });
324+
// tag.appendLine('</select>'); // VP_VS_VARIABLES
325+
// $(this.wrapSelector('#' + id)).replaceWith(function() {
326+
// return tag.toString();
327+
// });
328+
let mappedList = varList.map(obj => { return { label: obj.varName, value: obj.varName, dtype: obj.varType } });
329+
330+
var variableInput = new SuggestInput();
331+
variableInput.setComponentID(id);
332+
variableInput.addClass('vp-state');
333+
variableInput.setPlaceholder('Select variable');
334+
variableInput.setSuggestList(function () { return mappedList; });
335+
variableInput.setNormalFilter(true);
336+
variableInput.setValue(defaultValue);
324337
$(this.wrapSelector('#' + id)).replaceWith(function() {
325-
return tag.toString();
338+
return variableInput.toTagString();
326339
});
327340
}
328341

js/m_apps/Subset.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,25 @@ define([
632632

633633
// 1. Target Variable
634634
var prevValue = $(that.wrapSelector('.' + VP_DS_PANDAS_OBJECT)).val();
635-
$(that.wrapSelector('.' + VP_DS_PANDAS_OBJECT_BOX)).replaceWith(function () {
636-
var pdVarSelect = new VarSelector(that.pdObjTypes, that.state.dataType, false, false);
637-
pdVarSelect.addClass(VP_DS_PANDAS_OBJECT);
638-
pdVarSelect.addBoxClass(VP_DS_PANDAS_OBJECT_BOX);
639-
pdVarSelect.setValue(prevValue);
640-
return pdVarSelect.render();
635+
// $(that.wrapSelector('.' + VP_DS_PANDAS_OBJECT_BOX)).replaceWith(function () {
636+
// var pdVarSelect = new VarSelector(that.pdObjTypes, that.state.dataType, false, false);
637+
// pdVarSelect.addClass(VP_DS_PANDAS_OBJECT);
638+
// pdVarSelect.addBoxClass(VP_DS_PANDAS_OBJECT_BOX);
639+
// pdVarSelect.setValue(prevValue);
640+
// return pdVarSelect.render();
641+
// });
642+
var variableInput = new SuggestInput();
643+
variableInput.addClass(VP_DS_PANDAS_OBJECT);
644+
variableInput.setPlaceholder('Select variable');
645+
variableInput.setSuggestList(function () { return varList; });
646+
variableInput.setSelectEvent(function (value) {
647+
$(this.wrapSelector()).val(value);
648+
$(this.wrapSelector()).trigger('change');
649+
});
650+
variableInput.setNormalFilter(true);
651+
variableInput.setValue(prevValue);
652+
$(that.wrapSelector('.' + VP_DS_PANDAS_OBJECT)).replaceWith(function() {
653+
return variableInput.toTagString();
641654
});
642655
if (!that.stateLoaded) {
643656
that.reloadSubsetData();

0 commit comments

Comments
 (0)