mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 18:26:00 +00:00
multiple sort criteria #235
This commit is contained in:
@@ -372,6 +372,22 @@ export abstract class GridDisplay {
|
|||||||
this.reload();
|
this.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addToSort(uniqueName, order) {
|
||||||
|
this.setConfig(cfg => ({
|
||||||
|
...cfg,
|
||||||
|
sort: [...(cfg.sort || []), { uniqueName, order }],
|
||||||
|
}));
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
clearSort() {
|
||||||
|
this.setConfig(cfg => ({
|
||||||
|
...cfg,
|
||||||
|
sort: [],
|
||||||
|
}));
|
||||||
|
this.reload();
|
||||||
|
}
|
||||||
|
|
||||||
setGrouping(uniqueName, groupFunc: GroupFunc) {
|
setGrouping(uniqueName, groupFunc: GroupFunc) {
|
||||||
this.setConfig(cfg => ({
|
this.setConfig(cfg => ({
|
||||||
...cfg,
|
...cfg,
|
||||||
@@ -408,6 +424,15 @@ export abstract class GridDisplay {
|
|||||||
return this.config.sort.find(x => x.uniqueName == uniqueName)?.order;
|
return this.config.sort.find(x => x.uniqueName == uniqueName)?.order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSortOrderIndex(uniqueName) {
|
||||||
|
if (this.config.sort.length <= 1) return -1;
|
||||||
|
return _.findIndex(this.config.sort, x => x.uniqueName == uniqueName);
|
||||||
|
}
|
||||||
|
|
||||||
|
isSortDefined() {
|
||||||
|
return (this.config.sort || []).length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
get filterCount() {
|
get filterCount() {
|
||||||
return _.compact(_.values(this.config.filters)).length;
|
return _.compact(_.values(this.config.filters)).length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,13 @@
|
|||||||
export let column;
|
export let column;
|
||||||
export let conid = undefined;
|
export let conid = undefined;
|
||||||
export let database = undefined;
|
export let database = undefined;
|
||||||
export let setSort;
|
export let setSort = undefined;
|
||||||
|
export let addToSort = undefined;
|
||||||
|
export let clearSort = undefined;
|
||||||
export let grouping = undefined;
|
export let grouping = undefined;
|
||||||
export let order = undefined;
|
export let order = undefined;
|
||||||
|
export let orderIndex = undefined;
|
||||||
|
export let isSortDefined = false;
|
||||||
export let allowDefineVirtualReferences = false;
|
export let allowDefineVirtualReferences = false;
|
||||||
export let setGrouping;
|
export let setGrouping;
|
||||||
|
|
||||||
@@ -44,6 +48,9 @@
|
|||||||
return [
|
return [
|
||||||
setSort && { onClick: () => setSort('ASC'), text: 'Sort ascending' },
|
setSort && { onClick: () => setSort('ASC'), text: 'Sort ascending' },
|
||||||
setSort && { onClick: () => setSort('DESC'), text: 'Sort descending' },
|
setSort && { onClick: () => setSort('DESC'), text: 'Sort descending' },
|
||||||
|
isSortDefined && addToSort && !order && { onClick: () => addToSort('ASC'), text: 'Add to sort - ascending' },
|
||||||
|
isSortDefined && addToSort && !order && { onClick: () => addToSort('DESC'), text: 'Add to sort - descending' },
|
||||||
|
order && clearSort && { onClick: () => clearSort(), text: 'Clear sort criteria' },
|
||||||
{ onClick: () => copyTextToClipboard(column.columnName), text: 'Copy column name' },
|
{ onClick: () => copyTextToClipboard(column.columnName), text: 'Copy column name' },
|
||||||
|
|
||||||
column.foreignKey && [{ divider: true }, { onClick: openReferencedTable, text: column.foreignKey.refTableName }],
|
column.foreignKey && [{ divider: true }, { onClick: openReferencedTable, text: column.foreignKey.refTableName }],
|
||||||
@@ -90,11 +97,17 @@
|
|||||||
{#if order == 'ASC'}
|
{#if order == 'ASC'}
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<FontIcon icon="img sort-asc" />
|
<FontIcon icon="img sort-asc" />
|
||||||
|
{#if orderIndex >= 0}
|
||||||
|
<span class="color-icon-green order-index">{orderIndex + 1}</span>
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#if order == 'DESC'}
|
{#if order == 'DESC'}
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<FontIcon icon="img sort-desc" />
|
<FontIcon icon="img sort-desc" />
|
||||||
|
{#if orderIndex >= 0}
|
||||||
|
<span class="color-icon-green order-index">{orderIndex + 1}</span>
|
||||||
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
<DropDownButton menu={getMenu} narrow />
|
<DropDownButton menu={getMenu} narrow />
|
||||||
@@ -106,6 +119,13 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: nowrap;
|
flex-wrap: nowrap;
|
||||||
}
|
}
|
||||||
|
.order-index {
|
||||||
|
font-size: 10pt;
|
||||||
|
margin-left: -3px;
|
||||||
|
margin-right: 2px;
|
||||||
|
top: -1px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
.label {
|
.label {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 10px;
|
min-width: 10px;
|
||||||
|
|||||||
@@ -1526,7 +1526,11 @@
|
|||||||
{conid}
|
{conid}
|
||||||
{database}
|
{database}
|
||||||
setSort={display.sortable ? order => display.setSort(col.uniqueName, order) : null}
|
setSort={display.sortable ? order => display.setSort(col.uniqueName, order) : null}
|
||||||
order={display.getSortOrder(col.uniqueName)}
|
addToSort={display.sortable ? order => display.addToSort(col.uniqueName, order) : null}
|
||||||
|
order={display.sortable ? display.getSortOrder(col.uniqueName) : null}
|
||||||
|
orderIndex={display.sortable ? display.getSortOrderIndex(col.uniqueName) : -1}
|
||||||
|
isSortDefined={display.sortable ? display.isSortDefined() : false}
|
||||||
|
clearSort={display.sortable ? () => display.clearSort() : null}
|
||||||
on:resizeSplitter={e => {
|
on:resizeSplitter={e => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
display.resizeColumn(col.uniqueName, col.width, e.detail);
|
display.resizeColumn(col.uniqueName, col.width, e.detail);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ const windowsAuthTypes = [
|
|||||||
disabledFields: ['port'],
|
disabledFields: ['port'],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: 'NodeJs portable driver (tedious)',
|
title: 'NodeJs portable driver (tedious) - recomended',
|
||||||
name: 'tedious',
|
name: 'tedious',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user