Skip to content

Commit f72a029

Browse files
committed
feat: enhance lifecycle history retrieval with optional reference ID population
- Introduced a new `populateRefId` option in the `getLifecycleHistory` method to conditionally include reference ID population in the response. - Updated the controller to parse the `populateRefId` query parameter and pass it to the service method. - Refactored the lifecycle history component to improve layout and user experience, including a new dialog for lifecycle event details.
1 parent 7b9325a commit f72a029

File tree

3 files changed

+304
-78
lines changed

3 files changed

+304
-78
lines changed

apps/api/src/management/lifecycle/lifecycle-crud.service.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { Lifecycle, LifecycleRefId } from './_schemas/lifecycle.schema'
66
import { loadCustomStates } from './_functions/load-custom-states.function'
77
import { AbstractLifecycleService } from './_abstracts/abstract.lifecycle.service'
88

9+
type LifecycleHistoryOptions = FilterOptions & {
10+
populateRefId?: boolean
11+
}
12+
913
/**
1014
* Service CRUD de gestion du cycle de vie des identités
1115
*
@@ -201,10 +205,11 @@ export class LifecycleCrudService extends AbstractLifecycleService {
201205
*/
202206
public async getLifecycleHistory(
203207
refId: Types.ObjectId,
204-
options?: FilterOptions,
208+
options?: LifecycleHistoryOptions,
205209
): Promise<[number, Query<Array<Lifecycle>, Lifecycle, any, Lifecycle>[]]> {
210+
const shouldPopulateRefId = options?.populateRefId !== false
206211
const result = await this.find<Lifecycle>({ refId }, null, {
207-
populate: LifecycleRefId,
212+
...(shouldPopulateRefId ? { populate: LifecycleRefId } : {}),
208213
sort: {
209214
...options?.sort,
210215
createdAt: -1,

apps/api/src/management/lifecycle/lifecycle.controller.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,13 @@ export class LifecycleController extends AbstractController {
9999
@Param('identityId', ObjectIdValidationPipe) identityId: Types.ObjectId,
100100
@Res() res: Response,
101101
@SearchFilterOptions() searchFilterOptions: FilterOptions,
102+
@Query('populateRefId') populateRefId?: string,
102103
): Promise<Response<Lifecycle[]>> {
103-
const [total, data] = await this._service.getLifecycleHistory(identityId, searchFilterOptions)
104+
const populateRefIdEnabled = /true|1|yes|on/i.test(populateRefId)
105+
const [total, data] = await this._service.getLifecycleHistory(identityId, {
106+
...searchFilterOptions,
107+
populateRefId: populateRefIdEnabled,
108+
})
104109

105110
return res.status(HttpStatus.OK).json({
106111
statusCode: HttpStatus.OK,

0 commit comments

Comments
 (0)