fam-archetype-app 0.0.1

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 (147) hide show
  1. package/README.md +38 -0
  2. package/package.json +25 -0
  3. package/src/collection.json +10 -0
  4. package/src/fam-archetype-app/files/.editorconfig +16 -0
  5. package/src/fam-archetype-app/files/.prettierignore +15 -0
  6. package/src/fam-archetype-app/files/.prettierrc.json +29 -0
  7. package/src/fam-archetype-app/files/LICENSE.md +21 -0
  8. package/src/fam-archetype-app/files/README.md +59 -0
  9. package/src/fam-archetype-app/files/angular.json.template +178 -0
  10. package/src/fam-archetype-app/files/cli +361 -0
  11. package/src/fam-archetype-app/files/eslint.config.js +89 -0
  12. package/src/fam-archetype-app/files/package-lock.json.template +18812 -0
  13. package/src/fam-archetype-app/files/package.json.template +62 -0
  14. package/src/fam-archetype-app/files/src/assets/fonts/DiBaScreen-Regular.woff2 +0 -0
  15. package/src/fam-archetype-app/files/src/assets/translations/translations-ca.json +284 -0
  16. package/src/fam-archetype-app/files/src/assets/translations/translations-en.json +28 -0
  17. package/src/fam-archetype-app/files/src/assets/translations/translations-es.json +28 -0
  18. package/src/fam-archetype-app/files/src/core/layout/component/footer/footer.component.html.template +3 -0
  19. package/src/fam-archetype-app/files/src/core/layout/component/footer/footer.component.scss +8 -0
  20. package/src/fam-archetype-app/files/src/core/layout/component/layout/layout.component.html +19 -0
  21. package/src/fam-archetype-app/files/src/core/layout/component/layout/layout.component.scss +28 -0
  22. package/src/fam-archetype-app/files/src/core/layout/component/main-info-popup/main-info-popup.component.html +33 -0
  23. package/src/fam-archetype-app/files/src/core/layout/component/main-info-popup/main-info-popup.component.scss +3 -0
  24. package/src/fam-archetype-app/files/src/core/layout/component/menu/menu.component.html +3 -0
  25. package/src/fam-archetype-app/files/src/core/layout/component/menu/menu.component.scss +163 -0
  26. package/src/fam-archetype-app/files/src/core/layout/component/menuitem/menuitem.component.html +39 -0
  27. package/src/fam-archetype-app/files/src/core/layout/component/menuitem/menuitem.component.scss +44 -0
  28. package/src/fam-archetype-app/files/src/core/layout/component/not-found/not-found.component.html +12 -0
  29. package/src/fam-archetype-app/files/src/core/layout/component/not-found/not-found.component.scss +17 -0
  30. package/src/fam-archetype-app/files/src/core/layout/component/sidebar/sidebar.component.html +13 -0
  31. package/src/fam-archetype-app/files/src/core/layout/component/sidebar/sidebar.component.scss +33 -0
  32. package/src/fam-archetype-app/files/src/core/layout/component/top-menu/top-menu.component.html +12 -0
  33. package/src/fam-archetype-app/files/src/core/layout/component/top-menu/top-menu.component.scss +9 -0
  34. package/src/fam-archetype-app/files/src/core/layout/component/topbar/_mixins.scss +8 -0
  35. package/src/fam-archetype-app/files/src/core/layout/component/topbar/topbar.component.html.template +45 -0
  36. package/src/fam-archetype-app/files/src/core/layout/component/topbar/topbar.component.scss +77 -0
  37. package/src/fam-archetype-app/files/src/environments/environment.dev.ts.template +12 -0
  38. package/src/fam-archetype-app/files/src/environments/environment.int.ts.template +12 -0
  39. package/src/fam-archetype-app/files/src/environments/environment.pre.ts.template +12 -0
  40. package/src/fam-archetype-app/files/src/environments/environment.ts.template +12 -0
  41. package/src/fam-archetype-app/files/src/index.html.template +18 -0
  42. package/src/fam-archetype-app/files/src/shared/filters/diba-filters/diba-filters.component.html +69 -0
  43. package/src/fam-archetype-app/files/src/shared/filters/diba-filters/diba-filters.component.scss +0 -0
  44. package/src/fam-archetype-app/files/src/shared/styles/_movements.scss +19 -0
  45. package/src/fam-archetype-app/files/src/shared/styles/global/_core.scss +20 -0
  46. package/src/fam-archetype-app/files/src/shared/styles/global/_icons.scss +37 -0
  47. package/src/fam-archetype-app/files/src/shared/styles/global/_tooltips.scss +14 -0
  48. package/src/fam-archetype-app/files/src/shared/styles/global/_typography.scss +68 -0
  49. package/src/fam-archetype-app/files/src/shared/styles/global/_utils.scss +24 -0
  50. package/src/fam-archetype-app/files/src/shared/styles/global/layout.scss +5 -0
  51. package/src/fam-archetype-app/files/src/shared/table/column-visibility-selector/column-visibility-selector.component.html +10 -0
  52. package/src/fam-archetype-app/files/src/shared/table/column-visibility-selector/column-visibility-selector.component.scss +0 -0
  53. package/src/fam-archetype-app/files/src/shared/table/diba-table/diba-table.component.html +136 -0
  54. package/src/fam-archetype-app/files/src/shared/table/diba-table/diba-table.component.scss +0 -0
  55. package/src/fam-archetype-app/files/src/styles.scss +109 -0
  56. package/src/fam-archetype-app/files/src/tailwind.css +3 -0
  57. package/src/fam-archetype-app/files/tailwind.config.js +36 -0
  58. package/src/fam-archetype-app/files/tools/cli/TelosysTools/commands/commands.txt +1 -0
  59. package/src/fam-archetype-app/files/tools/cli/TelosysTools/commands/db_to_entities.txt +1 -0
  60. package/src/fam-archetype-app/files/tools/cli/TelosysTools/commands/test_db_connection.txt +1 -0
  61. package/src/fam-archetype-app/files/tools/cli/TelosysTools/databases.yaml +188 -0
  62. package/src/fam-archetype-app/files/tools/cli/TelosysTools/downloads/.keep +0 -0
  63. package/src/fam-archetype-app/files/tools/cli/TelosysTools/lib/.keep +0 -0
  64. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamActivitat.entity +26 -0
  65. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamActivitatsUbicacio.entity +40 -0
  66. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamAlumne.entity +76 -0
  67. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamArea.entity +33 -0
  68. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamComanda.entity +37 -0
  69. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamCurs.entity +50 -0
  70. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamDocument.entity +53 -0
  71. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamDocumentTipus.entity +26 -0
  72. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamEntitatBase.entity +84 -0
  73. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamExpedient.entity +71 -0
  74. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamExpedientDocument.entity +51 -0
  75. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamExpedientEstat.entity +26 -0
  76. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamExpedientTipus.entity +26 -0
  77. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamJerarquia.entity +33 -0
  78. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamLinia.entity +56 -0
  79. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamMatricula.entity +63 -0
  80. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamTipusArticle.entity +26 -0
  81. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamUbicacio.entity +35 -0
  82. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FamZona.entity +27 -0
  83. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/Funcionalitat.entity +65 -0
  84. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/FuncionalitatGrupFunc.entity +58 -0
  85. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/GrupFuncionalitat.entity +54 -0
  86. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/PerfilGrupFuncionalitat.entity +50 -0
  87. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/VusPerfil.entity +31 -0
  88. package/src/fam-archetype-app/files/tools/cli/TelosysTools/models/app/model.yaml +4 -0
  89. package/src/fam-archetype-app/files/tools/cli/TelosysTools/telosys-tools.cfg +31 -0
  90. package/src/fam-archetype-app/files/tools/cli/TelosysTools/telosys.env +5 -0
  91. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/README.md +12 -0
  92. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/database.properties +23 -0
  93. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/include/init_var_entity.vm +169 -0
  94. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/include/macros.vm +218 -0
  95. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/app_config_ts.vm +56 -0
  96. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/app_routes_ts.vm +21 -0
  97. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/core/layout/component/menu/menu_component_ts.vm +30 -0
  98. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/core/layout/component/top-menu/top-menu_component_ts.vm +36 -0
  99. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/core/layout/service/menu_model_service_ts.vm +49 -0
  100. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/create-Xxx_use-case_ts.vm +18 -0
  101. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/create-file-Xxx_use-case_ts.vm +17 -0
  102. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/delete-Xxx_use-case_ts.vm +17 -0
  103. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/download-Xxx-file_use-case_ts.vm +24 -0
  104. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/find-Xxx_use-case_ts.vm +18 -0
  105. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/search-Xxx_use-case_ts.vm +25 -0
  106. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/application/update-Xxx_use-case_ts.vm +18 -0
  107. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/domain/Xxx_entity_ts.vm +36 -0
  108. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/domain/Xxx_repository_interface_ts.vm +27 -0
  109. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/mappers/Xxx_jsona_mapper_ts.vm +52 -0
  110. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/mappers/Xxx_mapper_ts.vm +36 -0
  111. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/Xxx_routes_ts.vm +15 -0
  112. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/detail/Xxx_detail_html.vm +178 -0
  113. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/detail/Xxx_detail_scss.vm +0 -0
  114. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/detail/Xxx_detail_spec_ts.vm +29 -0
  115. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/detail/Xxx_detail_ts.vm +382 -0
  116. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/list/Xxx_list_html.vm +37 -0
  117. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/list/Xxx_list_scss.vm +10 -0
  118. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/list/Xxx_list_spec_ts.vm +29 -0
  119. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/pages/list/Xxx_list_ts.vm +430 -0
  120. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/inbound/resources/Xxx_resource_ts.vm +43 -0
  121. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/modules/infrastructure/outbound/Xxx_repository_impl_ts.vm +162 -0
  122. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/main-angular/test_code.vm +3 -0
  123. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/templates.cfg +52 -0
  124. package/src/fam-archetype-app/files/tools/cli/TelosysTools/templates/fam-app-templates/tools-test/test-api_Xxx_rest.vm +181 -0
  125. package/src/fam-archetype-app/files/tools/cli/telosys +5 -0
  126. package/src/fam-archetype-app/files/tools/cli/telosys-cli-4.2.0-001.jar +0 -0
  127. package/src/fam-archetype-app/files/tools/cli/telosys-cli.cfg +55 -0
  128. package/src/fam-archetype-app/files/tools/cli/telosys-term.sh +30 -0
  129. package/src/fam-archetype-app/files/tools/cli/telosys.bat +4 -0
  130. package/src/fam-archetype-app/files/tools/cli/telosys.ico +0 -0
  131. package/src/fam-archetype-app/files/tools/db/develop/data/.keep +0 -0
  132. package/src/fam-archetype-app/files/tools/db/production/data/.keep +0 -0
  133. package/src/fam-archetype-app/files/tools/db/production/migrations/.keep +0 -0
  134. package/src/fam-archetype-app/files/tools/docs/.keep +0 -0
  135. package/src/fam-archetype-app/files/tools/test/test-api.rest +80 -0
  136. package/src/fam-archetype-app/files/tsconfig.app.json +15 -0
  137. package/src/fam-archetype-app/files/tsconfig.json +42 -0
  138. package/src/fam-archetype-app/files/tsconfig.spec.json +15 -0
  139. package/src/fam-archetype-app/files/vercel.json +9 -0
  140. package/src/fam-archetype-app/index.d.ts +2 -0
  141. package/src/fam-archetype-app/index.js +18 -0
  142. package/src/fam-archetype-app/index.js.map +1 -0
  143. package/src/fam-archetype-app/index_spec.d.ts +1 -0
  144. package/src/fam-archetype-app/index_spec.js +23 -0
  145. package/src/fam-archetype-app/index_spec.js.map +1 -0
  146. package/src/fam-archetype-app/schema.json +21 -0
  147. package/tsconfig.json +24 -0
@@ -0,0 +1,382 @@
1
+ #parse("include/macros.vm")
2
+ ## --------------------------------------------------
3
+ #checkId($entity)
4
+ #parse("include/init_var_entity.vm")
5
+ #parse("include/macros.vm")
6
+ ##---------------------------------------------------
7
+ import { Component, ViewChild, inject } from '@angular/core';
8
+ import { CommonModule } from '@angular/common';
9
+ import { FormsModule } from '@angular/forms';
10
+ import { Create${entityName}UseCase } from '../../../../application/create-#kebabCase("${entityName}").use-case';
11
+ import { ${entityName} } from '../../../../domain/#kebabCase("${entityName}").entity';
12
+ import { ActivatedRoute, Router } from '@angular/router';
13
+ import { Update${entityName}UseCase } from '@modules/#kebabCase("${entityName}")/application/update-#kebabCase("${entityName}").use-case';
14
+ import { Find${entityName}UseCase } from '@modules/#kebabCase("${entityName}")/application/find-#kebabCase("${entityName}").use-case';
15
+ import { ${entityName}Resource } from '../../resources/#kebabCase("${entityName}").resource';
16
+ import { ${entityName}Mapper } from '../../mappers/#kebabCase("${entityName}").mapper';
17
+ import { PrimeNgTranslationPipe } from '@core/pipes/primeng-translation.pipe';
18
+ import { Button } from 'primeng/button';
19
+ import { UtilsService } from '@shared/service/utils.service';
20
+ import { SelectModule } from 'primeng/select';
21
+ import { InputTextModule } from 'primeng/inputtext';
22
+ import { InputNumberModule } from 'primeng/inputnumber';
23
+ import { DatePickerModule } from 'primeng/datepicker';
24
+ import { CheckboxModule } from 'primeng/checkbox';
25
+ import { TextareaModule } from 'primeng/textarea';
26
+ import { ReactiveFormsModule, FormBuilder, FormGroup, Validators } from '@angular/forms';
27
+ import { FileUpload, FileUploadModule } from 'primeng/fileupload';
28
+ import { InputGroupModule } from 'primeng/inputgroup';
29
+ import { InputGroupAddonModule } from 'primeng/inputgroupaddon';
30
+ import { TabsModule } from 'primeng/tabs';
31
+ import { DynamicDialogConfig, DynamicDialogRef } from 'primeng/dynamicdialog';
32
+ #foreach( $link in $toOneLinks )
33
+ #if( $velocityCount == 1 )
34
+ //to One
35
+ #end
36
+ #if( ${entityName} != ${link.fieldType})
37
+ import { ${link.fieldType} } from '../../../../../#kebabCase("${link.fieldType}")/domain/#kebabCase("${link.fieldType}").entity';
38
+ #end
39
+ import { Search${link.fieldType}UseCase } from '@modules/#kebabCase("${link.fieldType}")/application/search-#kebabCase("${link.fieldType}").use-case';
40
+ #end
41
+ #if($existsDetailTabs)
42
+ #foreach($detailTab in $listDetailTabs)
43
+ import { ${detailTab}ListComponent } from '@modules/#kebabCase("${detailTab}")/infrastructure/inbound/pages/#kebabCase("${detailTab}")-list/#kebabCase("${detailTab}")-list.component';
44
+ #end#end
45
+ #if($hasFileTypeinNAS)
46
+ import { Download${entityName}UseCase } from '@modules/#kebabCase("${entityName}")/application/download-#kebabCase("${entityName}")-file.use-case';
47
+ #end
48
+
49
+
50
+
51
+ @Component({
52
+ selector: 'app-#kebabCase("${entityName}")-detail',
53
+ imports: [
54
+ FormsModule,
55
+ PrimeNgTranslationPipe,
56
+ CommonModule,
57
+ Button,
58
+ SelectModule,
59
+ InputTextModule,
60
+ InputNumberModule,
61
+ DatePickerModule,
62
+ CheckboxModule,
63
+ TextareaModule,
64
+ FileUploadModule,
65
+ InputGroupModule,
66
+ InputGroupAddonModule,
67
+ TabsModule,
68
+ ReactiveFormsModule,
69
+ #if($existsDetailTabs)
70
+ #foreach($detailTab in $listDetailTabs)
71
+ ${detailTab}ListComponent,
72
+ #end#end
73
+ ],
74
+ templateUrl: './#kebabCase("${entityName}")-detail.component.html',
75
+ styleUrl: './#kebabCase("${entityName}")-detail.component.scss'
76
+ })
77
+ export class ${entityName}DetailComponent {
78
+ #camelCase("${entityName}"): ${entityName}Resource = new ${entityName}Resource();
79
+ isEmbedded: boolean = false;
80
+
81
+ #foreach( $link in $toOneLinks )
82
+ #if( $velocityCount == 1 )
83
+ //to One
84
+ #end
85
+ ${link.fieldName}Select: { label: string; value: any }[] = [];
86
+ #end
87
+
88
+ isNew = false;
89
+ stackingForm = $entity.tagValueAsBoolean("stackingForm", false);
90
+ twoColumnForm = $entity.tagValueAsBoolean("twoColumnForm", true);
91
+
92
+ form!: FormGroup;
93
+
94
+ #foreach( $attribute in $sortedAttributes )
95
+ #if( $attribute.type == "binary[]" || $attribute.type == "byte[]")
96
+ selectedFile#camelCaseCapitalize("${attribute.name}"): File | null = null;
97
+
98
+ uploadedFile#camelCaseCapitalize("${attribute.name}"): File | null = null;
99
+ @ViewChild('#snakeLowerCase("$attribute.name")_fileUploader') #camelCase("${attribute.name}")fileUploader!: FileUpload;
100
+ #end#end
101
+
102
+ //Funcionamiento en popup
103
+ private ref = inject(DynamicDialogRef, { optional: true });
104
+ private cfg = inject(DynamicDialogConfig, { optional: true });
105
+ parentControlName: string | undefined;
106
+
107
+ constructor(
108
+ private fb: FormBuilder,
109
+ private route: ActivatedRoute,
110
+ private router: Router,
111
+ private utils: UtilsService,
112
+ private create${entityName}: Create${entityName}UseCase,
113
+ private update${entityName}: Update${entityName}UseCase,
114
+ private find${entityName}: Find${entityName}UseCase
115
+ #foreach( $link in $toOneLinks )
116
+ #if( $velocityCount == 1 )
117
+ ,
118
+ #end
119
+ private search${link.fieldType}: Search${link.fieldType}UseCase #comma( $foreach.hasNext )
120
+
121
+ #end
122
+ #if($hasFileTypeinNAS)
123
+ , private download${entityName}: Download${entityName}UseCase
124
+ #end
125
+ ) {}
126
+
127
+ async ngOnInit() {
128
+ // 1) Form
129
+ // Inicializa el formulario
130
+ this.form = this.fb.group({
131
+ #foreach( $attribute in $sortedAttributes )
132
+ #snakeLowerCase("$attribute.name"): [ #if($attribute.tagValueAsBoolean("disbaled", false)){value:#end null#if($attribute.tagValueAsBoolean("disbaled", false)) ,disabled: true}#end #if($attribute.isNotNull()), Validators.required#end ]#if($foreach.hasNext),
133
+ #end
134
+ #end
135
+ #foreach( $link in $toOneLinks )
136
+ #if( $velocityCount == 1 )
137
+ ,
138
+ #end
139
+ #snakeLowerCase("${link.fieldName}"): [null, Validators.required]#if($foreach.hasNext),
140
+ #end
141
+ #end
142
+
143
+ });
144
+
145
+ this.twoColumnForm = this.utils.checkTwoColumnForm(this.form);
146
+ this.isEmbedded = !!this.ref; // si hay DynamicDialogRef, estamos embebidos
147
+
148
+ // 2) Cargar combos
149
+ #foreach( $link in $toOneLinks )
150
+ #set($fieldShowFront = $link.tagValue("fieldShowFront", "id"))
151
+ this.${link.fieldName}Select = await this.loadDropdownForm('#snakeLowerCase("${fieldShowFront}")', this.search${link.fieldType});
152
+ #end
153
+
154
+ // 3) Resolver id y modo desde ruta o diálogo
155
+ const idFromRoute = this.route.snapshot.paramMap.get('id') ?? undefined;
156
+ const idFromDialog = this.cfg?.data?.id as string | undefined;
157
+ const modeFromDialog = this.cfg?.data?.mode as ('create' | 'edit' | undefined);
158
+ const parentId = this.cfg?.data?.parentId as string | number | undefined;
159
+ this.parentControlName = this.cfg?.data?.parent as string | undefined;
160
+
161
+ //this.#camelCase("${entityName}").id = this.route.snapshot.paramMap.get('id') ?? undefined;
162
+ //this.#camelCase("${entityName}").id = this.cfg?.data?.id ?? this.route.snapshot.paramMap.get('id');
163
+ this.#camelCase("${entityName}").id = idFromDialog ?? idFromRoute;
164
+
165
+ //this.isNew = this.route.snapshot.routeConfig?.path === 'new';
166
+ // `isNew` si viene explícito en dialog (mode=create) o si no hay id y la ruta es /new
167
+ this.isNew = (modeFromDialog === 'create') ||
168
+ (!this.#camelCase("${entityName}").id && this.route.snapshot.routeConfig?.path === 'new');
169
+
170
+ // 4) Si es edición, carga entidad y parchea formulario
171
+ if (!this.isNew && this.#camelCase("${entityName}").id) {
172
+ // Lógica para editar: cargar datos del ${entityName} existente
173
+ const #camelCase("${entityName}") = await this.find${entityName}.execute(this.#camelCase("${entityName}").id);
174
+ if (#camelCase("${entityName}")) {
175
+ this.#camelCase("${entityName}") = new ${entityName}Resource(#camelCase("${entityName}"));
176
+
177
+
178
+ #foreach( $attribute in $sortedAttributes )
179
+ #if( $attribute.type == "binary[]" || $attribute.type == "byte[]")
180
+ let fileList#camelCaseCapitalize("${attribute.name}") = null;
181
+ if(this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name") != null && this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name") != undefined) {
182
+ const file = new File(
183
+ [this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name")], // Pasamos el Uint8Array directamente
184
+ this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name")_nom,
185
+ { type: this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name")_content_type }
186
+ );
187
+ if(file.name != null && file.name != "") {
188
+ this.uploadedFile#camelCaseCapitalize("${attribute.name}") = file;
189
+
190
+ // Crear un objeto tipo FileList falso (si lo necesitas)
191
+ const dataTransfer = new DataTransfer();
192
+ dataTransfer.items.add(file);
193
+ fileList#camelCaseCapitalize("${attribute.name}") = dataTransfer.files;
194
+ console.log("FileList creado #camelCaseCapitalize("${attribute.name}") :", fileList#camelCaseCapitalize("${attribute.name}"));
195
+ this.form.get('#snakeLowerCase("$attribute.name")')?.setValue(fileList#camelCaseCapitalize("${attribute.name}"));
196
+ }
197
+ }
198
+ #end#end
199
+
200
+ this.form.patchValue({
201
+ #foreach( $attribute in $sortedAttributes )
202
+ #if( $attribute.type == "LocalDate" || $attribute.type == "localdate" || $attribute.type == "Date" || $attribute.type == "date")
203
+ #snakeLowerCase("$attribute.name"): this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name") ? new Date(this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name")) : null #if($foreach.hasNext),
204
+ #end
205
+ #else
206
+ #snakeLowerCase("$attribute.name"): this.#camelCase("${entityName}").#snakeLowerCase("$attribute.name") #if($foreach.hasNext),
207
+ #end
208
+ #end
209
+ #end
210
+ #foreach( $link in $toOneLinks )
211
+ #if( $velocityCount == 1 )
212
+ ,
213
+ #end
214
+ #snakeLowerCase("${link.fieldName}"): this.#camelCase("${entityName}").#snakeLowerCase("${link.fieldName}")?.id ?? null #if($foreach.hasNext), #end
215
+ #end
216
+
217
+ });
218
+ }
219
+ }
220
+
221
+ // 5) Bloquear campo padre cuando está embebido
222
+ if (this.isEmbedded && typeof this.parentControlName === 'string' && this.parentControlName.length > 0 && parentId != null) {
223
+ this.parentControlName = this.utils.toSnakeCase(this.parentControlName, { stripAccents: true })
224
+ const ctrl = this.form.get(this.parentControlName);
225
+ // forzamos el valor del padre
226
+ ctrl?.setValue(parentId, { emitEvent: false });
227
+
228
+ // lo bloqueamos en modo embebido (si no lo has hecho ya)
229
+ ctrl?.disable({ emitEvent: false });
230
+ }
231
+ }
232
+
233
+ removeFile(field: string): void {
234
+ this.utils.removeFile(field, this.form, this);
235
+ }
236
+
237
+ async loadDropdownForm(field: string, searchService: any) {
238
+ // Load info for dropdown filter
239
+ return this.utils.mapJsonApiToDropdownOptions((await searchService.execute()).data, field);
240
+ }
241
+
242
+ onFileSelected(event: any, field: string): void {
243
+ console.log("File selected:", event);
244
+ this.utils.onFileSelected(event, field, this.form, this);
245
+ }
246
+
247
+ async save() {
248
+ if (this.form.invalid) {
249
+ this.form.markAllAsTouched();
250
+ return;
251
+ }
252
+
253
+ const values = this.form.getRawValue();
254
+
255
+ #foreach( $attribute in $sortedAttributes )
256
+ #if( $attribute.type == "binary[]" || $attribute.type == "byte[]")
257
+ if (values.fam_ent_fitxer == null || (typeof values.#snakeLowerCase("$attribute.name") === 'object' && Object.keys(values.#snakeLowerCase("$attribute.name")).length === 0)) {
258
+ values.#snakeLowerCase("$attribute.name") = null;
259
+ values.#snakeLowerCase("$attribute.name")_nom = null;
260
+ values.#snakeLowerCase("$attribute.name")_content_type = null;
261
+ values.#snakeLowerCase("$attribute.name")_pes = null;
262
+ }
263
+ #end#end
264
+
265
+
266
+ const #camelCase("${entityName}"): ${entityName} = ${entityName}Mapper.toDomain({
267
+ ...this.#camelCase("${entityName}"),
268
+ #foreach( $attribute in $sortedAttributes )
269
+ #if( $attribute.type == "LocalDate" || $attribute.type == "localdate" || $attribute.type == "Date" || $attribute.type == "date")
270
+ #snakeLowerCase("$attribute.name"): this.utils.formatDateAsIsoNoTZ(values.#snakeLowerCase("$attribute.name")) #if($foreach.hasNext),
271
+ #end
272
+ #else
273
+ #snakeLowerCase("$attribute.name"): values.#snakeLowerCase("$attribute.name") #if($foreach.hasNext),
274
+ #end
275
+ #end
276
+ #end
277
+ #foreach( $link in $toOneLinks )
278
+ #if( $velocityCount == 1 )
279
+ ,
280
+ #end
281
+ #snakeLowerCase("${link.fieldName}"): {id: values.#snakeLowerCase("${link.fieldName}")} as ${link.fieldType} #if($foreach.hasNext),
282
+ #end
283
+ #end
284
+
285
+ });
286
+
287
+ if (this.isNew) {
288
+ // Crear nueva ${entityName}
289
+ #if($hasFileType)
290
+ const created: ${entityName} = await this.create${entityName}.execute(
291
+ #camelCase("${entityName}"),
292
+ #foreach( $attribute in $sortedAttributes )
293
+ #if( $attribute.type == "binary[]" || $attribute.type == "byte[]")
294
+ this.selectedFile#camelCaseCapitalize("${attribute.name}")
295
+ ? { file: this.selectedFile#camelCaseCapitalize("${attribute.name}"), field: '#snakeLowerCase("$attribute.name")' }
296
+ : undefined);
297
+ #end#end
298
+ #else
299
+ //await this.create${entityName}.execute(#camelCase("${entityName}"));
300
+ const created = await this.create${entityName}.execute(#camelCase("${entityName}"));
301
+ #end
302
+ // Capturar el ID del FamArea creado
303
+ const createdId = (created as any)?.id ?? this.#camelCase("${entityName}").id;
304
+
305
+ if (this.ref) {
306
+ this.ref.close({ created: true, id: createdId });
307
+ return;
308
+ }
309
+ this.router.navigate(['../'], { relativeTo: this.route });
310
+ return;
311
+
312
+ } else if (this.#camelCase("${entityName}").id) {
313
+ // Editar ${entityName} existente
314
+ #if($hasFileType)
315
+ await this.update${entityName}.execute(
316
+ #camelCase("${entityName}"),
317
+ #foreach( $attribute in $sortedAttributes )
318
+ #if( $attribute.type == "binary[]" || $attribute.type == "byte[]")
319
+ this.selectedFile#camelCaseCapitalize("${attribute.name}")
320
+ ? { file: this.selectedFile#camelCaseCapitalize("${attribute.name}"), field: '#snakeLowerCase("$attribute.name")' }
321
+ : undefined
322
+ #end#end
323
+ ).then(async () => {
324
+ #else
325
+ await this.update${entityName}.execute(#camelCase("${entityName}")).then(async () => {
326
+ #end
327
+ console.log("#camelCase("${entityName}") updated successfully");
328
+ if (this.ref) {
329
+ this.ref.close({ update: true, id: this.#camelCase("${entityName}").id });
330
+ } else {
331
+ this.router.navigate(['../'], { relativeTo: this.route });
332
+ }
333
+ }).catch(error => {
334
+ console.error("Error updating #camelCase("${entityName}"):", error);
335
+ throw error;
336
+ });
337
+ }
338
+ }
339
+
340
+
341
+ #if($hasFileType)
342
+ downloadFile(field: string): void {
343
+ #if($hasFileTypeinNAS)
344
+ const idFromRoute = this.route.snapshot.paramMap.get('id') ?? 0;
345
+ const fileName = this.form.get(`#[[${field}]]#_nom`)?.value;
346
+ this.download${entityName}.execute(idFromRoute as number)
347
+ .then(async (blob) => {
348
+ // Truco estándar para descargar Blob en navegador
349
+ const url = window.URL.createObjectURL(blob);
350
+ const a = document.createElement('a');
351
+ a.href = url;
352
+ a.download = fileName; // Nombre del fichero
353
+ document.body.appendChild(a);
354
+ a.click();
355
+ document.body.removeChild(a);
356
+ window.URL.revokeObjectURL(url);
357
+ }, error => {
358
+ console.error('Error descargando', error);
359
+ });
360
+ #else
361
+ const camelCaseName = this.utils.toCamelCaseCapitalized(field);
362
+ const selectedFile: File | null = (this as any)[`selectedFile#[[${camelCaseName}]]#`];
363
+ const base64String = (this as any)[`#camelCase("${entityName}")`][field];
364
+ const fileName = this.form.get(`#[[${field}]]#_nom`)?.value;
365
+ const contentType = this.form.get(`#[[${field}]]#_content_type`)?.value;
366
+
367
+ this.utils.downloadFile(selectedFile, base64String, fileName, contentType);
368
+ #end
369
+ }
370
+ #end
371
+
372
+ goBack() {
373
+ if (this.ref) {
374
+ // cierra el diálogo y devuelve un resultado opcional al padre
375
+ this.ref.close();
376
+ } else {
377
+ this.router.navigate(['../'], { relativeTo: this.route });
378
+ }
379
+ }
380
+
381
+ isDisabled = (name: string) => this.utils.isDisabled(this.form, name);
382
+ }
@@ -0,0 +1,37 @@
1
+ #parse("include/macros.vm")
2
+ ## --------------------------------------------------
3
+ #checkId($entity)
4
+ #parse("include/init_var_entity.vm")
5
+ #parse("include/macros.vm")
6
+ ##---------------------------------------------------
7
+ <h3 *ngIf="!embedded">{{ '#snakeUpperCase("${entityName}")_LIST' | primengTranslation }}</h3>
8
+
9
+ <app-diba-filters
10
+ *ngIf="showFilters"
11
+ [filters]="filters"
12
+ (searchClick)="newSearch(#[[$event]]#)"
13
+ (cleanClick)="cleanFilters(#[[$event]]#)">
14
+ </app-diba-filters>
15
+
16
+ <app-diba-table
17
+ [data]="#camelCase("${entityName}")List"
18
+ [columnasMostrar]="columnasMostrar"
19
+ [columnasOcultar]="columnasOcultar"
20
+ [page]="meta.page.number"
21
+ [rows]="meta.page.size"
22
+ [rowsPerPageOptions]="rowsPerPageOptions"
23
+ [totalRecords]="meta.page.totalElements"
24
+ [selectRows]="selectRows"
25
+ [editButton]="allowEdit"
26
+ [deleteButton]="allowDelete"
27
+ [loading]="loading"
28
+ [linkColumn]="linkColumn"
29
+ [embedded]="embedded"
30
+ [detailComponent]="detailComponent"
31
+ [parentId]="parentId"
32
+ [parent]="parent"
33
+ (pageChange)="onPageChange(#[[$event]]#)"
34
+ (sortChange)="onSortChange(#[[$event]]#)"
35
+ (deleteEvent)="onDeleteEvent(#[[$event]]#)"
36
+ (updateEvent)="onPageUpdate(#[[$event]]#)">
37
+ </app-diba-table>
@@ -0,0 +1,10 @@
1
+ table {
2
+ border-collapse: collapse;
3
+ }
4
+
5
+ table,
6
+ table th,
7
+ table td {
8
+ border: 1px solid black;
9
+ padding: 8px;
10
+ }
@@ -0,0 +1,29 @@
1
+ #parse("include/macros.vm")
2
+ ## --------------------------------------------------
3
+ #checkId($entity)
4
+ #parse("include/init_var_entity.vm")
5
+ #parse("include/macros.vm")
6
+ ##---------------------------------------------------
7
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
8
+
9
+ import { ${entityName}ListComponent } from './#kebabCase("${entityName}")-list.component';
10
+
11
+ describe('${entityName}ListComponent', () => {
12
+ let component: ${entityName}ListComponent;
13
+ let fixture: ComponentFixture<${entityName}ListComponent>;
14
+
15
+ beforeEach(async () => {
16
+ await TestBed.configureTestingModule({
17
+ imports: [${entityName}ListComponent]
18
+ })
19
+ .compileComponents();
20
+
21
+ fixture = TestBed.createComponent(${entityName}ListComponent);
22
+ component = fixture.componentInstance;
23
+ fixture.detectChanges();
24
+ });
25
+
26
+ it('should create', () => {
27
+ expect(component).toBeTruthy();
28
+ });
29
+ });