WIP: dynamic list filtering.

This commit is contained in:
a.bouhuolia
2021-07-31 17:07:37 +02:00
parent 9186076676
commit 3546b6b7ae
34 changed files with 569 additions and 314 deletions

View File

@@ -1,8 +1,9 @@
import path from 'path';
import { Model } from 'objection';
import { Model, mixin } from 'objection';
import TenantModel from 'models/TenantModel';
import ModelSetting from './ModelSetting';
import ItemCategorySettings from './ItemCategory.Settings';
export default class ItemCategory extends TenantModel {
export default class ItemCategory extends mixin(TenantModel, [ModelSetting]) {
/**
* Table name.
*/
@@ -10,10 +11,6 @@ export default class ItemCategory extends TenantModel {
return 'items_categories';
}
static get resourceable() {
return true;
}
/**
* Timestamps columns.
*/
@@ -42,7 +39,24 @@ export default class ItemCategory extends TenantModel {
};
}
static sortCountQuery(query, role) {
query.orderBy('count', role.order);
}
/**
* Model modifiers.
*/
static get modifiers() {
return {
/**
* Inactive/Active mode.
*/
sortByCount(query, order = 'asc') {
query.orderBy('count', order);
},
};
}
/**
* Model meta.
*/
static get meta() {
return ItemCategorySettings;
}
}