feat(tableOrder): save order in url
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
444bc36f31
commit
4df99a82e1
|
@ -1,7 +1,7 @@
|
|||
import selectors from '../../helpers/selectors.js';
|
||||
import getBrowser from '../../helpers/puppeteer';
|
||||
|
||||
describe('Item summary path', () => {
|
||||
fdescribe('Item summary path', () => {
|
||||
let browser;
|
||||
let page;
|
||||
beforeAll(async() => {
|
||||
|
|
|
@ -167,7 +167,7 @@ export default class Searchbar extends Component {
|
|||
|
||||
let keys = Object.keys(filter);
|
||||
keys.forEach(key => {
|
||||
if (key == 'search' || key == 'tableQ') return;
|
||||
if (key == 'search' || key == 'tableQ' || key == 'tableOrder') return;
|
||||
let value = filter[key];
|
||||
let chip;
|
||||
|
||||
|
@ -281,7 +281,6 @@ export default class Searchbar extends Component {
|
|||
this.model.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Object.keys(filter).length === 0) {
|
||||
this.filterSanitizer('search');
|
||||
if (this.model.userParams)
|
||||
|
@ -301,10 +300,12 @@ export default class Searchbar extends Component {
|
|||
params = this.fetchParams({$params: params});
|
||||
}
|
||||
|
||||
if (this.$params.q)
|
||||
if (this.$params.q) {
|
||||
Object.assign(params, JSON.parse(this.$params.q));
|
||||
|
||||
return this.model.addFilter(where ? {where} : null, params)
|
||||
return this.model.addFilter(where ? {where} : null, params)
|
||||
.then(() => this.model.data);
|
||||
}
|
||||
return this.model.applyFilter(where ? {where} : null, params)
|
||||
.then(() => this.model.data);
|
||||
}
|
||||
|
||||
|
@ -312,7 +313,9 @@ export default class Searchbar extends Component {
|
|||
const userFilter = this.model.userFilter;
|
||||
const userParams = this.model.userParams;
|
||||
const where = userFilter && userFilter.where;
|
||||
delete this.$params.q[field];
|
||||
|
||||
if (this.$params.q)
|
||||
delete this.$params.q[field];
|
||||
|
||||
if (this.exprBuilder) {
|
||||
const param = this.exprBuilder({
|
||||
|
|
|
@ -188,7 +188,12 @@ export default class SmartTable extends Component {
|
|||
}
|
||||
|
||||
defaultOrder() {
|
||||
const order = this.model.order;
|
||||
let stateOrder;
|
||||
if (this.$params.q)
|
||||
stateOrder = JSON.parse(this.$params.q).tableOrder;
|
||||
|
||||
const order = stateOrder ? stateOrder : this.model.order;
|
||||
|
||||
if (!order) return;
|
||||
|
||||
const orderFields = order.split(', ');
|
||||
|
@ -222,6 +227,9 @@ export default class SmartTable extends Component {
|
|||
this.setPriority(column.element, priority);
|
||||
}
|
||||
}
|
||||
|
||||
this.model.order = order;
|
||||
this.model.refresh();
|
||||
}
|
||||
|
||||
registerColumns() {
|
||||
|
@ -443,10 +451,12 @@ export default class SmartTable extends Component {
|
|||
addFilter(field, value) {
|
||||
if (value == '') value = null;
|
||||
|
||||
let filterState;
|
||||
let stateFilter = {tableQ: {}};
|
||||
if (this.$params.q) {
|
||||
filterState = JSON.parse(this.$params.q);
|
||||
delete filterState.tableQ[field];
|
||||
stateFilter = JSON.parse(this.$params.q);
|
||||
if (!stateFilter.tableQ)
|
||||
stateFilter.tableQ = {};
|
||||
delete stateFilter.tableQ[field];
|
||||
}
|
||||
|
||||
const whereParams = {[field]: value};
|
||||
|
@ -462,12 +472,9 @@ export default class SmartTable extends Component {
|
|||
|
||||
const searchProps = this.searchPropsSanitizer();
|
||||
|
||||
if (filterState.tableQ)
|
||||
Object.assign(searchProps, filterState.tableQ);
|
||||
Object.assign(stateFilter.tableQ, searchProps);
|
||||
|
||||
Object.assign(filterState.tableQ, searchProps);
|
||||
|
||||
const params = {q: JSON.stringify(filterState)};
|
||||
const params = {q: JSON.stringify(stateFilter)};
|
||||
|
||||
this.$state.go(this.$state.current.name, params, {location: 'replace'});
|
||||
this.model.refresh();
|
||||
|
@ -480,6 +487,17 @@ export default class SmartTable extends Component {
|
|||
if (order)
|
||||
this.model.order = order;
|
||||
|
||||
let stateFilter = {tableOrder: {}};
|
||||
if (this.$params.q) {
|
||||
stateFilter = JSON.parse(this.$params.q);
|
||||
if (!stateFilter.tableOrder)
|
||||
stateFilter.tableOrder = {};
|
||||
}
|
||||
|
||||
stateFilter.tableOrder = order;
|
||||
|
||||
const params = {q: JSON.stringify(stateFilter)};
|
||||
this.$state.go(this.$state.current.name, params, {location: 'replace'});
|
||||
this.model.refresh();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue