BIG-20: fix filtering manual journals by status column.

This commit is contained in:
a.bouhuolia
2021-09-12 10:22:15 +02:00
parent 9045cffb7f
commit b3a96ace71
3 changed files with 48 additions and 0 deletions

View File

@@ -187,6 +187,11 @@ body.hide-scrollbar .Pane2 {
.bp3-drawer {
box-shadow: 0 0 0;
background-color: #fbfbfb;
.dashboard__loading-indicator{
margin: auto;
}
}
// RTL Icons.

View File

@@ -43,6 +43,7 @@ export default {
{ key: 'draft', label: 'Draft' },
{ key: 'published', label: 'published' }
],
filterCustomQuery: StatusFieldFilterQuery,
sortCustomQuery: StatusFieldSortQuery,
},
'created_at': {
@@ -53,6 +54,16 @@ export default {
},
};
/**
* Status field sorting custom query.
*/
function StatusFieldSortQuery(query, role) {
return query.modify('sortByStatus', role.order);
}
/**
* Status field filter custom query.
*/
function StatusFieldFilterQuery(query, role) {
query.modify('filterByStatus', role.value);
}

View File

@@ -52,9 +52,41 @@ export default class ManualJournal extends mixin(TenantModel, [
*/
static get modifiers() {
return {
/**
* Sort by status query.
*/
sortByStatus(query, order) {
query.orderByRaw(`PUBLISHED_AT IS NULL ${order}`);
},
/**
* Filter by draft status.
*/
filterByDraft(query) {
query.whereNull('publishedAt');
},
/**
* Filter by published status.
*/
filterByPublished(query) {
query.whereNotNull('publishedAt');
},
/**
* Filter by the given status.
*/
filterByStatus(query, filterType) {
switch (filterType) {
case 'draft':
query.modify('filterByDraft');
break;
case 'published':
default:
query.modify('filterByPublished');
break;
}
},
};
}