cloud-ide-academics 0.0.28 → 0.0.30

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.
Files changed (26) hide show
  1. package/fesm2022/cloud-ide-academics-class-program-term-create.component-B-7JRpVE.mjs +1196 -0
  2. package/fesm2022/cloud-ide-academics-class-program-term-create.component-B-7JRpVE.mjs.map +1 -0
  3. package/fesm2022/{cloud-ide-academics-class-program-term-list.component-CP2vlRBP.mjs → cloud-ide-academics-class-program-term-list.component-DObKkh-y.mjs} +186 -48
  4. package/fesm2022/cloud-ide-academics-class-program-term-list.component-DObKkh-y.mjs.map +1 -0
  5. package/fesm2022/cloud-ide-academics-cloud-ide-academics-FwQEJSnJ.mjs +6127 -0
  6. package/fesm2022/cloud-ide-academics-cloud-ide-academics-FwQEJSnJ.mjs.map +1 -0
  7. package/fesm2022/{cloud-ide-academics-program-class-create.component-KijRP6Nl.mjs → cloud-ide-academics-program-class-create.component-x0rh1ESo.mjs} +45 -23
  8. package/fesm2022/cloud-ide-academics-program-class-create.component-x0rh1ESo.mjs.map +1 -0
  9. package/fesm2022/{cloud-ide-academics-program-class-list.component-B5cy2Gpk.mjs → cloud-ide-academics-program-class-list.component-CkzH8u8u.mjs} +10 -9
  10. package/fesm2022/cloud-ide-academics-program-class-list.component-CkzH8u8u.mjs.map +1 -0
  11. package/fesm2022/cloud-ide-academics.mjs +1 -1
  12. package/index.d.ts +500 -18
  13. package/package.json +1 -1
  14. package/fesm2022/cloud-ide-academics-class-program-term-create.component-BRbHViJN.mjs +0 -659
  15. package/fesm2022/cloud-ide-academics-class-program-term-create.component-BRbHViJN.mjs.map +0 -1
  16. package/fesm2022/cloud-ide-academics-class-program-term-list.component-CP2vlRBP.mjs.map +0 -1
  17. package/fesm2022/cloud-ide-academics-class-program-term.service-BW4PJQEM.mjs +0 -111
  18. package/fesm2022/cloud-ide-academics-class-program-term.service-BW4PJQEM.mjs.map +0 -1
  19. package/fesm2022/cloud-ide-academics-cloud-ide-academics-g9qZGJtG.mjs +0 -3102
  20. package/fesm2022/cloud-ide-academics-cloud-ide-academics-g9qZGJtG.mjs.map +0 -1
  21. package/fesm2022/cloud-ide-academics-program-class-create.component-KijRP6Nl.mjs.map +0 -1
  22. package/fesm2022/cloud-ide-academics-program-class-list.component-B5cy2Gpk.mjs.map +0 -1
  23. package/fesm2022/cloud-ide-academics-program-term-section-create.component-DHrTb-XI.mjs +0 -248
  24. package/fesm2022/cloud-ide-academics-program-term-section-create.component-DHrTb-XI.mjs.map +0 -1
  25. package/fesm2022/cloud-ide-academics-program-term-section-list.component-ktIAxvxR.mjs +0 -495
  26. package/fesm2022/cloud-ide-academics-program-term-section-list.component-ktIAxvxR.mjs.map +0 -1
@@ -1,659 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, DestroyRef, signal, Component } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import * as i1 from '@angular/forms';
5
- import { FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
6
- import { Router, ActivatedRoute } from '@angular/router';
7
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
- import { NotificationService, ConfirmationService, CideInputComponent, CideTextareaComponent, CideEleButtonComponent, CideIconComponent, CideSelectComponent } from 'cloud-ide-element';
9
- import { AppStateHelperService, CideLytSharedWrapperComponent } from 'cloud-ide-layout';
10
- import { ENTITY_SERVICE_TOKEN } from 'cloud-ide-shared';
11
- import { b as CideLytClassProgramBranchService, C as CideLytProgramClassService } from './cloud-ide-academics-cloud-ide-academics-g9qZGJtG.mjs';
12
- import { C as CideLytClassProgramTermService } from './cloud-ide-academics-class-program-term.service-BW4PJQEM.mjs';
13
- import { generateObjectFromString } from 'cloud-ide-lms-model';
14
-
15
- class ClassProgramTermCreateComponent {
16
- // Dependency injection
17
- destroyRef = inject(DestroyRef);
18
- fb = inject(FormBuilder);
19
- entityService = inject(ENTITY_SERVICE_TOKEN);
20
- router = inject(Router);
21
- route = inject(ActivatedRoute);
22
- appState = inject(AppStateHelperService);
23
- notificationService = inject(NotificationService);
24
- confirmationService = inject(ConfirmationService);
25
- classProgramBranchService = inject(CideLytClassProgramBranchService);
26
- programClassService = inject(CideLytProgramClassService);
27
- classProgramTermService = inject(CideLytClassProgramTermService);
28
- classProgramTermForm;
29
- loading = signal(false, ...(ngDevMode ? [{ debugName: "loading" }] : []));
30
- error = signal(null, ...(ngDevMode ? [{ debugName: "error" }] : []));
31
- // Class program term information from route
32
- classProgramTermId = signal('', ...(ngDevMode ? [{ debugName: "classProgramTermId" }] : []));
33
- isEditMode = signal(false, ...(ngDevMode ? [{ debugName: "isEditMode" }] : []));
34
- isViewMode = signal(false, ...(ngDevMode ? [{ debugName: "isViewMode" }] : []));
35
- // Data signals
36
- programClasses = signal([], ...(ngDevMode ? [{ debugName: "programClasses" }] : []));
37
- classProgramBranches = signal([], ...(ngDevMode ? [{ debugName: "classProgramBranches" }] : []));
38
- // Options for dropdowns
39
- programClassOptions = signal([], ...(ngDevMode ? [{ debugName: "programClassOptions" }] : []));
40
- branchOptions = signal([], ...(ngDevMode ? [{ debugName: "branchOptions" }] : []));
41
- parentTermOptions = signal([], ...(ngDevMode ? [{ debugName: "parentTermOptions" }] : []));
42
- // Route parameters
43
- acabrnId = signal(null, ...(ngDevMode ? [{ debugName: "acabrnId" }] : []));
44
- acacpmId = signal(null, ...(ngDevMode ? [{ debugName: "acacpmId" }] : []));
45
- parentTermId = signal(null, ...(ngDevMode ? [{ debugName: "parentTermId" }] : []));
46
- // Signal for breadcrumb data that will be passed to shared wrapper
47
- breadcrumbData = signal([], ...(ngDevMode ? [{ debugName: "breadcrumbData" }] : []));
48
- // Date constraints
49
- endDateMinDate = signal('', ...(ngDevMode ? [{ debugName: "endDateMinDate" }] : []));
50
- constructor() {
51
- this.classProgramTermForm = this.fb.group({
52
- // Basic Class Program Term Information
53
- acapt_code: ['', [Validators.required]],
54
- acapt_name: ['', [Validators.required]],
55
- acapt_description: [''],
56
- acapt_class_program_id_acacpm: ['', [Validators.required]],
57
- acapt_class_program_branch_id_acabrn: ['', [Validators.required]],
58
- acapt_parent_class_prog_term_acapt: [''],
59
- acapt_start_date: [''],
60
- acapt_end_date: [''],
61
- acapt_isactive: [true],
62
- acapt_islocked: [false]
63
- });
64
- }
65
- ngOnInit() {
66
- this.initializeComponent();
67
- this.setupFormSubscriptions();
68
- this.updateBreadcrumbData();
69
- }
70
- /**
71
- * Update breadcrumb data based on mode
72
- */
73
- updateBreadcrumbData() {
74
- const additionalItems = [];
75
- if (this.isViewMode()) {
76
- additionalItems.push({
77
- id: 'view',
78
- label: 'View',
79
- icon: 'visibility',
80
- url: undefined
81
- });
82
- }
83
- else if (this.isEditMode()) {
84
- additionalItems.push({
85
- id: 'edit',
86
- label: 'Edit',
87
- icon: 'edit',
88
- url: undefined
89
- });
90
- }
91
- else {
92
- additionalItems.push({
93
- id: 'create',
94
- label: 'Create',
95
- icon: 'add',
96
- url: undefined
97
- });
98
- }
99
- this.breadcrumbData.set(additionalItems);
100
- }
101
- /**
102
- * Setup form subscriptions for dependent dropdowns
103
- */
104
- setupFormSubscriptions() {
105
- // Watch for program class changes to filter branches
106
- this.classProgramTermForm.get('acapt_class_program_id_acacpm')?.valueChanges
107
- .pipe(takeUntilDestroyed(this.destroyRef))
108
- .subscribe(programClassId => {
109
- if (programClassId) {
110
- this.loadBranchesForProgramClass(programClassId);
111
- // Clear branch selection when program class changes
112
- this.classProgramTermForm.patchValue({
113
- acapt_class_program_branch_id_acabrn: ''
114
- });
115
- }
116
- else {
117
- this.branchOptions.set([]);
118
- }
119
- });
120
- // Watch for branch changes to determine parent term
121
- this.classProgramTermForm.get('acapt_class_program_branch_id_acabrn')?.valueChanges
122
- .pipe(takeUntilDestroyed(this.destroyRef))
123
- .subscribe(branchId => {
124
- if (branchId) {
125
- this.determineParentTerm(branchId);
126
- }
127
- else {
128
- // Clear parent term when branch is cleared
129
- this.classProgramTermForm.patchValue({
130
- acapt_parent_class_prog_term_acapt: ''
131
- });
132
- }
133
- });
134
- // Watch for parent term changes to set date constraints
135
- this.classProgramTermForm.get('acapt_parent_class_prog_term_acapt')?.valueChanges
136
- .pipe(takeUntilDestroyed(this.destroyRef))
137
- .subscribe(parentTermId => {
138
- this.loadParentTermDetails(parentTermId);
139
- });
140
- // Watch for start date changes to set minimum date for end date
141
- this.classProgramTermForm.get('acapt_start_date')?.valueChanges
142
- .pipe(takeUntilDestroyed(this.destroyRef))
143
- .subscribe(startDate => {
144
- this.updateEndDateMinDate(startDate);
145
- });
146
- }
147
- /**
148
- * Initialize component
149
- */
150
- initializeComponent() {
151
- // Check route parameters to determine mode
152
- this.checkRouteParams();
153
- const url = this.router.url;
154
- const queryParams = this.route.snapshot.queryParams;
155
- if (url.includes('/view/')) {
156
- this.isViewMode.set(true);
157
- this.loadClassProgramTermForView(queryParams);
158
- }
159
- else if (url.includes('/edit/')) {
160
- this.isEditMode.set(true);
161
- this.loadClassProgramTermForEdit(queryParams);
162
- }
163
- else {
164
- // Create mode
165
- this.isEditMode.set(false);
166
- this.isViewMode.set(false);
167
- }
168
- // Update breadcrumb after mode is determined
169
- this.updateBreadcrumbData();
170
- // Load dropdown options
171
- this.loadDropdownOptions();
172
- // Set parent term if provided from route (for child term creation)
173
- const parentId = this.parentTermId();
174
- if (parentId && !this.isEditMode() && !this.isViewMode()) {
175
- this.classProgramTermForm.patchValue({
176
- acapt_parent_class_prog_term_acapt: parentId
177
- });
178
- }
179
- }
180
- /**
181
- * Check route parameters for acabrn_id and acacpm_id
182
- */
183
- checkRouteParams() {
184
- this.route.params.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(params => {
185
- const queryParams = params['query'];
186
- console.log('🏢 Route params:', params, 'queryParams:', queryParams);
187
- if (queryParams) {
188
- // Query parameters passed (following page-controls pattern)
189
- const queryData = generateObjectFromString(queryParams);
190
- console.log('🏢 Class Program Term Create params from route:', queryData);
191
- if (queryData?.acabrn_id) {
192
- this.acabrnId.set(queryData.acabrn_id);
193
- console.log('🏢 Branch ID from route:', queryData.acabrn_id);
194
- }
195
- if (queryData?.acacpm_id) {
196
- this.acacpmId.set(queryData.acacpm_id);
197
- console.log('🏢 Class Program ID from route:', queryData.acacpm_id);
198
- }
199
- if (queryData?.acapt_parent_id || queryData?.acapt_id) {
200
- const parentId = (queryData.acapt_parent_id || queryData.acapt_id);
201
- this.parentTermId.set(parentId);
202
- console.log('🏢 Parent Term ID from route:', parentId);
203
- }
204
- }
205
- });
206
- }
207
- /**
208
- * Load class program term for viewing
209
- */
210
- loadClassProgramTermForView(queryParams) {
211
- // Implementation for view mode
212
- this.classProgramTermForm.disable();
213
- }
214
- /**
215
- * Load class program term for editing
216
- */
217
- loadClassProgramTermForEdit(queryParams) {
218
- // Implementation for edit mode
219
- }
220
- /**
221
- * Load dropdown options
222
- */
223
- loadDropdownOptions() {
224
- // Load program classes
225
- this.loadProgramClasses();
226
- // Load branches
227
- this.loadClassProgramBranches();
228
- }
229
- /**
230
- * Load program classes
231
- */
232
- loadProgramClasses() {
233
- this.programClassService.getProgramClassList({ pagination: false })
234
- .pipe(takeUntilDestroyed(this.destroyRef))
235
- .subscribe({
236
- next: (response) => {
237
- console.log('✅ Program classes loaded:', response);
238
- if (response?.success && response.data) {
239
- this.programClassOptions.set(response.data);
240
- // Pre-select program class if provided in route
241
- const acacpmId = this.acacpmId();
242
- if (acacpmId) {
243
- this.classProgramTermForm.patchValue({
244
- acapt_class_program_id_acacpm: acacpmId
245
- });
246
- }
247
- }
248
- else {
249
- console.warn('⚠️ No program class data received');
250
- this.programClassOptions.set([]);
251
- }
252
- },
253
- error: (error) => {
254
- console.error('❌ Error loading program classes:', error);
255
- this.programClassOptions.set([]);
256
- }
257
- });
258
- }
259
- /**
260
- * Load class program branches
261
- */
262
- loadClassProgramBranches() {
263
- const acacpmId = this.acacpmId();
264
- if (acacpmId) {
265
- this.loadBranchesForProgramClass(acacpmId);
266
- }
267
- }
268
- /**
269
- * Load branches for a specific program class
270
- */
271
- loadBranchesForProgramClass(programClassId) {
272
- const payload = {
273
- pagination: false,
274
- pageIndex: 0,
275
- pageSize: 100,
276
- acabrn_class_program_id_acacpm: programClassId
277
- };
278
- this.classProgramBranchService.getClassProgramBranchList(payload)
279
- .pipe(takeUntilDestroyed(this.destroyRef))
280
- .subscribe({
281
- next: (response) => {
282
- console.log('✅ Class program branches loaded for program class:', programClassId, response);
283
- if (response?.success && response.data) {
284
- this.branchOptions.set(response.data);
285
- // Pre-select branch if provided in route and not already set
286
- const acabrnId = this.acabrnId();
287
- const currentBranchId = this.classProgramTermForm.get('acapt_class_program_branch_id_acabrn')?.value;
288
- if (acabrnId && !currentBranchId) {
289
- this.classProgramTermForm.patchValue({
290
- acapt_class_program_branch_id_acabrn: acabrnId
291
- });
292
- }
293
- }
294
- else {
295
- console.warn('⚠️ No branch data received');
296
- this.branchOptions.set([]);
297
- }
298
- },
299
- error: (error) => {
300
- console.error('❌ Error loading branches:', error);
301
- this.branchOptions.set([]);
302
- }
303
- });
304
- }
305
- /**
306
- * Determine parent term based on selected branch
307
- * This method will be called internally when branch is selected
308
- */
309
- determineParentTerm(branchId) {
310
- // Find the selected branch from the options
311
- const selectedBranch = this.branchOptions().find(branch => branch._id === branchId);
312
- if (selectedBranch) {
313
- console.log('🏢 Determining parent term for branch:', selectedBranch.acabrn_name);
314
- // Load existing terms for this branch to find potential parent terms
315
- this.loadParentTermsForBranch(branchId);
316
- }
317
- }
318
- /**
319
- * Load parent terms for a specific branch
320
- */
321
- loadParentTermsForBranch(branchId) {
322
- // TODO: Implement API call to get existing terms for the branch
323
- // This will help determine which terms can be parent terms
324
- console.log('🏢 Loading parent terms for branch:', branchId);
325
- // Example implementation - replace with actual API call
326
- // const payload = {
327
- // acabrn_id: branchId,
328
- // pagination: false
329
- // };
330
- // this.classProgramTermService.getClassProgramTermList(payload)
331
- // .pipe(takeUntilDestroyed(this.destroyRef))
332
- // .subscribe({
333
- // next: (response) => {
334
- // if (response?.success && response.data) {
335
- // // Filter terms that can be parent terms (e.g., terms without parent)
336
- // const parentTerms = response.data.filter(term => !term.acapt_parent_class_prog_term_acapt);
337
- // this.parentTermOptions.set(parentTerms);
338
- // }
339
- // },
340
- // error: (error) => {
341
- // console.error('❌ Error loading parent terms:', error);
342
- // this.parentTermOptions.set([]);
343
- // }
344
- // });
345
- // For now, set empty array
346
- this.parentTermOptions.set([]);
347
- }
348
- /**
349
- * Load parent term details for date validation
350
- * This method will be called when a parent term is selected
351
- */
352
- loadParentTermDetails(parentTermId) {
353
- if (!parentTermId) {
354
- // Clear date constraints when no parent is selected
355
- this.clearDateConstraints();
356
- return;
357
- }
358
- // TODO: Implement API call to get parent term details
359
- // For now, we'll use mock data or implement based on your API
360
- console.log('🏢 Loading parent term details for ID:', parentTermId);
361
- // Example implementation - replace with actual API call
362
- // this.classProgramTermService.getClassProgramTermById({ _id: parentTermId })
363
- // .pipe(takeUntilDestroyed(this.destroyRef))
364
- // .subscribe({
365
- // next: (response) => {
366
- // if (response?.success && response.data) {
367
- // const parentTerm = response.data;
368
- // this.setDateConstraints(parentTerm.acapt_start_date, parentTerm.acapt_end_date);
369
- // }
370
- // },
371
- // error: (error) => {
372
- // console.error('❌ Error loading parent term details:', error);
373
- // }
374
- // });
375
- }
376
- /**
377
- * Set date constraints based on parent term dates
378
- */
379
- setDateConstraints(parentStartDate, parentEndDate) {
380
- console.log('🏢 Setting date constraints:', { parentStartDate, parentEndDate });
381
- // Update form validation to ensure child dates are within parent range
382
- const startDateControl = this.classProgramTermForm.get('acapt_start_date');
383
- const endDateControl = this.classProgramTermForm.get('acapt_end_date');
384
- if (startDateControl && endDateControl) {
385
- // Add custom validators for date range
386
- startDateControl.setValidators([
387
- this.dateRangeValidator(parentStartDate, parentEndDate, 'start')
388
- ]);
389
- endDateControl.setValidators([
390
- this.dateRangeValidator(parentStartDate, parentEndDate, 'end')
391
- ]);
392
- // Update validation
393
- startDateControl.updateValueAndValidity();
394
- endDateControl.updateValueAndValidity();
395
- }
396
- }
397
- /**
398
- * Clear date constraints when no parent is selected
399
- */
400
- clearDateConstraints() {
401
- const startDateControl = this.classProgramTermForm.get('acapt_start_date');
402
- const endDateControl = this.classProgramTermForm.get('acapt_end_date');
403
- if (startDateControl && endDateControl) {
404
- // Remove custom validators
405
- startDateControl.clearValidators();
406
- endDateControl.clearValidators();
407
- // Update validation
408
- startDateControl.updateValueAndValidity();
409
- endDateControl.updateValueAndValidity();
410
- }
411
- }
412
- /**
413
- * Custom validator for date range constraints
414
- */
415
- dateRangeValidator(parentStartDate, parentEndDate, dateType) {
416
- return (control) => {
417
- if (!control.value || !parentStartDate || !parentEndDate) {
418
- return null; // No validation if no date or parent dates
419
- }
420
- const selectedDate = new Date(control.value);
421
- const parentStart = new Date(parentStartDate);
422
- const parentEnd = new Date(parentEndDate);
423
- if (dateType === 'start') {
424
- // Start date should be >= parent start date and < parent end date
425
- if (selectedDate < parentStart || selectedDate >= parentEnd) {
426
- return {
427
- dateRangeError: {
428
- message: `Start date must be between ${parentStartDate} and ${parentEndDate}`
429
- }
430
- };
431
- }
432
- }
433
- else if (dateType === 'end') {
434
- // End date should be > parent start date and <= parent end date
435
- if (selectedDate <= parentStart || selectedDate > parentEnd) {
436
- return {
437
- dateRangeError: {
438
- message: `End date must be between ${parentStartDate} and ${parentEndDate}`
439
- }
440
- };
441
- }
442
- }
443
- return null; // Valid
444
- };
445
- }
446
- /**
447
- * Update minimum date for end date based on start date
448
- */
449
- updateEndDateMinDate(startDate) {
450
- if (startDate) {
451
- // Set the minimum date for end date to be the start date
452
- this.endDateMinDate.set(startDate);
453
- // If end date is already set and is before the new start date, clear it
454
- const endDate = this.classProgramTermForm.get('acapt_end_date')?.value;
455
- if (endDate && endDate < startDate) {
456
- this.classProgramTermForm.patchValue({
457
- acapt_end_date: ''
458
- });
459
- }
460
- console.log('🏢 Updated end date minimum date to:', startDate);
461
- }
462
- else {
463
- // Clear minimum date constraint if no start date
464
- this.endDateMinDate.set('');
465
- }
466
- }
467
- onSubmit() {
468
- if (this.isViewMode()) {
469
- this.router.navigate(['/control-panel/class-program-term']);
470
- return;
471
- }
472
- if (this.classProgramTermForm.invalid) {
473
- this.notificationService.error('Please fill in all required fields correctly.');
474
- this.markFormGroupTouched();
475
- return;
476
- }
477
- this.loading.set(true);
478
- this.error.set(null);
479
- const formData = this.classProgramTermForm.value;
480
- console.log('Class Program Term Form Data:', formData);
481
- // Prepare payload for API call
482
- const payload = {
483
- acapt_code: formData.acapt_code,
484
- acapt_name: formData.acapt_name,
485
- acapt_class_program_id_acacpm: formData.acapt_class_program_id_acacpm,
486
- acapt_class_prg_branch_acabrn: formData.acapt_class_program_branch_id_acabrn,
487
- acapt_parent_class_prog_term_acapt: formData.acapt_parent_class_prog_term_acapt || null,
488
- acapt_start_date: formData.acapt_start_date,
489
- acapt_end_date: formData.acapt_end_date,
490
- acapt_isactive: formData.acapt_isactive,
491
- acapt_islocked: formData.acapt_islocked
492
- };
493
- // Add _id for edit mode
494
- if (this.isEditMode() && this.classProgramTermId()) {
495
- payload._id = this.classProgramTermId();
496
- }
497
- console.log('API Payload:', payload);
498
- // Make API call
499
- this.classProgramTermService.saveClassProgramTerm(payload)
500
- .pipe(takeUntilDestroyed(this.destroyRef))
501
- .subscribe({
502
- next: (response) => {
503
- console.log('✅ Class program term saved successfully:', response);
504
- if (response?.success) {
505
- const action = this.isEditMode() ? 'updated' : 'created';
506
- this.notificationService.success(`Class program term has been ${action} successfully.`);
507
- if (this.isEditMode()) {
508
- // Navigate back to list on edit mode
509
- this.router.navigate(['/control-panel/class-program-term']);
510
- }
511
- else {
512
- // In create mode, reset only Term Code, Term Name, and Description
513
- this.resetFormFields();
514
- }
515
- }
516
- else {
517
- this.error.set(response?.message || 'Failed to save class program term');
518
- this.notificationService.error(response?.message || 'Failed to save class program term');
519
- }
520
- this.loading.set(false);
521
- },
522
- error: (error) => {
523
- console.error('❌ Error saving class program term:', error);
524
- this.error.set('Failed to save class program term');
525
- this.notificationService.error('Failed to save class program term. Please try again.');
526
- this.loading.set(false);
527
- }
528
- });
529
- }
530
- /**
531
- * Mark all form controls as touched to trigger validation display
532
- */
533
- markFormGroupTouched() {
534
- Object.keys(this.classProgramTermForm.controls).forEach(key => {
535
- const control = this.classProgramTermForm.get(key);
536
- control?.markAsTouched();
537
- });
538
- }
539
- resetForm() {
540
- this.classProgramTermForm.reset({
541
- acapt_isactive: true,
542
- acapt_islocked: false
543
- });
544
- // Clear options when form is reset
545
- this.branchOptions.set([]);
546
- this.parentTermOptions.set([]);
547
- // Clear date constraints
548
- this.clearDateConstraints();
549
- this.endDateMinDate.set('');
550
- }
551
- /**
552
- * Reset only Term Code, Term Name, and Description fields after successful save
553
- */
554
- resetFormFields() {
555
- // Get current values to preserve
556
- const currentProgramClass = this.classProgramTermForm.get('acapt_class_program_id_acacpm')?.value;
557
- const currentBranch = this.classProgramTermForm.get('acapt_class_program_branch_id_acabrn')?.value;
558
- const currentStartDate = this.classProgramTermForm.get('acapt_start_date')?.value;
559
- const currentEndDate = this.classProgramTermForm.get('acapt_end_date')?.value;
560
- const currentIsActive = this.classProgramTermForm.get('acapt_isactive')?.value;
561
- const currentIsLocked = this.classProgramTermForm.get('acapt_islocked')?.value;
562
- // Reset only the specified fields
563
- this.classProgramTermForm.patchValue({
564
- acapt_code: '',
565
- acapt_name: '',
566
- acapt_description: '',
567
- // Preserve other fields
568
- acapt_class_program_id_acacpm: currentProgramClass,
569
- acapt_class_program_branch_id_acabrn: currentBranch,
570
- acapt_start_date: currentStartDate,
571
- acapt_end_date: currentEndDate,
572
- acapt_isactive: currentIsActive,
573
- acapt_islocked: currentIsLocked
574
- });
575
- // Clear validation errors for reset fields
576
- this.classProgramTermForm.get('acapt_code')?.setErrors(null);
577
- this.classProgramTermForm.get('acapt_name')?.setErrors(null);
578
- this.classProgramTermForm.get('acapt_description')?.setErrors(null);
579
- }
580
- /**
581
- * Go back to class program term list
582
- */
583
- goBackToClassProgramTermList() {
584
- this.router.navigate(['/control-panel/class-program-term']);
585
- }
586
- /**
587
- * Cancel form and navigate back to listing page
588
- */
589
- cancelForm() {
590
- this.goBackToClassProgramTermList();
591
- }
592
- /**
593
- * Get page title based on mode
594
- */
595
- getPageTitle() {
596
- if (this.isViewMode())
597
- return 'View Class Program Term';
598
- return this.isEditMode() ? 'Edit Class Program Term' : 'Create New Class Program Term';
599
- }
600
- /**
601
- * Handle Active card click to toggle checkbox
602
- */
603
- onActiveCardClick() {
604
- if (this.isViewMode()) {
605
- return; // Don't allow changes in view mode
606
- }
607
- const currentValue = this.classProgramTermForm.get('acapt_isactive')?.value;
608
- this.classProgramTermForm.patchValue({
609
- acapt_isactive: !currentValue
610
- });
611
- }
612
- /**
613
- * Handle Locked card click to toggle checkbox
614
- */
615
- onLockedCardClick() {
616
- if (this.isViewMode()) {
617
- return; // Don't allow changes in view mode
618
- }
619
- const currentValue = this.classProgramTermForm.get('acapt_islocked')?.value;
620
- this.classProgramTermForm.patchValue({
621
- acapt_islocked: !currentValue
622
- });
623
- }
624
- /**
625
- * Cleanup when component is destroyed
626
- */
627
- ngOnDestroy() {
628
- console.log('🧹 ClassProgramTermCreateComponent: Cleaning up component state');
629
- // Reset all signals to their initial state
630
- this.loading.set(false);
631
- this.error.set(null);
632
- this.classProgramTermId.set('');
633
- this.isEditMode.set(false);
634
- this.programClassOptions.set([]);
635
- this.branchOptions.set([]);
636
- this.parentTermOptions.set([]);
637
- // Reset form to initial state
638
- this.resetForm();
639
- console.log('🧹 ClassProgramTermCreateComponent: Component state cleaned up');
640
- }
641
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ClassProgramTermCreateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
642
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.1.7", type: ClassProgramTermCreateComponent, isStandalone: true, selector: "cide-academics-class-program-term-create", ngImport: i0, template: "<!-- \n CLASS PROGRAM TERM MASTER FORM\n \n Enterprise-Level Styling with Tailwind CSS\n Features: Responsive grids, proper typography, enhanced user experience\n-->\n\n<cide-lyt-shared-wrapper [shared_wrapper_setup_param]=\"{ sypg_page_code: 'class_program_term' }\"\n [breadcrumb_data]=\"breadcrumbData()\">\n \n <form class=\"tw-w-full tw-table tw-h-full tw-bg-transparent\" [formGroup]=\"classProgramTermForm\"\n [class.tw-opacity-60]=\"loading()\" (ngSubmit)=\"onSubmit()\">\n\n <!-- Form Content -->\n <div class=\"tw-table-row\">\n <div class=\"tw-table-cell tw-w-full tw-px-6 tw-py-6\">\n <div class=\"tw-transition-opacity tw-duration-300\" [class.tw-opacity-60]=\"loading()\">\n <!-- Class Program Term Information -->\n <div class=\"tw-space-y-6\">\n <!-- Program Class and Branch at the top -->\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-3 tw-gap-6\">\n <div class=\"tw-space-y-2\">\n <label class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Program Class *</label>\n <cide-ele-select \n formControlName=\"acapt_class_program_id_acacpm\" \n placeholder=\"Select program class\"\n [disabled]=\"isViewMode()\" \n valueKey=\"_id\" \n labelKey=\"acacpm_alise_title\" \n [options]=\"programClassOptions()\">\n </cide-ele-select>\n </div>\n\n <div class=\"tw-space-y-2 md:tw-col-span-2\">\n <label class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Specialization *</label>\n <cide-ele-select \n formControlName=\"acapt_class_program_branch_id_acabrn\" \n placeholder=\"Select specialization\"\n [disabled]=\"isViewMode()\" \n valueKey=\"_id\" \n labelKey=\"acabrn_name\" \n [options]=\"branchOptions()\">\n </cide-ele-select>\n </div>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <cide-ele-input label=\"Term Code *\" formControlName=\"acapt_code\" placeholder=\"e.g., T1, T2, T3\"\n size=\"md\" leadingIcon=\"code\">\n </cide-ele-input>\n\n <cide-ele-input label=\"Term Name *\" formControlName=\"acapt_name\"\n placeholder=\"e.g., First Term, Second Term\" size=\"md\" leadingIcon=\"schedule\">\n </cide-ele-input>\n </div>\n\n <div>\n <cide-ele-textarea label=\"Description\" formControlName=\"acapt_description\"\n placeholder=\"Enter detailed description of the term...\" rows=\"3\" size=\"md\">\n </cide-ele-textarea>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <cide-ele-input id=\"acapt_start_date\" label=\"Start Date\" formControlName=\"acapt_start_date\" type=\"date\"\n size=\"md\" leadingIcon=\"event\">\n </cide-ele-input>\n\n <cide-ele-input id=\"acapt_end_date\" label=\"End Date\" formControlName=\"acapt_end_date\" type=\"date\"\n [min]=\"endDateMinDate()\" size=\"md\" leadingIcon=\"event\">\n </cide-ele-input>\n </div>\n\n <div class=\"tw-p-3 tw-bg-blue-50 tw-border tw-border-blue-200 tw-rounded-lg\">\n <div class=\"tw-flex tw-items-center tw-gap-2\">\n <cide-ele-icon name=\"info\" class=\"tw-w-4 tw-h-4 tw-text-blue-500\"></cide-ele-icon>\n <span class=\"tw-text-sm tw-text-blue-700\">\n Sequence will be automatically managed through drag-and-drop on the listing page\n </span>\n </div>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <div\n class=\"tw-flex tw-items-center tw-gap-3 tw-p-4 tw-bg-gray-50 tw-rounded-lg tw-border tw-border-gray-200 tw-cursor-pointer hover:tw-bg-gray-100 tw-transition-colors tw-duration-200\"\n [class.tw-cursor-not-allowed]=\"isViewMode()\"\n [class.tw-opacity-60]=\"isViewMode()\"\n (click)=\"onActiveCardClick()\">\n <cide-ele-input formControlName=\"acapt_isactive\" type=\"checkbox\" size=\"md\">\n </cide-ele-input>\n <div class=\"tw-flex tw-flex-col\">\n <span class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Active</span>\n <span class=\"tw-text-xs tw-text-gray-500\">Enable/disable this term</span>\n </div>\n </div>\n\n <div\n class=\"tw-flex tw-items-center tw-gap-3 tw-p-4 tw-bg-gray-50 tw-rounded-lg tw-border tw-border-gray-200 tw-cursor-pointer hover:tw-bg-gray-100 tw-transition-colors tw-duration-200\"\n [class.tw-cursor-not-allowed]=\"isViewMode()\"\n [class.tw-opacity-60]=\"isViewMode()\"\n (click)=\"onLockedCardClick()\">\n <cide-ele-input formControlName=\"acapt_islocked\" type=\"checkbox\" size=\"md\">\n </cide-ele-input>\n <div class=\"tw-flex tw-flex-col\">\n <span class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Locked</span>\n <span class=\"tw-text-xs tw-text-gray-500\">Prevent modifications</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Error Display -->\n @if (error()) {\n <div class=\"tw-mt-6 tw-p-4 tw-bg-red-50 tw-border tw-border-red-200 tw-rounded-lg\">\n <div class=\"tw-flex tw-items-center tw-gap-2\">\n <cide-ele-icon variant=\"red\" size=\"sm\">error</cide-ele-icon>\n <span class=\"tw-text-sm tw-font-medium tw-text-red-800\">{{ error() }}</span>\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Form Actions -->\n <div class=\"tw-table-row tw-h-0\">\n <div class=\"tw-table-cell tw-w-full tw-px-6 tw-py-2 tw-bg-gray-50 tw-border-t tw-border-gray-200\">\n <div class=\"tw-flex tw-justify-end tw-gap-4\">\n <button cideEleButton type=\"button\" variant=\"secondary\" (click)=\"resetForm()\" leftIcon=\"refresh\"\n [disabled]=\"loading()\">\n Reset Form\n </button>\n\n <button cideEleButton type=\"button\" variant=\"secondary\" (click)=\"cancelForm()\" leftIcon=\"close\"\n [disabled]=\"loading()\">\n Cancel\n </button>\n\n <button cideEleButton type=\"submit\" variant=\"primary\" [disabled]=\"loading() || classProgramTermForm.invalid\"\n [loading]=\"loading()\" leftIcon=\"save\">\n {{ isEditMode() ? 'Update Class Program Term' : 'Create Class Program Term' }}\n </button>\n </div>\n </div>\n </div>\n </form>\n</cide-lyt-shared-wrapper>\n\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: "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", "size"], outputs: ["ngModelChange"] }, { 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: 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: 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"], outputs: ["ngModelChange", "change", "searchChange"] }, { kind: "component", type: CideLytSharedWrapperComponent, selector: "cide-lyt-shared-wrapper", inputs: ["shared_wrapper_setup_param", "breadcrumb_data"] }] });
643
- }
644
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.7", ngImport: i0, type: ClassProgramTermCreateComponent, decorators: [{
645
- type: Component,
646
- args: [{ selector: 'cide-academics-class-program-term-create', standalone: true, imports: [
647
- CommonModule,
648
- ReactiveFormsModule,
649
- CideInputComponent,
650
- CideTextareaComponent,
651
- CideEleButtonComponent,
652
- CideIconComponent,
653
- CideSelectComponent,
654
- CideLytSharedWrapperComponent
655
- ], template: "<!-- \n CLASS PROGRAM TERM MASTER FORM\n \n Enterprise-Level Styling with Tailwind CSS\n Features: Responsive grids, proper typography, enhanced user experience\n-->\n\n<cide-lyt-shared-wrapper [shared_wrapper_setup_param]=\"{ sypg_page_code: 'class_program_term' }\"\n [breadcrumb_data]=\"breadcrumbData()\">\n \n <form class=\"tw-w-full tw-table tw-h-full tw-bg-transparent\" [formGroup]=\"classProgramTermForm\"\n [class.tw-opacity-60]=\"loading()\" (ngSubmit)=\"onSubmit()\">\n\n <!-- Form Content -->\n <div class=\"tw-table-row\">\n <div class=\"tw-table-cell tw-w-full tw-px-6 tw-py-6\">\n <div class=\"tw-transition-opacity tw-duration-300\" [class.tw-opacity-60]=\"loading()\">\n <!-- Class Program Term Information -->\n <div class=\"tw-space-y-6\">\n <!-- Program Class and Branch at the top -->\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-3 tw-gap-6\">\n <div class=\"tw-space-y-2\">\n <label class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Program Class *</label>\n <cide-ele-select \n formControlName=\"acapt_class_program_id_acacpm\" \n placeholder=\"Select program class\"\n [disabled]=\"isViewMode()\" \n valueKey=\"_id\" \n labelKey=\"acacpm_alise_title\" \n [options]=\"programClassOptions()\">\n </cide-ele-select>\n </div>\n\n <div class=\"tw-space-y-2 md:tw-col-span-2\">\n <label class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Specialization *</label>\n <cide-ele-select \n formControlName=\"acapt_class_program_branch_id_acabrn\" \n placeholder=\"Select specialization\"\n [disabled]=\"isViewMode()\" \n valueKey=\"_id\" \n labelKey=\"acabrn_name\" \n [options]=\"branchOptions()\">\n </cide-ele-select>\n </div>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <cide-ele-input label=\"Term Code *\" formControlName=\"acapt_code\" placeholder=\"e.g., T1, T2, T3\"\n size=\"md\" leadingIcon=\"code\">\n </cide-ele-input>\n\n <cide-ele-input label=\"Term Name *\" formControlName=\"acapt_name\"\n placeholder=\"e.g., First Term, Second Term\" size=\"md\" leadingIcon=\"schedule\">\n </cide-ele-input>\n </div>\n\n <div>\n <cide-ele-textarea label=\"Description\" formControlName=\"acapt_description\"\n placeholder=\"Enter detailed description of the term...\" rows=\"3\" size=\"md\">\n </cide-ele-textarea>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <cide-ele-input id=\"acapt_start_date\" label=\"Start Date\" formControlName=\"acapt_start_date\" type=\"date\"\n size=\"md\" leadingIcon=\"event\">\n </cide-ele-input>\n\n <cide-ele-input id=\"acapt_end_date\" label=\"End Date\" formControlName=\"acapt_end_date\" type=\"date\"\n [min]=\"endDateMinDate()\" size=\"md\" leadingIcon=\"event\">\n </cide-ele-input>\n </div>\n\n <div class=\"tw-p-3 tw-bg-blue-50 tw-border tw-border-blue-200 tw-rounded-lg\">\n <div class=\"tw-flex tw-items-center tw-gap-2\">\n <cide-ele-icon name=\"info\" class=\"tw-w-4 tw-h-4 tw-text-blue-500\"></cide-ele-icon>\n <span class=\"tw-text-sm tw-text-blue-700\">\n Sequence will be automatically managed through drag-and-drop on the listing page\n </span>\n </div>\n </div>\n\n <div class=\"tw-grid tw-grid-cols-1 md:tw-grid-cols-2 tw-gap-6\">\n <div\n class=\"tw-flex tw-items-center tw-gap-3 tw-p-4 tw-bg-gray-50 tw-rounded-lg tw-border tw-border-gray-200 tw-cursor-pointer hover:tw-bg-gray-100 tw-transition-colors tw-duration-200\"\n [class.tw-cursor-not-allowed]=\"isViewMode()\"\n [class.tw-opacity-60]=\"isViewMode()\"\n (click)=\"onActiveCardClick()\">\n <cide-ele-input formControlName=\"acapt_isactive\" type=\"checkbox\" size=\"md\">\n </cide-ele-input>\n <div class=\"tw-flex tw-flex-col\">\n <span class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Active</span>\n <span class=\"tw-text-xs tw-text-gray-500\">Enable/disable this term</span>\n </div>\n </div>\n\n <div\n class=\"tw-flex tw-items-center tw-gap-3 tw-p-4 tw-bg-gray-50 tw-rounded-lg tw-border tw-border-gray-200 tw-cursor-pointer hover:tw-bg-gray-100 tw-transition-colors tw-duration-200\"\n [class.tw-cursor-not-allowed]=\"isViewMode()\"\n [class.tw-opacity-60]=\"isViewMode()\"\n (click)=\"onLockedCardClick()\">\n <cide-ele-input formControlName=\"acapt_islocked\" type=\"checkbox\" size=\"md\">\n </cide-ele-input>\n <div class=\"tw-flex tw-flex-col\">\n <span class=\"tw-text-sm tw-font-medium tw-text-gray-700\">Locked</span>\n <span class=\"tw-text-xs tw-text-gray-500\">Prevent modifications</span>\n </div>\n </div>\n </div>\n </div>\n </div>\n\n <!-- Error Display -->\n @if (error()) {\n <div class=\"tw-mt-6 tw-p-4 tw-bg-red-50 tw-border tw-border-red-200 tw-rounded-lg\">\n <div class=\"tw-flex tw-items-center tw-gap-2\">\n <cide-ele-icon variant=\"red\" size=\"sm\">error</cide-ele-icon>\n <span class=\"tw-text-sm tw-font-medium tw-text-red-800\">{{ error() }}</span>\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Form Actions -->\n <div class=\"tw-table-row tw-h-0\">\n <div class=\"tw-table-cell tw-w-full tw-px-6 tw-py-2 tw-bg-gray-50 tw-border-t tw-border-gray-200\">\n <div class=\"tw-flex tw-justify-end tw-gap-4\">\n <button cideEleButton type=\"button\" variant=\"secondary\" (click)=\"resetForm()\" leftIcon=\"refresh\"\n [disabled]=\"loading()\">\n Reset Form\n </button>\n\n <button cideEleButton type=\"button\" variant=\"secondary\" (click)=\"cancelForm()\" leftIcon=\"close\"\n [disabled]=\"loading()\">\n Cancel\n </button>\n\n <button cideEleButton type=\"submit\" variant=\"primary\" [disabled]=\"loading() || classProgramTermForm.invalid\"\n [loading]=\"loading()\" leftIcon=\"save\">\n {{ isEditMode() ? 'Update Class Program Term' : 'Create Class Program Term' }}\n </button>\n </div>\n </div>\n </div>\n </form>\n</cide-lyt-shared-wrapper>\n\n" }]
656
- }], ctorParameters: () => [] });
657
-
658
- export { ClassProgramTermCreateComponent };
659
- //# sourceMappingURL=cloud-ide-academics-class-program-term-create.component-BRbHViJN.mjs.map