refactor: dynamic list to nestjs

This commit is contained in:
Ahmed Bouhuolia
2025-01-14 22:57:54 +02:00
parent 081fdebee0
commit e7e7a95aa1
81 changed files with 596 additions and 742 deletions

View File

@@ -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 (