Skip to content

Commit 71c0981

Browse files
author
minjk-bl
committed
Edit pandas option app
1 parent 503cd1f commit 71c0981

File tree

2 files changed

+86
-39
lines changed

2 files changed

+86
-39
lines changed
Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,58 @@
11
<body>
22
<div class="vp-grid-border-box vp-pandas-option-body vp-po-option">
3+
<label class="vp-bold">Display</label>
34
<div class="vp-grid-col-110">
4-
<label for="min_rows" class="">Min/Max rows</label>
5+
<label for="min_rows" class="">Min rows</label>
6+
<input type="number" id="min_rows" class="vp-po-option-item vp-input vp-state" placeholder="10 (min)">
7+
</div>
8+
<div>
9+
<label class="vp-orange-text vp-italic">NOTE:</label> <label class="vp-gray-text vp-italic">numbers of rows to show in a truncated view</label>
10+
</div>
11+
<div class="vp-grid-col-110">
12+
<label for="min_rows" class="">Max rows</label>
513
<div>
6-
<input type="number" id="min_rows" class="vp-input m vp-state" placeholder="10 (min)">
7-
<input type="number" id="max_rows" class="vp-input m vp-state" placeholder="60 (max)">
14+
<input type="number" id="max_rows" class="vp-po-option-item vp-input vp-state" placeholder="60 (max)">
15+
<label>
16+
<input type="checkbox" id="showAllRows" class="vp-po-option-item">
17+
<span title="Set option as None to show all rows">Show all rows</span>
18+
</label>
819
</div>
920
<label for="min_columns" class="">Max columns</label>
10-
<input type="number" id="max_columns" class="vp-input m vp-state" placeholder="0">
21+
<div>
22+
<input type="number" id="max_columns" class="vp-po-option-item vp-input vp-state" placeholder="0">
23+
<label>
24+
<input type="checkbox" id="showAllColumns" class="vp-po-option-item">
25+
<span title="Set option as None to show all columns">Show all columns</span>
26+
</label>
27+
</div>
1128
<label for="max_colwidth" class="">Max colwidth</label>
12-
<input type="number" id="max_colwidth" class="vp-input m vp-state" placeholder="50">
13-
</div>
14-
<hr style="margin: 5px 0;">
15-
<div class="vp-grid-col-110">
16-
<label for="precision" class="">Precision</label>
17-
<input type="number" class="vp-input vp-state" id="precision" placeholder="6">
18-
<label for="chop_threshold" class="">Chop threshold</label>
19-
<input type="number" class="vp-input vp-state" id="chop_threshold" placeholder="None">
29+
<input type="number" id="max_colwidth" class="vp-po-option-item vp-input vp-state" placeholder="50">
2030
<label for="expand_frame_repr" class="">Expand frame</label>
21-
<select id="expand_frame_repr" class="vp-select vp-state">
31+
<select id="expand_frame_repr" class="vp-po-option-item vp-select vp-state">
2232
<option value="">Select option...</option>
2333
<option value="True">True (default)</option>
2434
<option value="False">False</option>
2535
</select>
2636
</div>
2737
<hr style="margin: 5px 0;">
38+
<div class="vp-grid-col-110">
39+
<label for="precision" class="">Precision</label>
40+
<input type="number" class="vp-po-option-item vp-input vp-state" id="precision" placeholder="6">
41+
<label for="chop_threshold" class="">Chop threshold</label>
42+
<input type="number" class="vp-po-option-item vp-input vp-state" id="chop_threshold" placeholder="None">
43+
</div>
44+
<hr style="margin: 5px 0;">
2845
<label class="mt5">
29-
<input type="checkbox" id="setDefault">
30-
<span title="Set pandas options to default.">Reset option</span>
46+
<input type="checkbox" id="resetDisplay">
47+
<span title="Set pandas options to default.">Set default</span>
3148
</label>
3249
</div>
3350
<hr style="margin: 5px 0;">
3451
<div class="vp-grid-border-box vp-po-warning">
52+
<label class="vp-bold">Warnings</label>
3553
<div class="vp-grid-col-110">
36-
<label for="filter_warning" class="">Filter warning</label>
37-
<select id="filter_warning" class="vp-select vp-state">
54+
<label for="filter_warning" class="">Filter warnings</label>
55+
<select id="filter_warning" class="vp-po-warning-item vp-select vp-state">
3856
<option value="">Select option...</option>
3957
<option value="default">Default (default)</option>
4058
<option value="error">Error</option>
@@ -44,9 +62,10 @@
4462
<option value="once">Once</option>
4563
</select>
4664
</div>
65+
<hr style="margin: 5px 0;">
4766
<label class="mt5">
4867
<input type="checkbox" id="resetWarning">
49-
<span title="Reset warning option.">Reset warning</span>
68+
<span title="Reset warning option.">Set default</span>
5069
</label>
5170
</div>
5271
</body>

visualpython/js/m_apps/PandasOption.js

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ define([
3636
filter_warning: '',
3737
min_rows: '',
3838
max_rows: '',
39-
max_cols: '',
39+
max_columns: '',
4040
max_colwidth: '',
41+
expand_frame_repr: '',
4142
precision: '',
4243
chop_threshold: '',
43-
expand_frame_repr: '',
4444
...this.state
4545
}
4646
}
@@ -51,15 +51,35 @@ define([
5151
var that = this;
5252

5353
// setting popup - set default
54-
$(this.wrapSelector('#setDefault')).on('change', function() {
54+
$(this.wrapSelector('#resetDisplay')).on('change', function() {
5555
let checked = $(this).prop('checked');
5656

5757
if (checked) {
5858
// disable input
59-
$(that.wrapSelector('.vp-po-option input:not([type="checkbox"])')).prop('disabled', true);
59+
$(that.wrapSelector('.vp-po-option-item')).prop('disabled', true);
6060
} else {
6161
// enable input
62-
$(that.wrapSelector('.vp-po-option input:not([type="checkbox"])')).prop('disabled', false);
62+
$(that.wrapSelector('.vp-po-option-item')).prop('disabled', false);
63+
}
64+
});
65+
66+
// show all rows
67+
$(this.wrapSelector('#showAllRows')).on('change', function() {
68+
let checked = $(this).prop('checked');
69+
if (checked) {
70+
$(that.wrapSelector('#max_rows')).prop('disabled', true);
71+
} else {
72+
$(that.wrapSelector('#max_rows')).prop('disabled', false);
73+
}
74+
});
75+
76+
// show all columns
77+
$(this.wrapSelector('#showAllColumns')).on('change', function() {
78+
let checked = $(this).prop('checked');
79+
if (checked) {
80+
$(that.wrapSelector('#max_columns')).prop('disabled', true);
81+
} else {
82+
$(that.wrapSelector('#max_columns')).prop('disabled', false);
6383
}
6484
});
6585

@@ -69,10 +89,10 @@ define([
6989

7090
if (checked) {
7191
// disable input
72-
$(that.wrapSelector('.vp-po-warning input:not([type="checkbox"])')).prop('disabled', true);
92+
$(that.wrapSelector('.vp-po-warning-item')).prop('disabled', true);
7393
} else {
7494
// enable input
75-
$(that.wrapSelector('.vp-po-warning input:not([type="checkbox"])')).prop('disabled', false);
95+
$(that.wrapSelector('.vp-po-warning-item')).prop('disabled', false);
7696
}
7797
});
7898
}
@@ -93,26 +113,34 @@ define([
93113
let that = this;
94114
let code = [];
95115

96-
let setDefault = $(this.wrapSelector('#setDefault')).prop('checked');
116+
let resetDisplay = $(this.wrapSelector('#resetDisplay')).prop('checked');
97117
let resetWarning = $(this.wrapSelector('#resetWarning')).prop('checked');
98-
if (setDefault == true) {
99-
// Object.keys(this.state).forEach((key) => {
100-
// code.push(com_util.formatString("pd.reset_option('display.{0}')", key));
101-
// })
102-
code.push("pd.reset_option('^display')");
103-
} else if (resetWarning) {
118+
119+
// warning options
120+
if (resetWarning === true) {
104121
code.push("import warnings\nwarnings.resetwarnings()");
105122
} else{
123+
if (that.state['filter_warning'] && that.state['filter_warning'] != '') {
124+
code.push(com_util.formatString("import warnings\nwarnings.simplefilter(action='{0}', category=Warning)", that.state['filter_warning']));
125+
}
126+
}
127+
128+
// display options
129+
if (resetDisplay === true) {
130+
code.push("pd.reset_option('^display')");
131+
} else {
132+
let showAllRows = $(this.wrapSelector('#showAllRows')).prop('checked');
133+
let showAllCols = $(this.wrapSelector('#showAllColumns')).prop('checked');
106134
Object.keys(this.state).forEach((key) => {
107-
if (that.state[key] && that.state[key] != '') {
108-
if (key === 'filter_warning') {
109-
code.push(com_util.formatString("import warnings\nwarnings.simplefilter(action='{0}', category=Warning)", that.state[key]));
110-
} else {
111-
code.push(com_util.formatString("pd.set_option('display.{0}', {1})", key, that.state[key]));
112-
}
135+
if ((showAllRows === true && key === 'max_rows')
136+
|| (showAllCols === true && key === 'max_columns')) {
137+
code.push(com_util.formatString("pd.set_option('display.{0}', {1})", key, 'None'));
138+
} else if (key !== 'filter_warning' && that.state[key] && that.state[key] != '') {
139+
code.push(com_util.formatString("pd.set_option('display.{0}', {1})", key, that.state[key]));
113140
}
114-
})
141+
});
115142
}
143+
116144
return code.join('\n');
117145
}
118146

0 commit comments

Comments
 (0)