mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
BIG-20: fix filtering manual journals by status column.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user