cloud-ide-core 2.0.108 → 2.0.111
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-page-form.component-C3xTQLI3.mjs +527 -0
- package/fesm2022/cloud-ide-core-page-form.component-C3xTQLI3.mjs.map +1 -0
- package/fesm2022/cloud-ide-core.mjs +146 -16
- package/fesm2022/cloud-ide-core.mjs.map +1 -1
- package/index.d.ts +11 -4
- package/package.json +1 -1
- package/fesm2022/cloud-ide-core-page-form.component-DBvmSPd5.mjs +0 -458
- package/fesm2022/cloud-ide-core-page-form.component-DBvmSPd5.mjs.map +0 -1
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, DestroyRef, signal, computed, Component } from '@angular/core';
|
|
3
|
+
import { CommonModule } from '@angular/common';
|
|
4
|
+
import * as i1 from '@angular/forms';
|
|
5
|
+
import { NonNullableFormBuilder, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
|
|
6
|
+
import { Router, ActivatedRoute } from '@angular/router';
|
|
7
|
+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
8
|
+
import { CideCorePageManagementService, MenuManagementService } from './cloud-ide-core.mjs';
|
|
9
|
+
import { AppStateHelperService, ComponentContextService, RightsService } from 'cloud-ide-layout';
|
|
10
|
+
import { ConfirmationService, CideEleButtonComponent, CideInputComponent, CideSelectComponent, CideTextareaComponent, CideEleJsonEditorComponent, CideFormFieldErrorComponent } from 'cloud-ide-element';
|
|
11
|
+
import { generateObjectFromString, generateStringFromObject } from 'cloud-ide-lms-model';
|
|
12
|
+
|
|
13
|
+
class CideCorePageFormComponent {
|
|
14
|
+
destroyRef = inject(DestroyRef);
|
|
15
|
+
pageService = inject(CideCorePageManagementService);
|
|
16
|
+
menuService = inject(MenuManagementService);
|
|
17
|
+
appState = inject(AppStateHelperService);
|
|
18
|
+
fb = inject(NonNullableFormBuilder);
|
|
19
|
+
router = inject(Router);
|
|
20
|
+
route = inject(ActivatedRoute);
|
|
21
|
+
componentContextService = inject(ComponentContextService);
|
|
22
|
+
rightsService = inject(RightsService);
|
|
23
|
+
confirmationService = inject(ConfirmationService);
|
|
24
|
+
loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : []));
|
|
25
|
+
error = signal(null, ...(ngDevMode ? [{ debugName: "error" }] : []));
|
|
26
|
+
success = signal(null, ...(ngDevMode ? [{ debugName: "success" }] : []));
|
|
27
|
+
// Page information
|
|
28
|
+
pageId = signal(null, ...(ngDevMode ? [{ debugName: "pageId" }] : []));
|
|
29
|
+
isEditMode = signal(false, ...(ngDevMode ? [{ debugName: "isEditMode" }] : []));
|
|
30
|
+
// Menu mapping
|
|
31
|
+
enableMenuMapping = signal(false, ...(ngDevMode ? [{ debugName: "enableMenuMapping" }] : []));
|
|
32
|
+
menuMappingMode = signal('none', ...(ngDevMode ? [{ debugName: "menuMappingMode" }] : []));
|
|
33
|
+
existingMenus = signal([], ...(ngDevMode ? [{ debugName: "existingMenus" }] : []));
|
|
34
|
+
menusLoading = signal(false, ...(ngDevMode ? [{ debugName: "menusLoading" }] : []));
|
|
35
|
+
selectedMenuId = signal(null, ...(ngDevMode ? [{ debugName: "selectedMenuId" }] : []));
|
|
36
|
+
// New menu form
|
|
37
|
+
newMenuForm = this.fb.group({
|
|
38
|
+
syme_title: ['', [Validators.required, Validators.maxLength(100)]],
|
|
39
|
+
syme_desc: ['', [Validators.maxLength(255)]],
|
|
40
|
+
syme_type: ['menu', [Validators.required]],
|
|
41
|
+
syme_path: ['', [Validators.maxLength(255)]],
|
|
42
|
+
syme_icon: ['', [Validators.maxLength(40)]],
|
|
43
|
+
syme_id_syme: [''],
|
|
44
|
+
syme_order_by: [1, [Validators.required, Validators.min(1)]],
|
|
45
|
+
syme_isactive: [true]
|
|
46
|
+
});
|
|
47
|
+
pageForm = this.fb.group({
|
|
48
|
+
sypg_title: ['', [Validators.required, Validators.maxLength(100)]],
|
|
49
|
+
sypg_desc: ['', [Validators.maxLength(255)]],
|
|
50
|
+
sypg_page_code: ['', [Validators.required, Validators.maxLength(40), Validators.pattern(/^[a-zA-Z0-9_]+$/)]],
|
|
51
|
+
sypg_configuration: ['{}', [Validators.required]],
|
|
52
|
+
sypg_isactive: [true]
|
|
53
|
+
});
|
|
54
|
+
// Menu options for dropdown
|
|
55
|
+
menuOptions = computed(() => {
|
|
56
|
+
return this.existingMenus().map(menu => ({
|
|
57
|
+
value: menu._id || '',
|
|
58
|
+
label: menu.syme_title || 'Untitled Menu'
|
|
59
|
+
}));
|
|
60
|
+
}, ...(ngDevMode ? [{ debugName: "menuOptions" }] : []));
|
|
61
|
+
constructor() {
|
|
62
|
+
this.setupFormSubscriptions();
|
|
63
|
+
}
|
|
64
|
+
ngOnInit() {
|
|
65
|
+
// Initialize rights for page management
|
|
66
|
+
this.rightsService.initializeRights('core_page_management');
|
|
67
|
+
// Check for page ID in query parameters
|
|
68
|
+
this.checkForPageId();
|
|
69
|
+
// Load menus for mapping (only in create mode)
|
|
70
|
+
if (!this.isEditMode()) {
|
|
71
|
+
this.loadMenus();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// Load menus for mapping
|
|
75
|
+
loadMenus() {
|
|
76
|
+
this.menusLoading.set(true);
|
|
77
|
+
const payload = {
|
|
78
|
+
pageIndex: 1,
|
|
79
|
+
pageSize: 1000,
|
|
80
|
+
sort: { order: 'asc', key: 'syme_order_by' }
|
|
81
|
+
};
|
|
82
|
+
this.menuService.getMenuList(payload)
|
|
83
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
84
|
+
.subscribe({
|
|
85
|
+
next: (response) => {
|
|
86
|
+
if (response.success && response.data) {
|
|
87
|
+
this.existingMenus.set(response.data);
|
|
88
|
+
}
|
|
89
|
+
this.menusLoading.set(false);
|
|
90
|
+
},
|
|
91
|
+
error: (error) => {
|
|
92
|
+
console.error('Error loading menus:', error);
|
|
93
|
+
this.menusLoading.set(false);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
// Toggle menu mapping section
|
|
98
|
+
toggleMenuMapping() {
|
|
99
|
+
this.enableMenuMapping.set(!this.enableMenuMapping());
|
|
100
|
+
if (this.enableMenuMapping() && this.existingMenus().length === 0) {
|
|
101
|
+
this.loadMenus();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// Handle menu mapping mode change
|
|
105
|
+
onMenuMappingModeChange(mode) {
|
|
106
|
+
this.menuMappingMode.set(mode);
|
|
107
|
+
if (mode === 'existing') {
|
|
108
|
+
this.selectedMenuId.set(null);
|
|
109
|
+
}
|
|
110
|
+
else if (mode === 'new') {
|
|
111
|
+
// Auto-fill menu title from page title
|
|
112
|
+
const pageTitle = this.pageForm.get('sypg_title')?.value || '';
|
|
113
|
+
this.newMenuForm.patchValue({
|
|
114
|
+
syme_title: pageTitle,
|
|
115
|
+
syme_path: this.pageForm.get('sypg_page_code')?.value || ''
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
// Handle menu selection change
|
|
120
|
+
onMenuSelectionChange(value) {
|
|
121
|
+
// Convert the value to string or null
|
|
122
|
+
if (value === null || value === undefined || value === '') {
|
|
123
|
+
this.selectedMenuId.set(null);
|
|
124
|
+
}
|
|
125
|
+
else if (typeof value === 'string') {
|
|
126
|
+
this.selectedMenuId.set(value);
|
|
127
|
+
}
|
|
128
|
+
else if (typeof value === 'number') {
|
|
129
|
+
this.selectedMenuId.set(String(value));
|
|
130
|
+
}
|
|
131
|
+
else if (Array.isArray(value) && value.length > 0) {
|
|
132
|
+
// If it's an array, take the first value and convert to string
|
|
133
|
+
this.selectedMenuId.set(String(value[0]));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
this.selectedMenuId.set(null);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Check for page ID in query parameters
|
|
140
|
+
checkForPageId() {
|
|
141
|
+
console.log('🔍 Checking for page ID in query parameters', this.route.params);
|
|
142
|
+
this.route.params.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
|
|
143
|
+
console.log('🔍 Query params:', params);
|
|
144
|
+
// Check for pageId, id, or page parameter
|
|
145
|
+
const queryParams = params['query'];
|
|
146
|
+
const queryData = generateObjectFromString(queryParams);
|
|
147
|
+
// If pageId is an object string (from generateStringFromObject), try to parse it
|
|
148
|
+
const pageId = queryData.sypg_id;
|
|
149
|
+
if (pageId) {
|
|
150
|
+
console.log('🔍 Page ID found in query params:', pageId);
|
|
151
|
+
this.pageId.set(pageId);
|
|
152
|
+
this.isEditMode.set(true);
|
|
153
|
+
this.loadPageData(pageId);
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
console.log('🆕 No page ID found - creating new page');
|
|
157
|
+
this.isEditMode.set(false);
|
|
158
|
+
this.pageId.set(null);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// Load page data for editing
|
|
163
|
+
loadPageData(pageId) {
|
|
164
|
+
this.loading.set(true);
|
|
165
|
+
this.error.set(null);
|
|
166
|
+
console.log('📥 Loading page data for ID:', pageId);
|
|
167
|
+
this.pageService.getPageById(pageId).pipe(takeUntilDestroyed(this.destroyRef)).subscribe({
|
|
168
|
+
next: (response) => {
|
|
169
|
+
console.log('✅ Page data loaded:', response);
|
|
170
|
+
if (response?.success && response?.data) {
|
|
171
|
+
const pageData = response.data;
|
|
172
|
+
if (pageData) {
|
|
173
|
+
this.populateFormWithPageData(pageData);
|
|
174
|
+
this.success.set('Page data loaded successfully');
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
this.error.set('Page data not found');
|
|
178
|
+
console.error('❌ Page data not found in response:', response);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
this.error.set('Failed to load page data');
|
|
183
|
+
console.error('❌ Page data response invalid:', response);
|
|
184
|
+
}
|
|
185
|
+
this.loading.set(false);
|
|
186
|
+
},
|
|
187
|
+
error: (err) => {
|
|
188
|
+
console.error('❌ Failed to load page data:', err);
|
|
189
|
+
let errorMessage = 'Failed to load page data.';
|
|
190
|
+
if (err?.error?.message) {
|
|
191
|
+
errorMessage = err.error.message;
|
|
192
|
+
}
|
|
193
|
+
else if (err?.message) {
|
|
194
|
+
errorMessage = err.message;
|
|
195
|
+
}
|
|
196
|
+
else if (err?.status === 404) {
|
|
197
|
+
errorMessage = 'Page not found.';
|
|
198
|
+
}
|
|
199
|
+
else if (err?.status === 500) {
|
|
200
|
+
errorMessage = 'Server error. Please try again later.';
|
|
201
|
+
}
|
|
202
|
+
this.error.set(errorMessage);
|
|
203
|
+
this.loading.set(false);
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
// Populate form with page data
|
|
208
|
+
populateFormWithPageData(pageData) {
|
|
209
|
+
try {
|
|
210
|
+
console.log('📝 Populating form with page data:', pageData);
|
|
211
|
+
const formData = {
|
|
212
|
+
sypg_title: pageData.sypg_title || '',
|
|
213
|
+
sypg_desc: pageData.sypg_desc || '',
|
|
214
|
+
sypg_page_code: pageData.sypg_page_code || '',
|
|
215
|
+
sypg_configuration: pageData.sypg_configuration ? JSON.stringify(pageData.sypg_configuration) : '{}',
|
|
216
|
+
sypg_isactive: pageData.sypg_isactive !== undefined ? pageData.sypg_isactive : true
|
|
217
|
+
};
|
|
218
|
+
// Patch the form with the page data
|
|
219
|
+
this.pageForm.patchValue(formData, { emitEvent: false });
|
|
220
|
+
console.log('✅ Form populated successfully');
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
console.error('💥 Error populating form with page data:', error);
|
|
224
|
+
this.error.set('Error loading page data into form');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
setupFormSubscriptions() {
|
|
228
|
+
// Watch for form changes to enable/disable save button
|
|
229
|
+
this.pageForm.valueChanges
|
|
230
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
231
|
+
.subscribe(() => {
|
|
232
|
+
// Form validation is handled by computed signals
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
// Computed values
|
|
236
|
+
isFormDirty = computed(() => this.pageForm.dirty, ...(ngDevMode ? [{ debugName: "isFormDirty" }] : []));
|
|
237
|
+
// Rights computed signals
|
|
238
|
+
canCreate = computed(() => this.rightsService.hasRight('CREATE'), ...(ngDevMode ? [{ debugName: "canCreate" }] : []));
|
|
239
|
+
canEdit = computed(() => this.rightsService.hasRight('EDIT'), ...(ngDevMode ? [{ debugName: "canEdit" }] : []));
|
|
240
|
+
canView = computed(() => this.rightsService.hasRight('VIEW'), ...(ngDevMode ? [{ debugName: "canView" }] : []));
|
|
241
|
+
// Form submission
|
|
242
|
+
savePage() {
|
|
243
|
+
const requiredRight = this.isEditMode() ? 'EDIT' : 'CREATE';
|
|
244
|
+
if (!this.rightsService.hasRight(requiredRight)) {
|
|
245
|
+
this.error.set(`You do not have permission to ${this.isEditMode() ? 'edit' : 'create'} pages`);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
if (!this.pageForm.valid) {
|
|
249
|
+
this.markFormAsTouched();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
// Validate menu mapping if enabled
|
|
253
|
+
if (this.enableMenuMapping() && !this.isEditMode()) {
|
|
254
|
+
if (this.menuMappingMode() === 'existing' && !this.selectedMenuId()) {
|
|
255
|
+
this.error.set('Please select a menu item to map this page to');
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
if (this.menuMappingMode() === 'new' && !this.newMenuForm.valid) {
|
|
259
|
+
this.markMenuFormAsTouched();
|
|
260
|
+
this.error.set('Please fill in all required menu fields');
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const formValue = this.pageForm.getRawValue();
|
|
265
|
+
const pageData = {
|
|
266
|
+
_id: this.pageId() || '',
|
|
267
|
+
sypg_title: formValue.sypg_title,
|
|
268
|
+
sypg_desc: formValue.sypg_desc,
|
|
269
|
+
sypg_page_code: formValue.sypg_page_code,
|
|
270
|
+
sypg_configuration: formValue.sypg_configuration,
|
|
271
|
+
sypg_isactive: formValue.sypg_isactive
|
|
272
|
+
};
|
|
273
|
+
this.loading.set(true);
|
|
274
|
+
this.error.set(null);
|
|
275
|
+
this.pageService.createOrUpdatePage(pageData)
|
|
276
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
277
|
+
.subscribe({
|
|
278
|
+
next: (response) => {
|
|
279
|
+
if (response.success) {
|
|
280
|
+
const savedPageId = response.data?._id || this.pageId();
|
|
281
|
+
const savedPageData = response.data;
|
|
282
|
+
this.success.set(this.isEditMode() ? 'Page updated successfully' : 'Page created successfully');
|
|
283
|
+
console.log('✅ Page saved successfully');
|
|
284
|
+
// Handle menu mapping if enabled (only in create mode)
|
|
285
|
+
if (this.enableMenuMapping() && !this.isEditMode() && savedPageId) {
|
|
286
|
+
this.handleMenuMapping(savedPageId, savedPageData || null);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
// For new pages, show confirmation dialog suggesting to create theme
|
|
290
|
+
if (!this.isEditMode() && savedPageId && savedPageData) {
|
|
291
|
+
this.showCreateThemeConfirmation(savedPageId, savedPageData);
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
296
|
+
}, 1500);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
this.loading.set(false);
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
this.error.set(response.message || 'Failed to save page');
|
|
303
|
+
console.error('❌ Failed to save page:', response.message);
|
|
304
|
+
this.loading.set(false);
|
|
305
|
+
}
|
|
306
|
+
},
|
|
307
|
+
error: (error) => {
|
|
308
|
+
console.error('❌ Error saving page:', error);
|
|
309
|
+
this.error.set('Failed to save page. Please try again.');
|
|
310
|
+
this.loading.set(false);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
// Handle menu mapping after page creation
|
|
315
|
+
handleMenuMapping(pageId, pageData) {
|
|
316
|
+
if (this.menuMappingMode() === 'none') {
|
|
317
|
+
setTimeout(() => {
|
|
318
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
319
|
+
}, 1500);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
if (this.menuMappingMode() === 'existing' && this.selectedMenuId()) {
|
|
323
|
+
// Update existing menu to include this page
|
|
324
|
+
this.menuService.getMenuItemById(this.selectedMenuId())
|
|
325
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
326
|
+
.subscribe({
|
|
327
|
+
next: (response) => {
|
|
328
|
+
if (response.success && response.data) {
|
|
329
|
+
const menu = response.data;
|
|
330
|
+
const existingPages = Array.isArray(menu.syme_pages_id_sypg)
|
|
331
|
+
? [...menu.syme_pages_id_sypg]
|
|
332
|
+
: [];
|
|
333
|
+
// Check if page ID already exists
|
|
334
|
+
const pageIdStr = pageId.toString();
|
|
335
|
+
if (!existingPages.some(p => p?.toString() === pageIdStr)) {
|
|
336
|
+
existingPages.push(pageId);
|
|
337
|
+
}
|
|
338
|
+
const updatePayload = {
|
|
339
|
+
...menu,
|
|
340
|
+
syme_pages_id_sypg: existingPages
|
|
341
|
+
};
|
|
342
|
+
this.menuService.updateMenuItem(this.selectedMenuId(), updatePayload)
|
|
343
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
344
|
+
.subscribe({
|
|
345
|
+
next: () => {
|
|
346
|
+
this.success.set('Page created and mapped to menu successfully');
|
|
347
|
+
this.loading.set(false);
|
|
348
|
+
// Show theme creation confirmation after menu mapping
|
|
349
|
+
if (pageData) {
|
|
350
|
+
this.showCreateThemeConfirmation(pageId, pageData);
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// Fallback to form data if pageData is not available
|
|
354
|
+
const formValue = this.pageForm.getRawValue();
|
|
355
|
+
const fallbackPageData = {
|
|
356
|
+
_id: pageId,
|
|
357
|
+
sypg_title: formValue.sypg_title,
|
|
358
|
+
sypg_page_code: formValue.sypg_page_code,
|
|
359
|
+
sypg_desc: formValue.sypg_desc,
|
|
360
|
+
sypg_configuration: formValue.sypg_configuration,
|
|
361
|
+
sypg_isactive: formValue.sypg_isactive
|
|
362
|
+
};
|
|
363
|
+
this.showCreateThemeConfirmation(pageId, fallbackPageData);
|
|
364
|
+
}
|
|
365
|
+
},
|
|
366
|
+
error: (error) => {
|
|
367
|
+
console.error('Error mapping page to menu:', error);
|
|
368
|
+
this.success.set('Page created successfully, but menu mapping failed');
|
|
369
|
+
setTimeout(() => {
|
|
370
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
371
|
+
}, 1500);
|
|
372
|
+
this.loading.set(false);
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
else {
|
|
377
|
+
this.loading.set(false);
|
|
378
|
+
setTimeout(() => {
|
|
379
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
380
|
+
}, 1500);
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
error: (error) => {
|
|
384
|
+
console.error('Error fetching menu:', error);
|
|
385
|
+
this.success.set('Page created successfully, but menu mapping failed');
|
|
386
|
+
setTimeout(() => {
|
|
387
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
388
|
+
}, 1500);
|
|
389
|
+
this.loading.set(false);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
else if (this.menuMappingMode() === 'new') {
|
|
394
|
+
// Create new menu item with this page
|
|
395
|
+
const menuFormValue = this.newMenuForm.getRawValue();
|
|
396
|
+
const newMenuPayload = {
|
|
397
|
+
syme_title: menuFormValue.syme_title,
|
|
398
|
+
syme_desc: menuFormValue.syme_desc || '',
|
|
399
|
+
syme_type: menuFormValue.syme_type,
|
|
400
|
+
syme_path: menuFormValue.syme_path || this.pageForm.get('sypg_page_code')?.value || '',
|
|
401
|
+
syme_icon: menuFormValue.syme_icon || '',
|
|
402
|
+
syme_id_syme: menuFormValue.syme_id_syme || undefined,
|
|
403
|
+
syme_order_by: menuFormValue.syme_order_by,
|
|
404
|
+
syme_isactive: menuFormValue.syme_isactive,
|
|
405
|
+
syme_pages_id_sypg: [pageId]
|
|
406
|
+
};
|
|
407
|
+
this.menuService.createMenuItem(newMenuPayload)
|
|
408
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
409
|
+
.subscribe({
|
|
410
|
+
next: () => {
|
|
411
|
+
this.success.set('Page created and new menu item created successfully');
|
|
412
|
+
this.loading.set(false);
|
|
413
|
+
// Show theme creation confirmation after menu creation
|
|
414
|
+
if (pageData) {
|
|
415
|
+
this.showCreateThemeConfirmation(pageId, pageData);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
// Fallback to form data if pageData is not available
|
|
419
|
+
const formValue = this.pageForm.getRawValue();
|
|
420
|
+
const fallbackPageData = {
|
|
421
|
+
_id: pageId,
|
|
422
|
+
sypg_title: formValue.sypg_title,
|
|
423
|
+
sypg_page_code: formValue.sypg_page_code,
|
|
424
|
+
sypg_desc: formValue.sypg_desc,
|
|
425
|
+
sypg_configuration: formValue.sypg_configuration,
|
|
426
|
+
sypg_isactive: formValue.sypg_isactive
|
|
427
|
+
};
|
|
428
|
+
this.showCreateThemeConfirmation(pageId, fallbackPageData);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
error: (error) => {
|
|
432
|
+
console.error('Error creating menu:', error);
|
|
433
|
+
this.success.set('Page created successfully, but menu creation failed');
|
|
434
|
+
setTimeout(() => {
|
|
435
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
436
|
+
}, 1500);
|
|
437
|
+
this.loading.set(false);
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
// Mark menu form as touched
|
|
443
|
+
markMenuFormAsTouched() {
|
|
444
|
+
Object.keys(this.newMenuForm.controls).forEach(key => {
|
|
445
|
+
const control = this.newMenuForm.get(key);
|
|
446
|
+
control?.markAsTouched();
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
// Cancel form
|
|
450
|
+
cancelForm() {
|
|
451
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
452
|
+
}
|
|
453
|
+
// Go back to page list
|
|
454
|
+
goBack() {
|
|
455
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
456
|
+
}
|
|
457
|
+
// Reset form - reload data in edit mode, reset to defaults in create mode
|
|
458
|
+
resetForm() {
|
|
459
|
+
if (this.isEditMode() && this.pageId()) {
|
|
460
|
+
this.loadPageData(this.pageId());
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
this.pageForm.reset({
|
|
464
|
+
sypg_isactive: true,
|
|
465
|
+
sypg_configuration: '{}'
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// Mark form as touched to trigger validation display
|
|
470
|
+
markFormAsTouched() {
|
|
471
|
+
Object.keys(this.pageForm.controls).forEach(key => {
|
|
472
|
+
const control = this.pageForm.get(key);
|
|
473
|
+
control?.markAsTouched();
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Show confirmation dialog suggesting to create theme after page creation
|
|
478
|
+
*/
|
|
479
|
+
showCreateThemeConfirmation(pageId, pageData) {
|
|
480
|
+
this.confirmationService.ask({
|
|
481
|
+
title: 'Page Created Successfully!',
|
|
482
|
+
message: `Would you like to create a theme for this page? This will set up the default theme configuration for "${pageData.sypg_title || pageData.sypg_page_code}".`,
|
|
483
|
+
confirmText: 'Create Theme',
|
|
484
|
+
cancelText: 'Skip',
|
|
485
|
+
type: 'success',
|
|
486
|
+
icon: 'palette'
|
|
487
|
+
}).then((confirmed) => {
|
|
488
|
+
if (confirmed) {
|
|
489
|
+
// Navigate to theme page with page data
|
|
490
|
+
const queryData = {
|
|
491
|
+
sypg_id: pageId,
|
|
492
|
+
sypg_title: pageData.sypg_title || '',
|
|
493
|
+
sypg_page_code: pageData.sypg_page_code || ''
|
|
494
|
+
};
|
|
495
|
+
// Generate query string from object using utility function
|
|
496
|
+
const queryString = generateStringFromObject(queryData);
|
|
497
|
+
// Navigate to theme page with query params
|
|
498
|
+
this.router.navigate(['/control-panel/page-theme', queryString]);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// User chose to skip - close and go to page list
|
|
502
|
+
setTimeout(() => {
|
|
503
|
+
this.componentContextService.close(['/control-panel/page']);
|
|
504
|
+
}, 500);
|
|
505
|
+
}
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideCorePageFormComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
509
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: CideCorePageFormComponent, isStandalone: true, selector: "cide-core-page-form", ngImport: i0, template: "<div class=\"page-form-wrapper\">\n <div class=\"page-form-container\">\n <form class=\"page-form\" [formGroup]=\"pageForm\" [class.loading]=\"loading()\" (ngSubmit)=\"savePage()\">\n \n <!-- Header Section -->\n <div class=\"form-header\">\n <h2 class=\"form-title\">{{ isEditMode() ? 'Edit Page' : 'Create Page' }}</h2>\n <p class=\"form-subtitle\">\n {{ isEditMode() ? 'Update page information and configuration' : 'Create a new page with configuration' }}\n </p>\n </div>\n\n <!-- Success and Error Messages -->\n <div class=\"form-messages\">\n @if (success()) {\n <div class=\"alert alert-success\">\n <svg class=\"alert-icon\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path>\n </svg>\n <span>{{ success() }}</span>\n </div>\n }\n @if (error()) {\n <div class=\"alert alert-error\">\n <svg class=\"alert-icon\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path>\n </svg>\n <span>{{ error() }}</span>\n </div>\n }\n </div>\n\n <!-- Form Content -->\n <div class=\"form-content\">\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input \n id=\"sypg_title\"\n label=\"Page Title\" \n formControlName=\"sypg_title\"\n placeholder=\"Enter page title\"\n size=\"md\">\n </cide-ele-input>\n </div>\n \n <div class=\"form-field\">\n <cide-ele-input \n id=\"sypg_page_code\"\n label=\"Page Code\" \n formControlName=\"sypg_page_code\"\n placeholder=\"Enter page code (alphanumeric and underscore only)\"\n size=\"md\">\n </cide-ele-input>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-textarea \n id=\"sypg_desc\"\n label=\"Page Description\" \n formControlName=\"sypg_desc\"\n placeholder=\"Enter page description\"\n [rows]=\"3\"\n size=\"md\">\n </cide-ele-textarea>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-json-editor\n id=\"sypg_configuration\"\n label=\"Configuration JSON\"\n formControlName=\"sypg_configuration\"\n placeholder='{\"key\": \"value\"}'>\n </cide-ele-json-editor>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"sypg_isactive\"\n type=\"checkbox\"\n formControlName=\"sypg_isactive\"\n label=\"Active Status\"\n size=\"sm\">\n </cide-ele-input>\n </div>\n </div>\n\n <!-- Menu Mapping Section (Only in Create Mode) -->\n @if (!isEditMode()) {\n <div class=\"form-row form-row-1\">\n <div class=\"form-field menu-mapping-section\">\n <div class=\"menu-mapping-header\">\n <div class=\"menu-mapping-toggle\">\n <input\n type=\"checkbox\"\n id=\"enable_menu_mapping\"\n [checked]=\"enableMenuMapping()\"\n (change)=\"toggleMenuMapping()\"\n class=\"menu-mapping-checkbox\">\n <label for=\"enable_menu_mapping\" class=\"menu-mapping-label-checkbox\">Map to Menu</label>\n </div>\n <span class=\"menu-mapping-hint\">Optionally map this page to a menu item during creation</span>\n </div>\n\n @if (enableMenuMapping()) {\n <div class=\"menu-mapping-content\">\n <!-- Menu Mapping Mode Selection -->\n <div class=\"menu-mapping-mode\">\n <label class=\"menu-mapping-label\">Mapping Option:</label>\n <div class=\"menu-mapping-options\">\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'none'\"\n (click)=\"onMenuMappingModeChange('none')\">\n Skip Mapping\n </button>\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'existing'\"\n (click)=\"onMenuMappingModeChange('existing')\">\n Map to Existing Menu\n </button>\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'new'\"\n (click)=\"onMenuMappingModeChange('new')\">\n Create New Menu\n </button>\n </div>\n </div>\n\n <!-- Existing Menu Selection -->\n @if (menuMappingMode() === 'existing') {\n <div class=\"menu-mapping-form\">\n <cide-ele-select\n label=\"Select Menu Item\"\n [options]=\"menuOptions()\"\n [loading]=\"menusLoading()\"\n placeholder=\"Choose a menu item to map this page to\"\n [searchable]=\"true\"\n size=\"md\"\n [ngModel]=\"selectedMenuId() ?? ''\"\n (ngModelChange)=\"onMenuSelectionChange($event)\">\n </cide-ele-select>\n <p class=\"menu-mapping-help\">\n This page will be added to the selected menu item's page list.\n </p>\n </div>\n }\n\n <!-- New Menu Creation Form -->\n @if (menuMappingMode() === 'new') {\n <div class=\"menu-mapping-form\">\n <form [formGroup]=\"newMenuForm\" class=\"new-menu-form\">\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_title\"\n label=\"Menu Title\"\n formControlName=\"syme_title\"\n placeholder=\"Enter menu title\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-select\n label=\"Menu Type\"\n formControlName=\"syme_type\"\n [options]=\"[\n { value: 'menu', label: 'Menu Item' },\n { value: 'section', label: 'Section' },\n { value: 'title', label: 'Title' }\n ]\"\n placeholder=\"Select menu type\"\n size=\"md\">\n </cide-ele-select>\n </div>\n </div>\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_path\"\n label=\"Menu Path\"\n formControlName=\"syme_path\"\n placeholder=\"e.g., /control-panel/page\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_icon\"\n label=\"Icon\"\n formControlName=\"syme_icon\"\n placeholder=\"e.g., dashboard, settings\"\n size=\"md\">\n </cide-ele-input>\n </div>\n </div>\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-textarea\n id=\"syme_desc\"\n label=\"Menu Description\"\n formControlName=\"syme_desc\"\n placeholder=\"Enter menu description (optional)\"\n [rows]=\"2\"\n size=\"md\">\n </cide-ele-textarea>\n </div>\n </div>\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_order_by\"\n label=\"Order\"\n formControlName=\"syme_order_by\"\n type=\"number\"\n placeholder=\"Menu order\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_isactive\"\n type=\"checkbox\"\n formControlName=\"syme_isactive\"\n label=\"Active\"\n size=\"sm\">\n </cide-ele-input>\n </div>\n </div>\n </form>\n <p class=\"menu-mapping-help\">\n A new menu item will be created and this page will be automatically mapped to it.\n </p>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n <!-- Form Actions -->\n <div class=\"form-actions\">\n <div class=\"form-actions-content\">\n <!-- Error Message (Left Side) -->\n <div class=\"form-actions-error\">\n <cide-form-field-error [formGroup]=\"pageForm\"></cide-form-field-error>\n </div>\n \n <!-- Action Buttons (Right Side) -->\n <div class=\"form-actions-buttons\">\n @if (!isEditMode()) {\n <button cideEleButton\n type=\"button\" \n variant=\"secondary\" \n (click)=\"resetForm()\" \n leftIcon=\"refresh\"\n [disabled]=\"loading()\">\n Reset Form\n </button>\n }\n \n <button cideEleButton\n type=\"button\" \n variant=\"secondary\" \n (click)=\"cancelForm()\" \n leftIcon=\"close\"\n [disabled]=\"loading()\">\n Cancel\n </button>\n \n <button cideEleButton\n type=\"submit\" \n variant=\"primary\" \n [disabled]=\"loading() || !pageForm.valid\"\n [loading]=\"loading()\"\n leftIcon=\"save\">\n {{ isEditMode() ? 'Update Page' : 'Create Page' }}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n</div>\n", styles: [".page-form-wrapper{min-height:100vh;background-color:#f9fafb;padding:1.5rem;box-sizing:border-box}:host-context(.dark) .page-form-wrapper,:host-context([data-theme=dark]) .page-form-wrapper{background-color:#111827}@media (max-width: 768px){.page-form-wrapper{padding:1rem}}@media (max-width: 480px){.page-form-wrapper{padding:.75rem}}.page-form-container{max-width:1200px;margin:0 auto;width:100%}.page-form{background-color:#fff;border-radius:.5rem;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;border:1px solid #e5e7eb;overflow:hidden;display:flex;flex-direction:column}:host-context(.dark) .page-form,:host-context([data-theme=dark]) .page-form{background-color:#1f2937;border-color:#374151;box-shadow:0 1px 3px #0000004d,0 1px 2px #0003}.page-form.loading{opacity:.6;pointer-events:none}.form-header{padding:1.5rem 1.5rem 1rem;border-bottom:1px solid #e5e7eb;background-color:#fff}:host-context(.dark) .form-header,:host-context([data-theme=dark]) .form-header{background-color:#1f2937;border-bottom-color:#374151}.form-header .form-title{font-size:1.5rem;font-weight:700;margin:0 0 .5rem;color:#111827;line-height:1.2}:host-context(.dark) .form-header .form-title,:host-context([data-theme=dark]) .form-header .form-title{color:#f9fafb}.form-header .form-subtitle{font-size:.875rem;margin:0;font-weight:400;color:#6b7280;line-height:1.5}:host-context(.dark) .form-header .form-subtitle,:host-context([data-theme=dark]) .form-header .form-subtitle{color:#9ca3af}@media (max-width: 768px){.form-header{padding:1.25rem 1rem .75rem}.form-header .form-title{font-size:1.25rem}.form-header .form-subtitle{font-size:.8125rem}}.form-messages{padding:0 1.5rem;margin-top:1rem}@media (max-width: 768px){.form-messages{padding:0 1rem}}.alert{display:flex;align-items:center;gap:.75rem;padding:.875rem 1rem;margin-bottom:1rem;border-radius:.375rem;font-weight:500;font-size:.875rem;border-left:3px solid}.alert .alert-icon{width:1.25rem;height:1.25rem;flex-shrink:0}.alert.alert-success{background-color:#d1fae5;border-left-color:#10b981;color:#065f46}:host-context(.dark) .alert.alert-success,:host-context([data-theme=dark]) .alert.alert-success{background-color:#10b98133;border-left-color:#10b981;color:#6ee7b7}.alert.alert-error{background-color:#fee2e2;border-left-color:#ef4444;color:#991b1b}:host-context(.dark) .alert.alert-error,:host-context([data-theme=dark]) .alert.alert-error{background-color:#ef444433;border-left-color:#ef4444;color:#fca5a5}.form-content{padding:1.5rem;flex:1}@media (max-width: 768px){.form-content{padding:1rem}}@media (max-width: 480px){.form-content{padding:.75rem}}.form-row{display:grid;gap:1rem;margin-bottom:1rem}.form-row:last-child{margin-bottom:0}.form-row.form-row-1{grid-template-columns:1fr}.form-row.form-row-2{grid-template-columns:repeat(2,1fr)}@media (max-width: 768px){.form-row.form-row-2{grid-template-columns:1fr}}.form-row.form-row-3{grid-template-columns:repeat(3,1fr)}@media (max-width: 1024px){.form-row.form-row-3{grid-template-columns:repeat(2,1fr)}}@media (max-width: 768px){.form-row.form-row-3{grid-template-columns:1fr}}.form-row.form-row-4{grid-template-columns:repeat(4,1fr)}@media (max-width: 1024px){.form-row.form-row-4{grid-template-columns:repeat(2,1fr)}}@media (max-width: 768px){.form-row.form-row-4{grid-template-columns:1fr}}.form-field{display:flex;flex-direction:column}.form-actions{padding:1.25rem 1.5rem;border-top:1px solid #e5e7eb;background-color:#fff;margin-top:auto}:host-context(.dark) .form-actions,:host-context([data-theme=dark]) .form-actions{background-color:#1f2937;border-top-color:#374151}@media (max-width: 768px){.form-actions{padding:1rem}}@media (max-width: 480px){.form-actions{padding:.75rem}}.form-actions-content{display:flex;justify-content:space-between;align-items:center;gap:1rem;width:100%;flex-wrap:wrap}@media (max-width: 768px){.form-actions-content{flex-direction:column;align-items:stretch}}.form-actions-error{flex:1;min-width:0;display:flex;align-items:center}@media (max-width: 768px){.form-actions-error{width:100%;margin-bottom:.75rem}}.form-actions-buttons{display:flex;gap:.75rem;align-items:center;flex-shrink:0}@media (max-width: 768px){.form-actions-buttons{width:100%;justify-content:stretch}.form-actions-buttons button{flex:1;min-width:0}}@media (max-width: 480px){.form-actions-buttons{flex-direction:column}.form-actions-buttons button{width:100%}}cide-ele-input,cide-ele-textarea,cide-ele-json-editor,cide-ele-select{width:100%}cide-ele-input:focus-within,cide-ele-textarea:focus-within,cide-ele-json-editor:focus-within,cide-ele-select:focus-within{outline:none}.menu-mapping-section{border:1px solid #e5e7eb;border-radius:.5rem;padding:1rem;background-color:#f9fafb;margin-top:1rem}:host-context(.dark) .menu-mapping-section,:host-context([data-theme=dark]) .menu-mapping-section{background-color:#1f2937;border-color:#374151}.menu-mapping-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;gap:1rem}@media (max-width: 768px){.menu-mapping-header{flex-direction:column;align-items:flex-start}}.menu-mapping-toggle{display:flex;align-items:center;gap:.5rem}.menu-mapping-checkbox{width:1rem;height:1rem;cursor:pointer}.menu-mapping-label-checkbox{font-weight:500;font-size:.875rem;color:#374151;cursor:pointer}:host-context(.dark) .menu-mapping-label-checkbox,:host-context([data-theme=dark]) .menu-mapping-label-checkbox{color:#d1d5db}.menu-mapping-hint{font-size:.75rem;color:#6b7280;font-style:italic}:host-context(.dark) .menu-mapping-hint,:host-context([data-theme=dark]) .menu-mapping-hint{color:#9ca3af}.menu-mapping-content{margin-top:1rem;padding-top:1rem;border-top:1px solid #e5e7eb}:host-context(.dark) .menu-mapping-content,:host-context([data-theme=dark]) .menu-mapping-content{border-top-color:#374151}.menu-mapping-mode{margin-bottom:1rem}.menu-mapping-label{display:block;font-size:.875rem;font-weight:500;color:#374151;margin-bottom:.5rem}:host-context(.dark) .menu-mapping-label,:host-context([data-theme=dark]) .menu-mapping-label{color:#d1d5db}.menu-mapping-options{display:flex;gap:.5rem;flex-wrap:wrap}.menu-option-btn{padding:.5rem 1rem;border:1px solid #d1d5db;border-radius:.375rem;background-color:#fff;color:#374151;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s}:host-context(.dark) .menu-option-btn,:host-context([data-theme=dark]) .menu-option-btn{background-color:#374151;border-color:#4b5563;color:#d1d5db}.menu-option-btn:hover{background-color:#f3f4f6;border-color:#9ca3af}:host-context(.dark) .menu-option-btn:hover,:host-context([data-theme=dark]) .menu-option-btn:hover{background-color:#4b5563;border-color:#6b7280}.menu-option-btn.active{background-color:#3b82f6;border-color:#3b82f6;color:#fff}:host-context(.dark) .menu-option-btn.active,:host-context([data-theme=dark]) .menu-option-btn.active{background-color:#2563eb;border-color:#2563eb}.menu-mapping-form{margin-top:1rem;padding:1rem;background-color:#fff;border-radius:.375rem;border:1px solid #e5e7eb}:host-context(.dark) .menu-mapping-form,:host-context([data-theme=dark]) .menu-mapping-form{background-color:#111827;border-color:#374151}.new-menu-form .form-row{margin-bottom:1rem}.new-menu-form .form-row:last-child{margin-bottom:0}.menu-mapping-help{margin-top:.75rem;font-size:.75rem;color:#6b7280;font-style:italic}:host-context(.dark) .menu-mapping-help,:host-context([data-theme=dark]) .menu-mapping-help{color:#9ca3af}@media (max-width: 480px){.page-form-wrapper{padding:.5rem}.form-header{padding:1rem .75rem .75rem}.form-content,.form-actions{padding:.75rem}.menu-mapping-options{flex-direction:column}.menu-mapping-options .menu-option-btn{width:100%}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i1.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { 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: CideInputComponent, selector: "cide-ele-input", inputs: ["fill", "label", "labelHide", "disabled", "clearInput", "labelPlacement", "labelDir", "placeholder", "leadingIcon", "trailingIcon", "helperText", "helperTextCollapse", "hideHelperAndErrorText", "errorText", "maxlength", "minlength", "required", "autocapitalize", "autocomplete", "type", "width", "id", "ngModel", "option", "min", "max", "step", "size"], outputs: ["ngModelChange"] }, { kind: "component", type: CideSelectComponent, selector: "cide-ele-select", inputs: ["label", "labelHide", "placeholder", "helperText", "errorText", "required", "disabled", "id", "ngModel", "size", "fill", "labelPlacement", "labelDir", "leadingIcon", "trailingIcon", "clearInput", "options", "multiple", "searchable", "showSearchInput", "loading", "valueKey", "labelKey", "treeView"], outputs: ["ngModelChange", "change", "searchChange"] }, { kind: "component", type: CideTextareaComponent, selector: "cide-ele-textarea", inputs: ["label", "labelHide", "placeholder", "helperText", "errorText", "required", "disabled", "minlength", "maxlength", "rows", "id", "ngModel", "size", "fill", "labelPlacement", "labelDir", "leadingIcon", "trailingIcon", "clearInput"], outputs: ["ngModelChange"] }, { kind: "component", type: CideEleJsonEditorComponent, selector: "cide-ele-json-editor", inputs: ["label", "helperText", "required", "disabled", "showCharacterCount", "config"], outputs: ["valueChange", "objectChange", "errorsChange", "validChange"] }, { kind: "component", type: CideFormFieldErrorComponent, selector: "cide-form-field-error", inputs: ["control", "formGroup", "fieldName", "customMessages"] }] });
|
|
510
|
+
}
|
|
511
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: CideCorePageFormComponent, decorators: [{
|
|
512
|
+
type: Component,
|
|
513
|
+
args: [{ selector: 'cide-core-page-form', standalone: true, imports: [
|
|
514
|
+
CommonModule,
|
|
515
|
+
ReactiveFormsModule,
|
|
516
|
+
FormsModule,
|
|
517
|
+
CideEleButtonComponent,
|
|
518
|
+
CideInputComponent,
|
|
519
|
+
CideSelectComponent,
|
|
520
|
+
CideTextareaComponent,
|
|
521
|
+
CideEleJsonEditorComponent,
|
|
522
|
+
CideFormFieldErrorComponent
|
|
523
|
+
], template: "<div class=\"page-form-wrapper\">\n <div class=\"page-form-container\">\n <form class=\"page-form\" [formGroup]=\"pageForm\" [class.loading]=\"loading()\" (ngSubmit)=\"savePage()\">\n \n <!-- Header Section -->\n <div class=\"form-header\">\n <h2 class=\"form-title\">{{ isEditMode() ? 'Edit Page' : 'Create Page' }}</h2>\n <p class=\"form-subtitle\">\n {{ isEditMode() ? 'Update page information and configuration' : 'Create a new page with configuration' }}\n </p>\n </div>\n\n <!-- Success and Error Messages -->\n <div class=\"form-messages\">\n @if (success()) {\n <div class=\"alert alert-success\">\n <svg class=\"alert-icon\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 13l4 4L19 7\"></path>\n </svg>\n <span>{{ success() }}</span>\n </div>\n }\n @if (error()) {\n <div class=\"alert alert-error\">\n <svg class=\"alert-icon\" fill=\"none\" stroke=\"currentColor\" viewBox=\"0 0 24 24\">\n <path stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M6 18L18 6M6 6l12 12\"></path>\n </svg>\n <span>{{ error() }}</span>\n </div>\n }\n </div>\n\n <!-- Form Content -->\n <div class=\"form-content\">\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input \n id=\"sypg_title\"\n label=\"Page Title\" \n formControlName=\"sypg_title\"\n placeholder=\"Enter page title\"\n size=\"md\">\n </cide-ele-input>\n </div>\n \n <div class=\"form-field\">\n <cide-ele-input \n id=\"sypg_page_code\"\n label=\"Page Code\" \n formControlName=\"sypg_page_code\"\n placeholder=\"Enter page code (alphanumeric and underscore only)\"\n size=\"md\">\n </cide-ele-input>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-textarea \n id=\"sypg_desc\"\n label=\"Page Description\" \n formControlName=\"sypg_desc\"\n placeholder=\"Enter page description\"\n [rows]=\"3\"\n size=\"md\">\n </cide-ele-textarea>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-json-editor\n id=\"sypg_configuration\"\n label=\"Configuration JSON\"\n formControlName=\"sypg_configuration\"\n placeholder='{\"key\": \"value\"}'>\n </cide-ele-json-editor>\n </div>\n </div>\n\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"sypg_isactive\"\n type=\"checkbox\"\n formControlName=\"sypg_isactive\"\n label=\"Active Status\"\n size=\"sm\">\n </cide-ele-input>\n </div>\n </div>\n\n <!-- Menu Mapping Section (Only in Create Mode) -->\n @if (!isEditMode()) {\n <div class=\"form-row form-row-1\">\n <div class=\"form-field menu-mapping-section\">\n <div class=\"menu-mapping-header\">\n <div class=\"menu-mapping-toggle\">\n <input\n type=\"checkbox\"\n id=\"enable_menu_mapping\"\n [checked]=\"enableMenuMapping()\"\n (change)=\"toggleMenuMapping()\"\n class=\"menu-mapping-checkbox\">\n <label for=\"enable_menu_mapping\" class=\"menu-mapping-label-checkbox\">Map to Menu</label>\n </div>\n <span class=\"menu-mapping-hint\">Optionally map this page to a menu item during creation</span>\n </div>\n\n @if (enableMenuMapping()) {\n <div class=\"menu-mapping-content\">\n <!-- Menu Mapping Mode Selection -->\n <div class=\"menu-mapping-mode\">\n <label class=\"menu-mapping-label\">Mapping Option:</label>\n <div class=\"menu-mapping-options\">\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'none'\"\n (click)=\"onMenuMappingModeChange('none')\">\n Skip Mapping\n </button>\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'existing'\"\n (click)=\"onMenuMappingModeChange('existing')\">\n Map to Existing Menu\n </button>\n <button\n type=\"button\"\n class=\"menu-option-btn\"\n [class.active]=\"menuMappingMode() === 'new'\"\n (click)=\"onMenuMappingModeChange('new')\">\n Create New Menu\n </button>\n </div>\n </div>\n\n <!-- Existing Menu Selection -->\n @if (menuMappingMode() === 'existing') {\n <div class=\"menu-mapping-form\">\n <cide-ele-select\n label=\"Select Menu Item\"\n [options]=\"menuOptions()\"\n [loading]=\"menusLoading()\"\n placeholder=\"Choose a menu item to map this page to\"\n [searchable]=\"true\"\n size=\"md\"\n [ngModel]=\"selectedMenuId() ?? ''\"\n (ngModelChange)=\"onMenuSelectionChange($event)\">\n </cide-ele-select>\n <p class=\"menu-mapping-help\">\n This page will be added to the selected menu item's page list.\n </p>\n </div>\n }\n\n <!-- New Menu Creation Form -->\n @if (menuMappingMode() === 'new') {\n <div class=\"menu-mapping-form\">\n <form [formGroup]=\"newMenuForm\" class=\"new-menu-form\">\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_title\"\n label=\"Menu Title\"\n formControlName=\"syme_title\"\n placeholder=\"Enter menu title\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-select\n label=\"Menu Type\"\n formControlName=\"syme_type\"\n [options]=\"[\n { value: 'menu', label: 'Menu Item' },\n { value: 'section', label: 'Section' },\n { value: 'title', label: 'Title' }\n ]\"\n placeholder=\"Select menu type\"\n size=\"md\">\n </cide-ele-select>\n </div>\n </div>\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_path\"\n label=\"Menu Path\"\n formControlName=\"syme_path\"\n placeholder=\"e.g., /control-panel/page\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_icon\"\n label=\"Icon\"\n formControlName=\"syme_icon\"\n placeholder=\"e.g., dashboard, settings\"\n size=\"md\">\n </cide-ele-input>\n </div>\n </div>\n <div class=\"form-row form-row-1\">\n <div class=\"form-field\">\n <cide-ele-textarea\n id=\"syme_desc\"\n label=\"Menu Description\"\n formControlName=\"syme_desc\"\n placeholder=\"Enter menu description (optional)\"\n [rows]=\"2\"\n size=\"md\">\n </cide-ele-textarea>\n </div>\n </div>\n <div class=\"form-row form-row-2\">\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_order_by\"\n label=\"Order\"\n formControlName=\"syme_order_by\"\n type=\"number\"\n placeholder=\"Menu order\"\n size=\"md\">\n </cide-ele-input>\n </div>\n <div class=\"form-field\">\n <cide-ele-input\n id=\"syme_isactive\"\n type=\"checkbox\"\n formControlName=\"syme_isactive\"\n label=\"Active\"\n size=\"sm\">\n </cide-ele-input>\n </div>\n </div>\n </form>\n <p class=\"menu-mapping-help\">\n A new menu item will be created and this page will be automatically mapped to it.\n </p>\n </div>\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n\n <!-- Form Actions -->\n <div class=\"form-actions\">\n <div class=\"form-actions-content\">\n <!-- Error Message (Left Side) -->\n <div class=\"form-actions-error\">\n <cide-form-field-error [formGroup]=\"pageForm\"></cide-form-field-error>\n </div>\n \n <!-- Action Buttons (Right Side) -->\n <div class=\"form-actions-buttons\">\n @if (!isEditMode()) {\n <button cideEleButton\n type=\"button\" \n variant=\"secondary\" \n (click)=\"resetForm()\" \n leftIcon=\"refresh\"\n [disabled]=\"loading()\">\n Reset Form\n </button>\n }\n \n <button cideEleButton\n type=\"button\" \n variant=\"secondary\" \n (click)=\"cancelForm()\" \n leftIcon=\"close\"\n [disabled]=\"loading()\">\n Cancel\n </button>\n \n <button cideEleButton\n type=\"submit\" \n variant=\"primary\" \n [disabled]=\"loading() || !pageForm.valid\"\n [loading]=\"loading()\"\n leftIcon=\"save\">\n {{ isEditMode() ? 'Update Page' : 'Create Page' }}\n </button>\n </div>\n </div>\n </div>\n </form>\n </div>\n</div>\n", styles: [".page-form-wrapper{min-height:100vh;background-color:#f9fafb;padding:1.5rem;box-sizing:border-box}:host-context(.dark) .page-form-wrapper,:host-context([data-theme=dark]) .page-form-wrapper{background-color:#111827}@media (max-width: 768px){.page-form-wrapper{padding:1rem}}@media (max-width: 480px){.page-form-wrapper{padding:.75rem}}.page-form-container{max-width:1200px;margin:0 auto;width:100%}.page-form{background-color:#fff;border-radius:.5rem;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;border:1px solid #e5e7eb;overflow:hidden;display:flex;flex-direction:column}:host-context(.dark) .page-form,:host-context([data-theme=dark]) .page-form{background-color:#1f2937;border-color:#374151;box-shadow:0 1px 3px #0000004d,0 1px 2px #0003}.page-form.loading{opacity:.6;pointer-events:none}.form-header{padding:1.5rem 1.5rem 1rem;border-bottom:1px solid #e5e7eb;background-color:#fff}:host-context(.dark) .form-header,:host-context([data-theme=dark]) .form-header{background-color:#1f2937;border-bottom-color:#374151}.form-header .form-title{font-size:1.5rem;font-weight:700;margin:0 0 .5rem;color:#111827;line-height:1.2}:host-context(.dark) .form-header .form-title,:host-context([data-theme=dark]) .form-header .form-title{color:#f9fafb}.form-header .form-subtitle{font-size:.875rem;margin:0;font-weight:400;color:#6b7280;line-height:1.5}:host-context(.dark) .form-header .form-subtitle,:host-context([data-theme=dark]) .form-header .form-subtitle{color:#9ca3af}@media (max-width: 768px){.form-header{padding:1.25rem 1rem .75rem}.form-header .form-title{font-size:1.25rem}.form-header .form-subtitle{font-size:.8125rem}}.form-messages{padding:0 1.5rem;margin-top:1rem}@media (max-width: 768px){.form-messages{padding:0 1rem}}.alert{display:flex;align-items:center;gap:.75rem;padding:.875rem 1rem;margin-bottom:1rem;border-radius:.375rem;font-weight:500;font-size:.875rem;border-left:3px solid}.alert .alert-icon{width:1.25rem;height:1.25rem;flex-shrink:0}.alert.alert-success{background-color:#d1fae5;border-left-color:#10b981;color:#065f46}:host-context(.dark) .alert.alert-success,:host-context([data-theme=dark]) .alert.alert-success{background-color:#10b98133;border-left-color:#10b981;color:#6ee7b7}.alert.alert-error{background-color:#fee2e2;border-left-color:#ef4444;color:#991b1b}:host-context(.dark) .alert.alert-error,:host-context([data-theme=dark]) .alert.alert-error{background-color:#ef444433;border-left-color:#ef4444;color:#fca5a5}.form-content{padding:1.5rem;flex:1}@media (max-width: 768px){.form-content{padding:1rem}}@media (max-width: 480px){.form-content{padding:.75rem}}.form-row{display:grid;gap:1rem;margin-bottom:1rem}.form-row:last-child{margin-bottom:0}.form-row.form-row-1{grid-template-columns:1fr}.form-row.form-row-2{grid-template-columns:repeat(2,1fr)}@media (max-width: 768px){.form-row.form-row-2{grid-template-columns:1fr}}.form-row.form-row-3{grid-template-columns:repeat(3,1fr)}@media (max-width: 1024px){.form-row.form-row-3{grid-template-columns:repeat(2,1fr)}}@media (max-width: 768px){.form-row.form-row-3{grid-template-columns:1fr}}.form-row.form-row-4{grid-template-columns:repeat(4,1fr)}@media (max-width: 1024px){.form-row.form-row-4{grid-template-columns:repeat(2,1fr)}}@media (max-width: 768px){.form-row.form-row-4{grid-template-columns:1fr}}.form-field{display:flex;flex-direction:column}.form-actions{padding:1.25rem 1.5rem;border-top:1px solid #e5e7eb;background-color:#fff;margin-top:auto}:host-context(.dark) .form-actions,:host-context([data-theme=dark]) .form-actions{background-color:#1f2937;border-top-color:#374151}@media (max-width: 768px){.form-actions{padding:1rem}}@media (max-width: 480px){.form-actions{padding:.75rem}}.form-actions-content{display:flex;justify-content:space-between;align-items:center;gap:1rem;width:100%;flex-wrap:wrap}@media (max-width: 768px){.form-actions-content{flex-direction:column;align-items:stretch}}.form-actions-error{flex:1;min-width:0;display:flex;align-items:center}@media (max-width: 768px){.form-actions-error{width:100%;margin-bottom:.75rem}}.form-actions-buttons{display:flex;gap:.75rem;align-items:center;flex-shrink:0}@media (max-width: 768px){.form-actions-buttons{width:100%;justify-content:stretch}.form-actions-buttons button{flex:1;min-width:0}}@media (max-width: 480px){.form-actions-buttons{flex-direction:column}.form-actions-buttons button{width:100%}}cide-ele-input,cide-ele-textarea,cide-ele-json-editor,cide-ele-select{width:100%}cide-ele-input:focus-within,cide-ele-textarea:focus-within,cide-ele-json-editor:focus-within,cide-ele-select:focus-within{outline:none}.menu-mapping-section{border:1px solid #e5e7eb;border-radius:.5rem;padding:1rem;background-color:#f9fafb;margin-top:1rem}:host-context(.dark) .menu-mapping-section,:host-context([data-theme=dark]) .menu-mapping-section{background-color:#1f2937;border-color:#374151}.menu-mapping-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem;gap:1rem}@media (max-width: 768px){.menu-mapping-header{flex-direction:column;align-items:flex-start}}.menu-mapping-toggle{display:flex;align-items:center;gap:.5rem}.menu-mapping-checkbox{width:1rem;height:1rem;cursor:pointer}.menu-mapping-label-checkbox{font-weight:500;font-size:.875rem;color:#374151;cursor:pointer}:host-context(.dark) .menu-mapping-label-checkbox,:host-context([data-theme=dark]) .menu-mapping-label-checkbox{color:#d1d5db}.menu-mapping-hint{font-size:.75rem;color:#6b7280;font-style:italic}:host-context(.dark) .menu-mapping-hint,:host-context([data-theme=dark]) .menu-mapping-hint{color:#9ca3af}.menu-mapping-content{margin-top:1rem;padding-top:1rem;border-top:1px solid #e5e7eb}:host-context(.dark) .menu-mapping-content,:host-context([data-theme=dark]) .menu-mapping-content{border-top-color:#374151}.menu-mapping-mode{margin-bottom:1rem}.menu-mapping-label{display:block;font-size:.875rem;font-weight:500;color:#374151;margin-bottom:.5rem}:host-context(.dark) .menu-mapping-label,:host-context([data-theme=dark]) .menu-mapping-label{color:#d1d5db}.menu-mapping-options{display:flex;gap:.5rem;flex-wrap:wrap}.menu-option-btn{padding:.5rem 1rem;border:1px solid #d1d5db;border-radius:.375rem;background-color:#fff;color:#374151;font-size:.875rem;font-weight:500;cursor:pointer;transition:all .2s}:host-context(.dark) .menu-option-btn,:host-context([data-theme=dark]) .menu-option-btn{background-color:#374151;border-color:#4b5563;color:#d1d5db}.menu-option-btn:hover{background-color:#f3f4f6;border-color:#9ca3af}:host-context(.dark) .menu-option-btn:hover,:host-context([data-theme=dark]) .menu-option-btn:hover{background-color:#4b5563;border-color:#6b7280}.menu-option-btn.active{background-color:#3b82f6;border-color:#3b82f6;color:#fff}:host-context(.dark) .menu-option-btn.active,:host-context([data-theme=dark]) .menu-option-btn.active{background-color:#2563eb;border-color:#2563eb}.menu-mapping-form{margin-top:1rem;padding:1rem;background-color:#fff;border-radius:.375rem;border:1px solid #e5e7eb}:host-context(.dark) .menu-mapping-form,:host-context([data-theme=dark]) .menu-mapping-form{background-color:#111827;border-color:#374151}.new-menu-form .form-row{margin-bottom:1rem}.new-menu-form .form-row:last-child{margin-bottom:0}.menu-mapping-help{margin-top:.75rem;font-size:.75rem;color:#6b7280;font-style:italic}:host-context(.dark) .menu-mapping-help,:host-context([data-theme=dark]) .menu-mapping-help{color:#9ca3af}@media (max-width: 480px){.page-form-wrapper{padding:.5rem}.form-header{padding:1rem .75rem .75rem}.form-content,.form-actions{padding:.75rem}.menu-mapping-options{flex-direction:column}.menu-mapping-options .menu-option-btn{width:100%}}\n"] }]
|
|
524
|
+
}], ctorParameters: () => [] });
|
|
525
|
+
|
|
526
|
+
export { CideCorePageFormComponent };
|
|
527
|
+
//# sourceMappingURL=cloud-ide-core-page-form.component-C3xTQLI3.mjs.map
|