WIP Custom fields feature.

This commit is contained in:
Ahmed Bouhuolia
2020-01-26 21:14:21 +02:00
parent 77c67cc4cb
commit a97b527e8c
10 changed files with 326 additions and 75 deletions

View File

@@ -1,7 +1,6 @@
import { Model } from 'objection';
export default class ModelBase extends Model {
static get collection() {
return Array;
}

View File

@@ -10,6 +10,19 @@ export default class Option extends mixin(BaseModel, [mixin]) {
return 'options';
}
/**
* Override the model query.
* @param {...any} args -
*/
static query(...args) {
return super.query(...args).runAfter((result) => {
if (result instanceof MetableCollection) {
result.setModel(Option);
}
return result;
});
}
static get collection() {
return MetableCollection;
}

View File

@@ -1,7 +1,7 @@
import { Model } from 'objection';
import path from 'path';
import BaseModel from '@/models/Model';
import MetableCollection from '@/lib/Metable/MetableCollection';
import ResourceFieldMetadataCollection from '@/collection/ResourceFieldMetadataCollection';
export default class ResourceFieldMetadata extends BaseModel {
/**
@@ -15,7 +15,7 @@ export default class ResourceFieldMetadata extends BaseModel {
* Override the resource field metadata collection.
*/
static get collection() {
return MetableCollection;
return ResourceFieldMetadataCollection;
}
/**