mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix api global options.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { mixin } from 'objection';
|
||||
import BaseModel from '@/models/Model';
|
||||
import MetableCollection from '@/lib/Metable/MetableCollection';
|
||||
import definedOptions from '@/data/options';
|
||||
|
||||
export default class Option extends mixin(BaseModel, [mixin]) {
|
||||
/**
|
||||
@@ -18,6 +19,7 @@ export default class Option extends mixin(BaseModel, [mixin]) {
|
||||
return super.query(...args).runAfter((result) => {
|
||||
if (result instanceof MetableCollection) {
|
||||
result.setModel(Option);
|
||||
result.setExtraColumns(['group']);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
@@ -26,4 +28,17 @@ export default class Option extends mixin(BaseModel, [mixin]) {
|
||||
static get collection() {
|
||||
return MetableCollection;
|
||||
}
|
||||
|
||||
static validateDefined(options) {
|
||||
const notDefined = [];
|
||||
|
||||
options.forEach((option) => {
|
||||
if (!definedOptions[option.group]) {
|
||||
notDefined.push(option);
|
||||
} else if (!definedOptions[option.group].some((o) => o.key === option.key)) {
|
||||
notDefined.push(option);
|
||||
}
|
||||
});
|
||||
return notDefined;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user