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