mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
refactor: dynamic list to nestjs
This commit is contained in:
@@ -2,21 +2,22 @@ import { Injectable } from '@nestjs/common';
|
||||
import { ERRORS } from './constants';
|
||||
import { DynamicFilterViews } from './DynamicFilter';
|
||||
import { ServiceError } from '../Items/ServiceError';
|
||||
import { BaseModel } from '@/models/Model';
|
||||
import { DynamicListServiceAbstract } from './DynamicListServiceAbstract';
|
||||
import { IView } from '../Views/Views.types';
|
||||
import { MetableModel } from './types/DynamicList.types';
|
||||
|
||||
@Injectable()
|
||||
export class DynamicListCustomView extends DynamicListServiceAbstract {
|
||||
/**
|
||||
* Retreive custom view or throws error not found.
|
||||
* @param {number} tenantId
|
||||
* @param {number} viewId
|
||||
* @param {string} viewSlug - View slug.
|
||||
* @param {MetableModel} model - Metable model.
|
||||
* @return {Promise<IView>}
|
||||
*/
|
||||
private getCustomViewOrThrowError = async (
|
||||
private async getCustomViewOrThrowError(
|
||||
viewSlug: string,
|
||||
model: BaseModel,
|
||||
) => {
|
||||
model: MetableModel,
|
||||
): Promise<IView> {
|
||||
// Finds the default view by the given view slug.
|
||||
const defaultView = model.getDefaultViewBySlug(viewSlug);
|
||||
|
||||
@@ -24,12 +25,12 @@ export class DynamicListCustomView extends DynamicListServiceAbstract {
|
||||
throw new ServiceError(ERRORS.VIEW_NOT_FOUND);
|
||||
}
|
||||
return defaultView;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic list custom view.
|
||||
* @param {IModel} model
|
||||
* @param {number} customViewId
|
||||
* @param {DynamicFilter} dynamicFilter - Dynamic filter.
|
||||
* @param {string} customViewSlug - Custom view slug.
|
||||
* @returns {DynamicFilterRoleAbstractor}
|
||||
*/
|
||||
public dynamicListCustomView = async (
|
||||
|
||||
Reference in New Issue
Block a user