cloud-ide-core 2.0.79 → 2.0.84
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/cloud-ide-core-workflow-registry-list.component-B453QJwg.mjs +323 -0
- package/fesm2022/cloud-ide-core-workflow-registry-list.component-B453QJwg.mjs.map +1 -0
- package/fesm2022/cloud-ide-core.mjs +157 -9
- package/fesm2022/cloud-ide-core.mjs.map +1 -1
- package/index.d.ts +8 -2
- package/package.json +1 -1
|
@@ -257,6 +257,16 @@ const coreRoutes = [
|
|
|
257
257
|
data: {
|
|
258
258
|
sypg_page_code: "core_user_role_view"
|
|
259
259
|
}
|
|
260
|
+
},
|
|
261
|
+
// Workflow Management Routes
|
|
262
|
+
{
|
|
263
|
+
path: 'workflow-registry',
|
|
264
|
+
loadComponent: () => import('./cloud-ide-core-workflow-registry-list.component-B453QJwg.mjs').then(c => c.CideCoreWorkflowRegistryListComponent),
|
|
265
|
+
title: 'Workflow Registry',
|
|
266
|
+
canActivate: [authGuard],
|
|
267
|
+
data: {
|
|
268
|
+
sypg_page_code: "core_workflow_registry"
|
|
269
|
+
}
|
|
260
270
|
}
|
|
261
271
|
];
|
|
262
272
|
|
|
@@ -6396,7 +6406,7 @@ class CideCorePageListComponent {
|
|
|
6396
6406
|
document.dispatchEvent(event);
|
|
6397
6407
|
}
|
|
6398
6408
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideCorePageListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
6399
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: CideCorePageListComponent, isStandalone: true, selector: "cide-core-page-list", viewQueries: [{ propertyName: "pageDetailsRendererTemplate", first: true, predicate: ["pageDetailsRendererTemplate"], descendants: true, isSignal: true }, { propertyName: "pageStatusRendererTemplate", first: true, predicate: ["pageStatusRendererTemplate"], descendants: true, isSignal: true }, { propertyName: "actionsDropdownRendererTemplate", first: true, predicate: ["actionsDropdownRendererTemplate"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- Page List Container -->\
|
|
6409
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: CideCorePageListComponent, isStandalone: true, selector: "cide-core-page-list", viewQueries: [{ propertyName: "pageDetailsRendererTemplate", first: true, predicate: ["pageDetailsRendererTemplate"], descendants: true, isSignal: true }, { propertyName: "pageStatusRendererTemplate", first: true, predicate: ["pageStatusRendererTemplate"], descendants: true, isSignal: true }, { propertyName: "actionsDropdownRendererTemplate", first: true, predicate: ["actionsDropdownRendererTemplate"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- Page List Container -->\n<div class=\"tw-table tw-w-full tw-h-full\">\n\n <!-- Header Section with Filters -->\n <div class=\"tw-table-row tw-h-0\">\n <div class=\"tw-table-cell tw-px-6 tw-py-3 tw-border-b tw-border-gray-200 tw-bg-gray-50\">\n <div class=\"tw-flex tw-flex-col sm:tw-flex-row tw-justify-between tw-items-start sm:tw-items-center tw-space-y-3 sm:tw-space-y-0\">\n\n <!-- Title -->\n <div class=\"tw-flex tw-items-center tw-space-x-2\">\n <cide-ele-icon class=\"tw-text-blue-600 tw-w-5 tw-h-5\">web</cide-ele-icon>\n <h5 class=\"tw-text-base tw-font-medium tw-text-gray-900 tw-m-0\">Page Management</h5>\n </div>\n\n <!-- Actions -->\n <div class=\"tw-flex tw-flex-col sm:tw-flex-row tw-items-start sm:tw-items-center tw-space-y-3 sm:tw-space-y-0 sm:tw-space-x-3\">\n <!-- Add Page Button -->\n @if (canCreate()) {\n <button\n cideEleButton\n variant=\"primary\"\n size=\"sm\"\n (click)=\"createPage()\"\n leftIcon=\"add\"\n class=\"tw-whitespace-nowrap tw-flex tw-items-center tw-gap-2\">\n Create New Page\n </button>\n }\n </div>\n </div>\n\n <!-- Error Message -->\n @if (error()) {\n <div class=\"tw-mt-4 tw-p-4 tw-bg-red-50 tw-border tw-border-red-200 tw-rounded-md\">\n <div class=\"tw-flex tw-items-start\">\n <cide-ele-icon class=\"tw-text-red-400 tw-w-5 tw-h-5 tw-mt-0.5 tw-flex-shrink-0\">error</cide-ele-icon>\n <div class=\"tw-ml-3\">\n <h3 class=\"tw-text-sm tw-font-medium tw-text-red-800 tw-m-0\">Error</h3>\n <p class=\"tw-text-sm tw-text-red-700 tw-mt-1 tw-m-0\">{{ error() }}</p>\n </div>\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Main Content Area -->\n <div class=\"tw-table-row\">\n <div class=\"tw-table-cell tw-h-full tw-relative\">\n \n <!-- Data Grid Component -->\n <div class=\"tw-h-full tw-overflow-auto\">\n <cide-ele-data-grid\n [config]=\"gridConfig()\"\n [templateRenderers]=\"getTemplateRenderers()\"\n [actionHandlers]=\"actionHandlers\"\n [serverSidePagination]=\"true\"\n [totalServerItems]=\"totalItems()\"\n [currentServerPage]=\"currentPage()\"\n [currentServerPageSize]=\"pageSize()\"\n (gridEvent)=\"onGridEvent($event)\">\n </cide-ele-data-grid>\n </div>\n\n </div>\n </div>\n\n</div>\n\n<!-- Page Details Renderer Template -->\n<ng-template #pageDetailsRendererTemplate let-row=\"row\" let-value=\"value\">\n <div class=\"tw-flex tw-items-center tw-min-w-0\">\n <!-- Page Icon -->\n <div class=\"tw-flex-shrink-0\">\n <cide-ele-icon class=\"tw-text-gray-400 tw-w-4 tw-h-4\">web</cide-ele-icon>\n </div>\n \n <!-- Page Details -->\n <div class=\"tw-ml-3 tw-min-w-0 tw-flex-1\">\n <div class=\"tw-text-sm tw-font-medium tw-text-gray-900 tw-truncate\" \n [title]=\"row.sypg_title\">\n {{ row.sypg_title || 'Untitled' }}\n </div>\n @if (row.sypg_desc) {\n <div class=\"tw-text-xs tw-text-gray-500 tw-truncate\" \n [title]=\"row.sypg_desc\">\n {{ row.sypg_desc }}\n </div>\n }\n </div>\n </div>\n</ng-template>\n\n<!-- Page Status Renderer Template -->\n<ng-template #pageStatusRendererTemplate let-row=\"row\" let-value=\"value\">\n <span class=\"tw-inline-flex tw-items-center tw-px-2.5 tw-py-0.5 tw-rounded-full tw-text-xs tw-font-medium tw-whitespace-nowrap\"\n [ngClass]=\"row.sypg_isactive ? 'tw-bg-green-100 tw-text-green-800' : 'tw-bg-red-100 tw-text-red-800'\">\n {{ row.sypg_isactive ? 'Active' : 'Inactive' }}\n </span>\n</ng-template>\n\n<!-- Actions Dropdown Renderer Template -->\n<ng-template #actionsDropdownRendererTemplate let-row=\"row\" let-value=\"value\">\n <cide-ele-dropdown\n [items]=\"getActionDropdownItems(row)\"\n [config]=\"{ triggerIcon: 'more_vert', triggerSize: 'sm' }\"\n (itemClick)=\"onDropdownItemClick($event, row)\">\n </cide-ele-dropdown>\n</ng-template> ", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1$1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: CideEleDataGridComponent, selector: "cide-ele-data-grid", inputs: ["config", "templateRenderers", "customFormatters", "actionHandlers", "serverSidePagination", "totalServerItems", "currentServerPage", "currentServerPageSize", "dragDropEnabled"], outputs: ["gridEvent"] }, { kind: "component", type: CideEleButtonComponent, selector: "button[cideEleButton], a[cideEleButton], cide-ele-button", inputs: ["label", "variant", "size", "type", "shape", "elevation", "disabled", "id", "loading", "fullWidth", "leftIcon", "rightIcon", "customClass", "tooltip", "ariaLabel", "testId", "routerLink", "routerExtras", "preventDoubleClick", "animated"], outputs: ["btnClick", "doubleClick"] }, { kind: "component", type: CideIconComponent, selector: "cide-ele-icon", inputs: ["size", "type", "toolTip"] }, { kind: "component", type: CideEleDropdownComponent, selector: "cide-ele-dropdown", inputs: ["items", "config", "triggerTemplate", "menuTemplate"], outputs: ["itemClick", "dropdownToggle"] }] });
|
|
6400
6410
|
}
|
|
6401
6411
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideCorePageListComponent, decorators: [{
|
|
6402
6412
|
type: Component,
|
|
@@ -6406,7 +6416,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImpor
|
|
|
6406
6416
|
CideEleButtonComponent,
|
|
6407
6417
|
CideIconComponent,
|
|
6408
6418
|
CideEleDropdownComponent
|
|
6409
|
-
], template: "<!-- Page List Container -->\
|
|
6419
|
+
], template: "<!-- Page List Container -->\n<div class=\"tw-table tw-w-full tw-h-full\">\n\n <!-- Header Section with Filters -->\n <div class=\"tw-table-row tw-h-0\">\n <div class=\"tw-table-cell tw-px-6 tw-py-3 tw-border-b tw-border-gray-200 tw-bg-gray-50\">\n <div class=\"tw-flex tw-flex-col sm:tw-flex-row tw-justify-between tw-items-start sm:tw-items-center tw-space-y-3 sm:tw-space-y-0\">\n\n <!-- Title -->\n <div class=\"tw-flex tw-items-center tw-space-x-2\">\n <cide-ele-icon class=\"tw-text-blue-600 tw-w-5 tw-h-5\">web</cide-ele-icon>\n <h5 class=\"tw-text-base tw-font-medium tw-text-gray-900 tw-m-0\">Page Management</h5>\n </div>\n\n <!-- Actions -->\n <div class=\"tw-flex tw-flex-col sm:tw-flex-row tw-items-start sm:tw-items-center tw-space-y-3 sm:tw-space-y-0 sm:tw-space-x-3\">\n <!-- Add Page Button -->\n @if (canCreate()) {\n <button\n cideEleButton\n variant=\"primary\"\n size=\"sm\"\n (click)=\"createPage()\"\n leftIcon=\"add\"\n class=\"tw-whitespace-nowrap tw-flex tw-items-center tw-gap-2\">\n Create New Page\n </button>\n }\n </div>\n </div>\n\n <!-- Error Message -->\n @if (error()) {\n <div class=\"tw-mt-4 tw-p-4 tw-bg-red-50 tw-border tw-border-red-200 tw-rounded-md\">\n <div class=\"tw-flex tw-items-start\">\n <cide-ele-icon class=\"tw-text-red-400 tw-w-5 tw-h-5 tw-mt-0.5 tw-flex-shrink-0\">error</cide-ele-icon>\n <div class=\"tw-ml-3\">\n <h3 class=\"tw-text-sm tw-font-medium tw-text-red-800 tw-m-0\">Error</h3>\n <p class=\"tw-text-sm tw-text-red-700 tw-mt-1 tw-m-0\">{{ error() }}</p>\n </div>\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Main Content Area -->\n <div class=\"tw-table-row\">\n <div class=\"tw-table-cell tw-h-full tw-relative\">\n \n <!-- Data Grid Component -->\n <div class=\"tw-h-full tw-overflow-auto\">\n <cide-ele-data-grid\n [config]=\"gridConfig()\"\n [templateRenderers]=\"getTemplateRenderers()\"\n [actionHandlers]=\"actionHandlers\"\n [serverSidePagination]=\"true\"\n [totalServerItems]=\"totalItems()\"\n [currentServerPage]=\"currentPage()\"\n [currentServerPageSize]=\"pageSize()\"\n (gridEvent)=\"onGridEvent($event)\">\n </cide-ele-data-grid>\n </div>\n\n </div>\n </div>\n\n</div>\n\n<!-- Page Details Renderer Template -->\n<ng-template #pageDetailsRendererTemplate let-row=\"row\" let-value=\"value\">\n <div class=\"tw-flex tw-items-center tw-min-w-0\">\n <!-- Page Icon -->\n <div class=\"tw-flex-shrink-0\">\n <cide-ele-icon class=\"tw-text-gray-400 tw-w-4 tw-h-4\">web</cide-ele-icon>\n </div>\n \n <!-- Page Details -->\n <div class=\"tw-ml-3 tw-min-w-0 tw-flex-1\">\n <div class=\"tw-text-sm tw-font-medium tw-text-gray-900 tw-truncate\" \n [title]=\"row.sypg_title\">\n {{ row.sypg_title || 'Untitled' }}\n </div>\n @if (row.sypg_desc) {\n <div class=\"tw-text-xs tw-text-gray-500 tw-truncate\" \n [title]=\"row.sypg_desc\">\n {{ row.sypg_desc }}\n </div>\n }\n </div>\n </div>\n</ng-template>\n\n<!-- Page Status Renderer Template -->\n<ng-template #pageStatusRendererTemplate let-row=\"row\" let-value=\"value\">\n <span class=\"tw-inline-flex tw-items-center tw-px-2.5 tw-py-0.5 tw-rounded-full tw-text-xs tw-font-medium tw-whitespace-nowrap\"\n [ngClass]=\"row.sypg_isactive ? 'tw-bg-green-100 tw-text-green-800' : 'tw-bg-red-100 tw-text-red-800'\">\n {{ row.sypg_isactive ? 'Active' : 'Inactive' }}\n </span>\n</ng-template>\n\n<!-- Actions Dropdown Renderer Template -->\n<ng-template #actionsDropdownRendererTemplate let-row=\"row\" let-value=\"value\">\n <cide-ele-dropdown\n [items]=\"getActionDropdownItems(row)\"\n [config]=\"{ triggerIcon: 'more_vert', triggerSize: 'sm' }\"\n (itemClick)=\"onDropdownItemClick($event, row)\">\n </cide-ele-dropdown>\n</ng-template> " }]
|
|
6410
6420
|
}], ctorParameters: () => [] });
|
|
6411
6421
|
|
|
6412
6422
|
var pageList_component = /*#__PURE__*/Object.freeze({
|
|
@@ -12154,22 +12164,35 @@ class CideCoreUserCreateComponent {
|
|
|
12154
12164
|
}
|
|
12155
12165
|
/**
|
|
12156
12166
|
* Process exceptions for each entity mapping based on modified vs actual permissions
|
|
12157
|
-
* This method should be called during save to create core_user_role_exceptions
|
|
12167
|
+
* This method should be called during save to create/update/delete core_user_role_exceptions
|
|
12168
|
+
*
|
|
12169
|
+
* Logic:
|
|
12170
|
+
* - If modified !== actual: create/update exception
|
|
12171
|
+
* - If modified === actual BUT exception exists in DB: delete exception
|
|
12172
|
+
* - If modified === actual AND no exception exists: do nothing
|
|
12173
|
+
* - Also process all existing exceptions from DB to ensure nothing is missed
|
|
12158
12174
|
*/
|
|
12159
12175
|
processRoleExceptions() {
|
|
12160
12176
|
const exceptions = [];
|
|
12177
|
+
const processedExceptionKeys = new Set(); // Track processed exceptions to avoid duplicates
|
|
12161
12178
|
console.log('🎭 Processing role exceptions for all entity mappings...');
|
|
12162
12179
|
// Iterate through all entity mappings
|
|
12163
12180
|
this.entityMappings().forEach((mapping, mappingIndex) => {
|
|
12164
12181
|
const menuRights = this.menuRightsMap()[mappingIndex.toString()] || [];
|
|
12182
|
+
const mappingWithExceptions = mapping;
|
|
12183
|
+
const existingExceptions = mappingWithExceptions.exceptions || [];
|
|
12165
12184
|
menuRights.forEach((menu) => {
|
|
12166
12185
|
if (menu._permissionValues) {
|
|
12167
12186
|
Object.keys(menu._permissionValues).forEach(permissionId => {
|
|
12168
12187
|
const permissionData = menu?._permissionValues?.[permissionId] || {};
|
|
12188
|
+
// Find existing exception for this menu/permission combination
|
|
12189
|
+
const existingException = this.findExistingException(this.userId() || '', mapping._id || '', permissionId, menu._id || '');
|
|
12190
|
+
// Create a unique key for this exception
|
|
12191
|
+
const exceptionKey = `${mapping._id || ''}_${menu._id || ''}_${permissionId}`;
|
|
12192
|
+
processedExceptionKeys.add(exceptionKey);
|
|
12169
12193
|
// Check if permission was modified (different from actual role permission)
|
|
12170
12194
|
if (permissionData.modified !== permissionData.actual) {
|
|
12171
|
-
//
|
|
12172
|
-
const existingException = this.findExistingException(this.userId() || '', mapping._id || '', permissionId, menu._id || '');
|
|
12195
|
+
// Create or update exception
|
|
12173
12196
|
const exception = {
|
|
12174
12197
|
_id: existingException?._id || '', // Use existing _id if found, otherwise empty for new exception
|
|
12175
12198
|
syusrex_user_id_user: this.userId() || '',
|
|
@@ -12181,15 +12204,68 @@ class CideCoreUserCreateComponent {
|
|
|
12181
12204
|
syusrex_status: permissionData.modified // Status reflects the checkbox state (true = checked, false = unchecked)
|
|
12182
12205
|
};
|
|
12183
12206
|
exceptions.push(exception);
|
|
12184
|
-
console.log(`🎭 Exception created for mapping ${mappingIndex}, menu ${menu.syme_title}, permission ${permissionData.permission
|
|
12207
|
+
console.log(`🎭 Exception created/updated for mapping ${mappingIndex}, menu ${menu.syme_title}, permission ${permissionData.permission?.sygms_title}:`, {
|
|
12185
12208
|
actual: permissionData.actual,
|
|
12186
12209
|
modified: permissionData.modified,
|
|
12187
12210
|
exception: exception
|
|
12188
12211
|
});
|
|
12189
12212
|
}
|
|
12213
|
+
else if (existingException && existingException._id) {
|
|
12214
|
+
// Modified === actual, but exception exists in DB - mark for deletion
|
|
12215
|
+
const exceptionToDelete = {
|
|
12216
|
+
_id: existingException._id,
|
|
12217
|
+
syusrex_user_id_user: this.userId() || '',
|
|
12218
|
+
syusrex_user_entity_mapping_id_syenm: mapping._id || '',
|
|
12219
|
+
syusrex_role_id_syusrol: mapping.syenm_role_id_syusrol?._id || '',
|
|
12220
|
+
syusrex_role_permissions_id_sygms: permissionId,
|
|
12221
|
+
syusrex_menu_id_syme: menu._id || '',
|
|
12222
|
+
syusrex_isactive: true,
|
|
12223
|
+
syusrex_status: false, // Not used for deletion, but required by type
|
|
12224
|
+
isDelete: true
|
|
12225
|
+
};
|
|
12226
|
+
exceptions.push(exceptionToDelete);
|
|
12227
|
+
console.log(`🗑️ Exception marked for deletion (modified === actual) for mapping ${mappingIndex}, menu ${menu.syme_title}, permission ${permissionData.permission?.sygms_title}:`, {
|
|
12228
|
+
actual: permissionData.actual,
|
|
12229
|
+
modified: permissionData.modified,
|
|
12230
|
+
exceptionId: existingException._id
|
|
12231
|
+
});
|
|
12232
|
+
}
|
|
12190
12233
|
});
|
|
12191
12234
|
}
|
|
12192
12235
|
});
|
|
12236
|
+
// Also check all existing exceptions from DB that might not be in current menu rights
|
|
12237
|
+
// This ensures we don't miss any exceptions that should be deleted
|
|
12238
|
+
existingExceptions.forEach((existingException) => {
|
|
12239
|
+
if (existingException._id) {
|
|
12240
|
+
const exceptionKey = `${existingException.syusrex_user_entity_mapping_id_syenm || ''}_${existingException.syusrex_menu_id_syme || ''}_${existingException.syusrex_role_permissions_id_sygms || ''}`;
|
|
12241
|
+
// If this exception wasn't processed above, check if it should be deleted
|
|
12242
|
+
if (!processedExceptionKeys.has(exceptionKey)) {
|
|
12243
|
+
// Find the corresponding menu and permission to check if it matches role
|
|
12244
|
+
const menuRights = this.menuRightsMap()[mappingIndex.toString()] || [];
|
|
12245
|
+
const menu = menuRights.find((m) => m._id === existingException.syusrex_menu_id_syme);
|
|
12246
|
+
if (menu && menu._permissionValues) {
|
|
12247
|
+
const permissionId = existingException.syusrex_role_permissions_id_sygms?.toString() || '';
|
|
12248
|
+
const permissionData = menu._permissionValues[permissionId];
|
|
12249
|
+
if (permissionData && permissionData.modified === permissionData.actual) {
|
|
12250
|
+
// Permission matches role, but exception exists - mark for deletion
|
|
12251
|
+
const exceptionToDelete = {
|
|
12252
|
+
_id: existingException._id,
|
|
12253
|
+
syusrex_user_id_user: this.userId() || '',
|
|
12254
|
+
syusrex_user_entity_mapping_id_syenm: mapping._id || '',
|
|
12255
|
+
syusrex_role_id_syusrol: mapping.syenm_role_id_syusrol?._id || '',
|
|
12256
|
+
syusrex_role_permissions_id_sygms: permissionId,
|
|
12257
|
+
syusrex_menu_id_syme: menu._id || '',
|
|
12258
|
+
syusrex_isactive: true,
|
|
12259
|
+
syusrex_status: false,
|
|
12260
|
+
isDelete: true
|
|
12261
|
+
};
|
|
12262
|
+
exceptions.push(exceptionToDelete);
|
|
12263
|
+
console.log(`🗑️ Exception marked for deletion (orphaned/not in menu rights): ${existingException._id}`);
|
|
12264
|
+
}
|
|
12265
|
+
}
|
|
12266
|
+
}
|
|
12267
|
+
}
|
|
12268
|
+
});
|
|
12193
12269
|
});
|
|
12194
12270
|
console.log(`🎭 Total exceptions to process: ${exceptions.length}`, exceptions);
|
|
12195
12271
|
return exceptions;
|
|
@@ -15111,9 +15187,81 @@ class CideCoreUserCreateComponent {
|
|
|
15111
15187
|
},
|
|
15112
15188
|
error: (error) => {
|
|
15113
15189
|
console.error('❌ Error saving user master:', error);
|
|
15114
|
-
|
|
15115
|
-
|
|
15116
|
-
|
|
15190
|
+
// Extract error message from API response
|
|
15191
|
+
let errorMessage = 'Failed to save user. Please try again.';
|
|
15192
|
+
let errorTitle = 'Save Failed';
|
|
15193
|
+
let duplicateField = null;
|
|
15194
|
+
// Check if error has a response with message (handle both error.error and direct error)
|
|
15195
|
+
const apiError = error?.error || error;
|
|
15196
|
+
if (apiError?.message) {
|
|
15197
|
+
errorMessage = apiError.message;
|
|
15198
|
+
errorTitle = 'Validation Error';
|
|
15199
|
+
// Check if it's a duplicate key error
|
|
15200
|
+
if (apiError?.data?.errorCode === 'DUPLICATE_KEY_ERROR' ||
|
|
15201
|
+
apiError?.code === 409 ||
|
|
15202
|
+
error?.status === 409 ||
|
|
15203
|
+
errorMessage.toLowerCase().includes('already') ||
|
|
15204
|
+
errorMessage.toLowerCase().includes('duplicate') ||
|
|
15205
|
+
errorMessage.toLowerCase().includes('registered') ||
|
|
15206
|
+
errorMessage.toLowerCase().includes('taken')) {
|
|
15207
|
+
errorTitle = 'Duplicate Entry';
|
|
15208
|
+
// Get duplicate field from error data
|
|
15209
|
+
duplicateField = apiError?.data?.duplicateField || null;
|
|
15210
|
+
// Set form field error for the duplicate field
|
|
15211
|
+
if (duplicateField) {
|
|
15212
|
+
const fieldName = duplicateField.toLowerCase().replace(/\s+/g, '_');
|
|
15213
|
+
if (fieldName === 'email_id' || fieldName === 'emailid') {
|
|
15214
|
+
const emailControl = this.userMasterForm.get('user_emailid');
|
|
15215
|
+
if (emailControl) {
|
|
15216
|
+
emailControl.setErrors({
|
|
15217
|
+
duplicate: true,
|
|
15218
|
+
message: errorMessage
|
|
15219
|
+
});
|
|
15220
|
+
emailControl.markAsTouched();
|
|
15221
|
+
}
|
|
15222
|
+
}
|
|
15223
|
+
else if (fieldName === 'username') {
|
|
15224
|
+
const usernameControl = this.userMasterForm.get('user_username');
|
|
15225
|
+
if (usernameControl) {
|
|
15226
|
+
usernameControl.setErrors({
|
|
15227
|
+
duplicate: true,
|
|
15228
|
+
message: errorMessage
|
|
15229
|
+
});
|
|
15230
|
+
usernameControl.markAsTouched();
|
|
15231
|
+
}
|
|
15232
|
+
}
|
|
15233
|
+
else if (fieldName === 'mobile_number' || fieldName === 'mobileno') {
|
|
15234
|
+
const mobileControl = this.userMasterForm.get('user_mobileno');
|
|
15235
|
+
if (mobileControl) {
|
|
15236
|
+
mobileControl.setErrors({
|
|
15237
|
+
duplicate: true,
|
|
15238
|
+
message: errorMessage
|
|
15239
|
+
});
|
|
15240
|
+
mobileControl.markAsTouched();
|
|
15241
|
+
}
|
|
15242
|
+
}
|
|
15243
|
+
}
|
|
15244
|
+
}
|
|
15245
|
+
}
|
|
15246
|
+
else if (error?.message) {
|
|
15247
|
+
errorMessage = error.message;
|
|
15248
|
+
}
|
|
15249
|
+
else if (error?.status === 409) {
|
|
15250
|
+
errorMessage = 'A user with this information already exists. Please check and modify the duplicate field.';
|
|
15251
|
+
errorTitle = 'Duplicate Entry';
|
|
15252
|
+
}
|
|
15253
|
+
else if (error?.status === 400) {
|
|
15254
|
+
errorMessage = 'Invalid data provided. Please check your input.';
|
|
15255
|
+
errorTitle = 'Validation Error';
|
|
15256
|
+
}
|
|
15257
|
+
else if (error?.status === 500) {
|
|
15258
|
+
errorMessage = 'Server error occurred. Please try again later.';
|
|
15259
|
+
errorTitle = 'Server Error';
|
|
15260
|
+
}
|
|
15261
|
+
// Show error notification with the extracted message
|
|
15262
|
+
this.notificationService.error(errorMessage, {
|
|
15263
|
+
title: errorTitle,
|
|
15264
|
+
duration: 7000 // Longer duration for important errors
|
|
15117
15265
|
});
|
|
15118
15266
|
this.loading.set(false);
|
|
15119
15267
|
}
|