Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions CCUI.DAPPI/src/app/app.config.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
import { provideServerRendering } from '@angular/platform-server';
import { provideServerRouting } from '@angular/ssr';
import { appConfig } from './app.config';
import { serverRoutes } from './app.routes.server';

/**
* Server-side rendering configuration for Angular 20+.
* Note: provideServerRouting was deprecated in Angular 20 and removed.
* Server routes configuration is now handled differently in Angular 20+.
*/
const serverConfig: ApplicationConfig = {
providers: [provideServerRendering(), provideServerRouting(serverRoutes)],
providers: [provideServerRendering()],
};

export const config = mergeApplicationConfig(appConfig, serverConfig);
124 changes: 81 additions & 43 deletions CCUI.DAPPI/src/app/state/collection/collection.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class CollectionEffects {
private store = inject(Store);
private snackBar = inject(MatSnackBar);
private enumsData: any = null;

loadCollectionTypes$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionActions.loadCollectionTypes),
Expand Down Expand Up @@ -109,6 +109,30 @@ export class CollectionEffects {
)
);

/**
* Clears the selected collection type when it's no longer valid.
* This effect triggers when collection types are reloaded (e.g., after deletion)
* and ensures the UI shows the empty state if the currently selected type
* doesn't exist in the new list of collection types.
*/
clearInvalidSelectedType$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionActions.loadCollectionTypesSuccess),
withLatestFrom(this.store.pipe(select(selectSelectedType))),
filter(
([action, selectedType]) =>
selectedType !== null &&
selectedType !== '' &&
!action.collectionTypes.includes(selectedType)
),
map(() =>
ContentActions.setContentType({
selectedType: '',
})
)
)
);

loadFields$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionActions.loadFields),
Expand All @@ -123,11 +147,11 @@ export class CollectionEffects {
const enumsRequest = this.enumsData
? of(this.enumsData)
: this.http.get<any>(enumsEndpoint).pipe(
map((data) => {
this.enumsData = data;
return data;
})
);
map((data) => {
this.enumsData = data;
return data;
})
);

return enumsRequest.pipe(
mergeMap((enumsData) => {
Expand All @@ -140,12 +164,12 @@ export class CollectionEffects {
isEnum: fieldType === FieldType.enum,
};
});

return CollectionActions.loadFieldsSuccess({
modelResponse: {
Fields: [...processedFields],
AllowedActions: res.AllowedActions
}
AllowedActions: res.AllowedActions,
},
});
}),
catchError((error) => {
Expand Down Expand Up @@ -202,7 +226,11 @@ export class CollectionEffects {
this.actions$.pipe(
ofType(CollectionActions.addCollectionType),
switchMap((action) => {
const payload = { modelName: action.collectionType, isAuditableEntity: action.isAuditableEntity , crudActions:action.crudActions };
const payload = {
modelName: action.collectionType,
isAuditableEntity: action.isAuditableEntity,
crudActions: action.crudActions,
};
return this.http.post(`${BASE_API_URL}models`, payload).pipe(
map(() =>
CollectionActions.addCollectionTypeSuccess({
Expand Down Expand Up @@ -286,16 +314,23 @@ export class CollectionEffects {
collectionHasRelatedProperties$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionActions.collectionHasRelatedProperties),
switchMap(action => {
return this.http.get<{ hasRelatedProperties: boolean }>(`${BASE_API_URL}models/hasRelatedProperties/${action.modelName}`).pipe(
map(res =>
CollectionActions.collectionHasRelatedPropertiesSuccess({ hasRelatedProperties : res.hasRelatedProperties})
),
catchError(error => {
return of(CollectionActions.collectionHasRelatedPropertiesFailure({ error: error.message }))
}
)
)
switchMap((action) => {
return this.http
.get<{
hasRelatedProperties: boolean;
}>(`${BASE_API_URL}models/hasRelatedProperties/${action.modelName}`)
.pipe(
map((res) =>
CollectionActions.collectionHasRelatedPropertiesSuccess({
hasRelatedProperties: res.hasRelatedProperties,
})
),
catchError((error) => {
return of(
CollectionActions.collectionHasRelatedPropertiesFailure({ error: error.message })
);
})
);
})
)
);
Expand All @@ -304,36 +339,39 @@ export class CollectionEffects {
this.actions$.pipe(
ofType(CollectionActions.configureActions),
switchMap((action) => {
const payload = {...action.request};
return this.http.put<{message:string}>(`${BASE_API_URL}models/configure-actions/${action.model}`, payload).pipe(
map((res) =>
CollectionActions.configureActionsSuccess({
message:res.message
const payload = { ...action.request };
return this.http
.put<{
message: string;
}>(`${BASE_API_URL}models/configure-actions/${action.model}`, payload)
.pipe(
map((res) =>
CollectionActions.configureActionsSuccess({
message: res.message,
})
),
catchError((error) => {
console.error('Error creating model:', error);
this.showErrorPopup(`Failed to configure actions: ${error.error}`);
return of(CollectionActions.configureActionsFailure({ error }));
})
),
catchError((error) => {
console.error('Error creating model:', error);
this.showErrorPopup(`Failed to configure actions: ${error.error}`);
return of(CollectionActions.configureActionsFailure({ error }));
})
);
);
})
)
);

deleteCollectionType$ = createEffect(() =>
this.actions$.pipe(
ofType(CollectionActions.deleteCollectionType),
switchMap(action => {
return this.http.delete<{ message: string }>(`${BASE_API_URL}models/${action.modelName}`).pipe(
map(res =>
CollectionActions.deleteCollectionTypeSuccess({ message: res.message })
),
catchError(error => {
return of(CollectionActions.deleteCollectionTypeFailure({ error: error.message }))
}
)
)
switchMap((action) => {
return this.http
.delete<{ message: string }>(`${BASE_API_URL}models/${action.modelName}`)
.pipe(
map((res) => CollectionActions.deleteCollectionTypeSuccess({ message: res.message })),
catchError((error) => {
return of(CollectionActions.deleteCollectionTypeFailure({ error: error.message }));
})
);
})
)
);
Expand Down Expand Up @@ -437,4 +475,4 @@ export class CollectionEffects {
panelClass: ['error-snackbar'],
});
}
}
}
Loading