Skip to content

Commit 948edb6

Browse files
committed
Merge pull request #417 from plotly/sort-by
change sorting_settings to sort_by
1 parent e657202 commit 948edb6

File tree

11 files changed

+61
-58
lines changed

11 files changed

+61
-58
lines changed

packages/dash-table/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1818
[#397](https://github.com/plotly/dash-table/pull/397)
1919
- Rename `filtering_settings` to `filter`
2020

21+
[#412](https://github.com/plotly/dash-table/pull/412)
22+
- Rename `sorting_settings` to `sort_by`
23+
2124
## [3.6.0] - 2019-03-04
2225
### Fixed
2326
[#189](https://github.com/plotly/dash-table/issues/189)

packages/dash-table/src/dash-table/components/ControlledTable/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
537537
editable,
538538
filter,
539539
setProps,
540-
sorting_settings,
540+
sort_by,
541541
viewport
542542
} = this.props;
543543

@@ -552,7 +552,7 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
552552
columns,
553553
data,
554554
true,
555-
!sorting_settings.length || !filter.length
555+
!sort_by.length || !filter.length
556556
);
557557

558558
if (result) {

packages/dash-table/src/dash-table/components/HeaderFactory.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ export default class HeaderFactory {
3232
public createHeaders() {
3333
const props = this.props;
3434

35-
let {
35+
const {
3636
columns,
3737
merge_duplicate_headers,
3838
pagination_mode,
3939
row_deletable,
4040
row_selectable,
4141
setProps,
4242
sorting,
43-
sorting_settings,
43+
sort_by,
4444
sorting_type,
4545
style_cell,
4646
style_cell_conditional,
@@ -85,7 +85,7 @@ export default class HeaderFactory {
8585
labelsAndIndices,
8686
sorting,
8787
sorting_type,
88-
sorting_settings,
88+
sort_by,
8989
pagination_mode,
9090
setProps,
9191
props
@@ -99,4 +99,4 @@ export default class HeaderFactory {
9999

100100
return arrayMap(operations, headers, (o, h) => Array.prototype.concat(o, h));
101101
}
102-
}
102+
}

packages/dash-table/src/dash-table/components/Table/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class Table extends Component<PropsWithDefaultsAndDerived, Standa
7676
pagination_settings,
7777
selected_rows,
7878
sorting,
79-
sorting_settings,
79+
sort_by,
8080
sorting_treat_empty_string_as_none,
8181
uiCell,
8282
uiHeaders,
@@ -89,7 +89,7 @@ export default class Table extends Component<PropsWithDefaultsAndDerived, Standa
8989
filtering,
9090
filter,
9191
sorting,
92-
sorting_settings,
92+
sort_by,
9393
sorting_treat_empty_string_as_none
9494
);
9595

@@ -151,7 +151,7 @@ export default class Table extends Component<PropsWithDefaultsAndDerived, Standa
151151
pagination_mode,
152152
pagination_settings,
153153
sorting,
154-
sorting_settings,
154+
sort_by,
155155
viewport,
156156
viewport_selected_rows,
157157
virtual,
@@ -168,7 +168,7 @@ export default class Table extends Component<PropsWithDefaultsAndDerived, Standa
168168

169169
const invalidatedFilter = this.filterCache(filter);
170170
const invalidatedPagination = this.paginationCache(pagination_settings);
171-
const invalidatedSort = this.sortCache(sorting_settings);
171+
const invalidatedSort = this.sortCache(sort_by);
172172

173173
const invalidateSelection =
174174
(!invalidatedFilter.cached && !invalidatedFilter.first && filtering === 'be') ||
@@ -272,4 +272,4 @@ export default class Table extends Component<PropsWithDefaultsAndDerived, Standa
272272
private readonly structuredQueryCache = memoizeOneWithFlag(
273273
(query: string) => new QuerySyntaxTree(query).toStructure()
274274
);
275-
}
275+
}

packages/dash-table/src/dash-table/components/Table/props.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ interface IProps {
281281
selected_rows?: Indices;
282282
setProps?: SetProps;
283283
sorting?: Sorting;
284-
sorting_settings?: SortSettings;
284+
sort_by?: SortSettings;
285285
sorting_type?: SortingType;
286286
sorting_treat_empty_string_as_none?: boolean;
287287
style_as_list_view?: boolean;
@@ -322,7 +322,7 @@ interface IDefaultProps {
322322
selected_cells: SelectedCells;
323323
selected_rows: number[];
324324
sorting: Sorting;
325-
sorting_settings: SortSettings;
325+
sort_by: SortSettings;
326326
sorting_type: SortingType;
327327
sorting_treat_empty_string_as_none: boolean;
328328
style_as_list_view: boolean;

packages/dash-table/src/dash-table/dash/DataTable.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const defaultProps = {
4646
filtering_types: ['basic'],
4747
sorting: false,
4848
sorting_type: 'single',
49-
sorting_settings: [],
49+
sort_by: [],
5050
style_as_list_view: false,
5151

5252
derived_viewport_data: [],
@@ -831,7 +831,7 @@ export const propTypes = {
831831
* with the `fe` (or True) setting or via a callback in your
832832
* python "back-end" with the `be` setting.
833833
* Clicking on the sort arrows will update the
834-
* `sorting_settings` property.
834+
* `sort_by` property.
835835
*/
836836
sorting: PropTypes.oneOf(['fe', 'be', true, false]),
837837

@@ -848,7 +848,7 @@ export const propTypes = {
848848
sorting_type: PropTypes.oneOf(['single', 'multi']),
849849

850850
/**
851-
* `sorting_settings` describes the current state
851+
* `sort_by` describes the current state
852852
* of the sorting UI.
853853
* That is, if the user clicked on the sort arrow
854854
* of a column, then this property will be updated
@@ -858,7 +858,7 @@ export const propTypes = {
858858
* sorting parameters, in the order in which they were
859859
* clicked.
860860
*/
861-
sorting_settings: PropTypes.arrayOf(
861+
sort_by: PropTypes.arrayOf(
862862
// .exact
863863
PropTypes.shape({
864864
column_id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,

packages/dash-table/src/dash-table/derived/data/virtual.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const getter = (
1616
filtering: Filtering,
1717
filter: string,
1818
sorting: Sorting,
19-
sorting_settings: SortSettings = [],
19+
sort_by: SortSettings = [],
2020
sorting_treat_empty_string_as_none: boolean
2121
): IDerivedData => {
2222
const map = new Map<Datum, number>();
@@ -37,7 +37,7 @@ const getter = (
3737
undefined;
3838

3939
if (sorting === 'fe' || sorting === true) {
40-
data = sort(data, sorting_settings, isNully);
40+
data = sort(data, sort_by, isNully);
4141
}
4242

4343
// virtual_indices

packages/dash-table/src/dash-table/derived/header/content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function doSort(columnId: ColumnId, sortSettings: SortSettings, sortType: Sortin
4747
multiUpdateSettings;
4848

4949
setProps({
50-
sorting_settings: sortingStrategy(
50+
sort_by: sortingStrategy(
5151
sortSettings,
5252
{ column_id: columnId, direction }
5353
)

packages/dash-table/tests/cypress/dash/v_be_page.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464

6565
@app.callback(Output("table", "data"), [
6666
Input("table", "pagination_settings"),
67-
Input("table", "sorting_settings")
67+
Input("table", "sort_by")
6868
])
69-
def updateData(pagination_settings, sorting_settings):
69+
def updateData(pagination_settings, sort_by):
7070
print(pagination_settings)
7171

7272
current_page = pagination_settings["current_page"]
@@ -75,14 +75,14 @@ def updateData(pagination_settings, sorting_settings):
7575
start_index = current_page * page_size
7676
end_index = start_index + page_size
7777
print(str(start_index) + "," + str(end_index))
78-
print(sorting_settings)
78+
print(sort_by)
7979

80-
if (sorting_settings is None or len(sorting_settings) == 0):
80+
if (sort_by is None or len(sort_by) == 0):
8181
sorted_df = df.values
8282
else:
8383
sorted_df = df.sort_index(
84-
axis=sorting_settings[0]['column_id'],
85-
ascending=(sorting_settings[0]['direction'] == 'asc')
84+
axis=sort_by[0]['column_id'],
85+
ascending=(sort_by[0]['direction'] == 'asc')
8686
).values
8787

8888
return sorted_df[start_index:end_index]
@@ -109,4 +109,4 @@ def findModifiedValue(data, previous):
109109

110110

111111
if __name__ == "__main__":
112-
app.run_server(port=8081, debug=False)
112+
app.run_server(port=8081, debug=False)

packages/dash-table/tests/dash/app_dataframe_backend_paging.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def layout():
7777

7878
sorting='be',
7979
sorting_type='single',
80-
sorting_settings=[]
80+
sort_by=[]
8181
),
8282

8383
section_title('Backend Paging with Multi Column Sorting'),
@@ -104,7 +104,7 @@ def layout():
104104

105105
sorting='be',
106106
sorting_type='multi',
107-
sorting_settings=[]
107+
sort_by=[]
108108
),
109109

110110
section_title('Backend Paging with Filtering'),
@@ -162,7 +162,7 @@ def layout():
162162

163163
sorting='be',
164164
sorting_type='multi',
165-
sorting_settings=[]
165+
sort_by=[]
166166
),
167167

168168
section_title('Connecting Backend Paging with a Graph'),
@@ -192,7 +192,7 @@ def layout():
192192

193193
sorting='be',
194194
sorting_type='multi',
195-
sorting_settings=[]
195+
sort_by=[]
196196
),
197197
style={'height': 750, 'overflowY': 'scroll'},
198198
className='six columns'
@@ -221,13 +221,13 @@ def update_graph(pagination_settings):
221221
@app.callback(
222222
Output(IDS["table-sorting"], "data"),
223223
[Input(IDS["table-sorting"], "pagination_settings"),
224-
Input(IDS["table-sorting"], "sorting_settings")])
225-
def update_graph(pagination_settings, sorting_settings):
226-
print(sorting_settings)
227-
if len(sorting_settings):
224+
Input(IDS["table-sorting"], "sort_by")])
225+
def update_graph(pagination_settings, sort_by):
226+
print(sort_by)
227+
if len(sort_by):
228228
dff = df.sort_values(
229-
sorting_settings[0]['columnId'],
230-
ascending=sorting_settings[0]['direction'] == 'asc',
229+
sort_by[0]['columnId'],
230+
ascending=sort_by[0]['direction'] == 'asc',
231231
inplace=False
232232
)
233233
else:
@@ -244,15 +244,15 @@ def update_graph(pagination_settings, sorting_settings):
244244
@app.callback(
245245
Output(IDS["table-multi-sorting"], "data"),
246246
[Input(IDS["table-multi-sorting"], "pagination_settings"),
247-
Input(IDS["table-multi-sorting"], "sorting_settings")])
248-
def update_graph(pagination_settings, sorting_settings):
249-
print(sorting_settings)
250-
if len(sorting_settings):
247+
Input(IDS["table-multi-sorting"], "sort_by")])
248+
def update_graph(pagination_settings, sort_by):
249+
print(sort_by)
250+
if len(sort_by):
251251
dff = df.sort_values(
252-
[col['columnId'] for col in sorting_settings],
252+
[col['columnId'] for col in sort_by],
253253
ascending=[
254254
col['direction'] == 'asc'
255-
for col in sorting_settings
255+
for col in sort_by
256256
],
257257
inplace=False
258258
)
@@ -297,9 +297,9 @@ def update_graph(pagination_settings, filter):
297297
@app.callback(
298298
Output(IDS["table-sorting-filtering"], "data"),
299299
[Input(IDS["table-sorting-filtering"], "pagination_settings"),
300-
Input(IDS["table-sorting-filtering"], "sorting_settings"),
300+
Input(IDS["table-sorting-filtering"], "sort_by"),
301301
Input(IDS["table-sorting-filtering"], "filter")])
302-
def update_graph(pagination_settings, sorting_settings, filter):
302+
def update_graph(pagination_settings, sort_by, filter):
303303
filtering_expressions = filter.split(' && ')
304304
dff = df
305305
for filter in filtering_expressions:
@@ -316,12 +316,12 @@ def update_graph(pagination_settings, sorting_settings, filter):
316316
filter_value = float(filter.split(' < ')[1])
317317
dff = dff.loc[dff[col_name] < filter_value]
318318

319-
if len(sorting_settings):
319+
if len(sort_by):
320320
dff = dff.sort_values(
321-
[col['columnId'] for col in sorting_settings],
321+
[col['columnId'] for col in sort_by],
322322
ascending=[
323323
col['direction'] == 'asc'
324-
for col in sorting_settings
324+
for col in sort_by
325325
],
326326
inplace=False
327327
)
@@ -335,9 +335,9 @@ def update_graph(pagination_settings, sorting_settings, filter):
335335
@app.callback(
336336
Output(IDS["table-paging-with-graph"], "data"),
337337
[Input(IDS["table-paging-with-graph"], "pagination_settings"),
338-
Input(IDS["table-paging-with-graph"], "sorting_settings"),
338+
Input(IDS["table-paging-with-graph"], "sort_by"),
339339
Input(IDS["table-paging-with-graph"], "filter")])
340-
def update_table(pagination_settings, sorting_settings, filter):
340+
def update_table(pagination_settings, sort_by, filter):
341341
filtering_expressions = filter.split(' && ')
342342
dff = df
343343
for filter in filtering_expressions:
@@ -354,12 +354,12 @@ def update_table(pagination_settings, sorting_settings, filter):
354354
filter_value = float(filter.split(' < ')[1])
355355
dff = dff.loc[dff[col_name] < filter_value]
356356

357-
if len(sorting_settings):
357+
if len(sort_by):
358358
dff = dff.sort_values(
359-
[col['columnId'] for col in sorting_settings],
359+
[col['columnId'] for col in sort_by],
360360
ascending=[
361361
col['direction'] == 'asc'
362-
for col in sorting_settings
362+
for col in sort_by
363363
],
364364
inplace=False
365365
)

0 commit comments

Comments
 (0)