angular-generate 2.2.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.
- package/README.md +149 -0
- package/explication_conception.md +119 -0
- package/package.json +28 -0
- package/src/api/index.d.ts +2 -0
- package/src/api/index.js +18 -0
- package/src/api/index.js.map +1 -0
- package/src/api/index_spec.d.ts +1 -0
- package/src/api/index_spec.js +23 -0
- package/src/api/index_spec.js.map +1 -0
- package/src/api/schema.json +17 -0
- package/src/collection.json +88 -0
- package/src/component/add/index.d.ts +2 -0
- package/src/component/add/index.js +64 -0
- package/src/component/add/index.js.map +1 -0
- package/src/component/add/index_spec.d.ts +1 -0
- package/src/component/add/index_spec.js +23 -0
- package/src/component/add/index_spec.js.map +1 -0
- package/src/component/deconnexion/index.d.ts +2 -0
- package/src/component/deconnexion/index.js +88 -0
- package/src/component/deconnexion/index.js.map +1 -0
- package/src/component/deconnexion/index_spec.d.ts +1 -0
- package/src/component/deconnexion/index_spec.js +23 -0
- package/src/component/deconnexion/index_spec.js.map +1 -0
- package/src/component/details/index.d.ts +2 -0
- package/src/component/details/index.js +12 -0
- package/src/component/details/index.js.map +1 -0
- package/src/component/details/index_spec.d.ts +1 -0
- package/src/component/details/index_spec.js +23 -0
- package/src/component/details/index_spec.js.map +1 -0
- package/src/component/edit/index.d.ts +2 -0
- package/src/component/edit/index.js +63 -0
- package/src/component/edit/index.js.map +1 -0
- package/src/component/edit/index_spec.d.ts +1 -0
- package/src/component/edit/index_spec.js +23 -0
- package/src/component/edit/index_spec.js.map +1 -0
- package/src/component/header/index.d.ts +2 -0
- package/src/component/header/index.js +311 -0
- package/src/component/header/index.js.map +1 -0
- package/src/component/list/index.d.ts +2 -0
- package/src/component/list/index.js +64 -0
- package/src/component/list/index.js.map +1 -0
- package/src/component/list/index_spec.d.ts +1 -0
- package/src/component/list/index_spec.js +23 -0
- package/src/component/list/index_spec.js.map +1 -0
- package/src/component/login/index.d.ts +2 -0
- package/src/component/login/index.js +314 -0
- package/src/component/login/index.js.map +1 -0
- package/src/component/login/index_spec.d.ts +1 -0
- package/src/component/login/index_spec.js +23 -0
- package/src/component/login/index_spec.js.map +1 -0
- package/src/component/not-found/index.d.ts +2 -0
- package/src/component/not-found/index.js +68 -0
- package/src/component/not-found/index.js.map +1 -0
- package/src/component/not-found/index_spec.d.ts +1 -0
- package/src/component/not-found/index_spec.js +23 -0
- package/src/component/not-found/index_spec.js.map +1 -0
- package/src/component/sidebar/index.d.ts +2 -0
- package/src/component/sidebar/index.js +247 -0
- package/src/component/sidebar/index.js.map +1 -0
- package/src/component/test/index.d.ts +2 -0
- package/src/component/test/index.js +20 -0
- package/src/component/test/index.js.map +1 -0
- package/src/component/test/index_spec.d.ts +1 -0
- package/src/component/test/index_spec.js +23 -0
- package/src/component/test/index_spec.js.map +1 -0
- package/src/component/type/index.d.ts +2 -0
- package/src/component/type/index.js +45 -0
- package/src/component/type/index.js.map +1 -0
- package/src/component/type/index_spec.d.ts +1 -0
- package/src/component/type/index_spec.js +23 -0
- package/src/component/type/index_spec.js.map +1 -0
- package/src/component/wrapper/index.d.ts +2 -0
- package/src/component/wrapper/index.js +175 -0
- package/src/component/wrapper/index.js.map +1 -0
- package/src/component/wrapper/index_spec.d.ts +1 -0
- package/src/component/wrapper/index_spec.js +23 -0
- package/src/component/wrapper/index_spec.js.map +1 -0
- package/src/config/index.d.ts +2 -0
- package/src/config/index.js +166 -0
- package/src/config/index.js.map +1 -0
- package/src/config/index_spec.d.ts +1 -0
- package/src/config/index_spec.js +23 -0
- package/src/config/index_spec.js.map +1 -0
- package/src/config/schema.json +31 -0
- package/src/guard/auth/index.d.ts +2 -0
- package/src/guard/auth/index.js +60 -0
- package/src/guard/auth/index.js.map +1 -0
- package/src/guard/auth/index_spec.d.ts +1 -0
- package/src/guard/auth/index_spec.js +23 -0
- package/src/guard/auth/index_spec.js.map +1 -0
- package/src/guard/permissions/index.d.ts +2 -0
- package/src/guard/permissions/index.js +51 -0
- package/src/guard/permissions/index.js.map +1 -0
- package/src/guard/permissions/index_spec.d.ts +1 -0
- package/src/guard/permissions/index_spec.js +23 -0
- package/src/guard/permissions/index_spec.js.map +1 -0
- package/src/module/index.d.ts +2 -0
- package/src/module/index.js +94 -0
- package/src/module/index.js.map +1 -0
- package/src/module/index_spec.d.ts +1 -0
- package/src/module/index_spec.js +23 -0
- package/src/module/index_spec.js.map +1 -0
- package/src/module/schema.json +17 -0
- package/src/other/taf-add-import-to-module/index.d.ts +2 -0
- package/src/other/taf-add-import-to-module/index.js +20 -0
- package/src/other/taf-add-import-to-module/index.js.map +1 -0
- package/src/other/taf-add-import-to-module/index_spec.d.ts +1 -0
- package/src/other/taf-add-import-to-module/index_spec.js +23 -0
- package/src/other/taf-add-import-to-module/index_spec.js.map +1 -0
- package/src/service/api/index.d.ts +2 -0
- package/src/service/api/index.js +508 -0
- package/src/service/api/index.js.map +1 -0
- package/src/service/api/index_spec.d.ts +1 -0
- package/src/service/api/index_spec.js +23 -0
- package/src/service/api/index_spec.js.map +1 -0
- package/src/templates/add/add.html.d.ts +1 -0
- package/src/templates/add/add.html.js +124 -0
- package/src/templates/add/add.html.js.map +1 -0
- package/src/templates/add/add.ts.d.ts +1 -0
- package/src/templates/add/add.ts.js +112 -0
- package/src/templates/add/add.ts.js.map +1 -0
- package/src/templates/edit/edit.html.d.ts +1 -0
- package/src/templates/edit/edit.html.js +121 -0
- package/src/templates/edit/edit.html.js.map +1 -0
- package/src/templates/edit/edit.ts.d.ts +1 -0
- package/src/templates/edit/edit.ts.js +117 -0
- package/src/templates/edit/edit.ts.js.map +1 -0
- package/src/templates/list/list.html.d.ts +1 -0
- package/src/templates/list/list.html.js +98 -0
- package/src/templates/list/list.html.js.map +1 -0
- package/src/templates/list/list.ts.d.ts +2 -0
- package/src/templates/list/list.ts.js +144 -0
- package/src/templates/list/list.ts.js.map +1 -0
- package/src/templates/test/test.ts.d.ts +4 -0
- package/src/templates/test/test.ts.js +145 -0
- package/src/templates/test/test.ts.js.map +1 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_html_content = void 0;
|
|
4
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
5
|
+
// 🔹 Fonction utilitaire pour formater les noms des champs
|
|
6
|
+
function formatFieldName(field) {
|
|
7
|
+
return field
|
|
8
|
+
.split("_") // Séparer par "_"
|
|
9
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) // Mettre la première lettre en majuscule
|
|
10
|
+
.join(" "); // Réassembler avec un espace
|
|
11
|
+
}
|
|
12
|
+
// 🔹 Fonction principale pour générer le contenu HTML
|
|
13
|
+
function get_html_content(table) {
|
|
14
|
+
let all_colonne = table.table_descriptions.les_colonnes
|
|
15
|
+
.map((une_colonne) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
let formattedField = formatFieldName(une_colonne.Field); // Appliquer la transformation
|
|
18
|
+
let attribut_select = (_b = (_a = une_colonne === null || une_colonne === void 0 ? void 0 : une_colonne.referenced_table) === null || _a === void 0 ? void 0 : _a.les_colonnes.find((col) => !col.Field.toLowerCase().includes('id'))) === null || _b === void 0 ? void 0 : _b.Field;
|
|
19
|
+
switch (une_colonne.Key) {
|
|
20
|
+
case "PRI":
|
|
21
|
+
return "";
|
|
22
|
+
case "MUL":
|
|
23
|
+
if (une_colonne.referenced_table) {
|
|
24
|
+
return `
|
|
25
|
+
<!-- Champ ${formattedField} (Clé étrangère vers ${une_colonne.referenced_table.table_name}) -->
|
|
26
|
+
<div class="form-group col-sm-12 mb-2">
|
|
27
|
+
<label for="${une_colonne.Field}">${formatFieldName(une_colonne.referenced_table.table_name)} <span class="text-danger">*</span></label>
|
|
28
|
+
<ng-select id="${une_colonne.Field}" [ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"
|
|
29
|
+
formControlName="${une_colonne.Field}" [items]="form_details?.${une_colonne.referenced_table.table_name}" bindLabel="${attribut_select}" bindValue="${une_colonne.referenced_table.cle_primaire.Field}" placeholder="Sélectionnez ${formatFieldName(une_colonne.referenced_table.table_name)}" virtualScroll="true">
|
|
30
|
+
</ng-select>
|
|
31
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
32
|
+
<div class="invalid-feedback">
|
|
33
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
34
|
+
<div>Ce champ est obligatoire</div>
|
|
35
|
+
}
|
|
36
|
+
</div>
|
|
37
|
+
}
|
|
38
|
+
</div>`;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return `<!-- Erreur : La clé étrangère ${une_colonne.Field} de la table ${table.table} n'est pas référencée -->`;
|
|
42
|
+
}
|
|
43
|
+
default:
|
|
44
|
+
if (une_colonne.Field === "created_at" && une_colonne.Default === "CURRENT_TIMESTAMP") {
|
|
45
|
+
return "";
|
|
46
|
+
}
|
|
47
|
+
if (une_colonne.type == 'date' || une_colonne.type == 'timestamp') {
|
|
48
|
+
return `
|
|
49
|
+
<!-- Champ ${formattedField} -->
|
|
50
|
+
<div class="form-group col-sm-12 mb-2">
|
|
51
|
+
<label for="${une_colonne.Field}">${formattedField} ${(une_colonne["Null"] == "NO") ? '<span class="text-danger">*</span>' : ''}</label>
|
|
52
|
+
<input id="${une_colonne.Field}" class="form-control"
|
|
53
|
+
type="date"
|
|
54
|
+
formControlName="${une_colonne.Field}"
|
|
55
|
+
placeholder="${formattedField}"
|
|
56
|
+
[ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"/>
|
|
57
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
58
|
+
<div class="invalid-feedback">
|
|
59
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
60
|
+
<div>Ce champ est obligatoire</div>
|
|
61
|
+
}
|
|
62
|
+
</div>
|
|
63
|
+
}
|
|
64
|
+
</div>`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return `
|
|
68
|
+
<!-- Champ ${formattedField} -->
|
|
69
|
+
<div class="form-group col-sm-12 mb-2">
|
|
70
|
+
<label for="${une_colonne.Field}">${formattedField} ${(une_colonne["Null"] == "NO") ? '<span class="text-danger">*</span>' : ''}</label>
|
|
71
|
+
<input id="${une_colonne.Field}" class="form-control"
|
|
72
|
+
type="text"
|
|
73
|
+
formControlName="${une_colonne.Field}"
|
|
74
|
+
placeholder="${formattedField}"
|
|
75
|
+
[ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"/>
|
|
76
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
77
|
+
<div class="invalid-feedback">
|
|
78
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
79
|
+
<div>Ce champ est obligatoire</div>
|
|
80
|
+
}
|
|
81
|
+
</div>
|
|
82
|
+
}
|
|
83
|
+
</div>`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
.filter((html) => html !== "") // Éviter les valeurs vides
|
|
88
|
+
.join("\n");
|
|
89
|
+
return `<div class="modal-header" data-bs-theme="ligth">
|
|
90
|
+
<h1 class="modal-title fs-5">Ajouter ${(0, strings_1.classify)(table.table)}</h1>
|
|
91
|
+
<button type="button" class="btn-close" aria-label="Close" (click)="activeModal.close()"></button>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="modal-body">
|
|
94
|
+
<form [formGroup]="reactiveForm_add_${table.table}"
|
|
95
|
+
(ngSubmit)="onSubmit_add_${table.table}()"
|
|
96
|
+
#form_add_${table.table}="ngForm"
|
|
97
|
+
class="row">
|
|
98
|
+
${all_colonne}
|
|
99
|
+
</form>
|
|
100
|
+
</div>
|
|
101
|
+
<!-- Footer -->
|
|
102
|
+
<div class="modal-footer border-0 pt-0">
|
|
103
|
+
<button type="button" class="btn btn-outline-secondary px-4" (click)="activeModal.close()">
|
|
104
|
+
Annuler
|
|
105
|
+
</button>
|
|
106
|
+
<button type="button" class="btn btn-primary px-4" [disabled]="
|
|
107
|
+
loading_add_${table.table}() ||
|
|
108
|
+
loading_get_details_add_${table.table}_form()
|
|
109
|
+
" (click)="form_add_${table.table}.ngSubmit.emit()">
|
|
110
|
+
@if(loading_add_${table.table}()){
|
|
111
|
+
<span>
|
|
112
|
+
<i class="bi bi-hourglass-split me-1"></i> Enregistrement...
|
|
113
|
+
</span>
|
|
114
|
+
}
|
|
115
|
+
@if(!loading_add_${table.table}()){
|
|
116
|
+
<span>
|
|
117
|
+
<i class="bi bi-check-circle me-1"></i> Enregistrer
|
|
118
|
+
</span>
|
|
119
|
+
}
|
|
120
|
+
</button>
|
|
121
|
+
</div>`;
|
|
122
|
+
}
|
|
123
|
+
exports.get_html_content = get_html_content;
|
|
124
|
+
//# sourceMappingURL=add.html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.html.js","sourceRoot":"","sources":["add.html.ts"],"names":[],"mappings":";;;AAAA,oEAAkE;AAElE,2DAA2D;AAC3D,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC,CAAC,kBAAkB;SAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,yCAAyC;SACnG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,6BAA6B;AAC7C,CAAC;AAED,sDAAsD;AACtD,SAAgB,gBAAgB,CAAC,KAAU;IACzC,IAAI,WAAW,GAAG,KAAK,CAAC,kBAAkB,CAAC,YAAY;SACtD,GAAG,CAAC,CAAC,WAAgB,EAAE,EAAE;;QACxB,IAAI,cAAc,GAAG,eAAe,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,8BAA8B;QACvF,IAAI,eAAe,GAAG,MAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,W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,oCAAoC,CAAA,CAAC,CAAA,EAAE;2BAC/G,WAAW,CAAC,KAAK;;wCAEJ,WAAW,CAAC,KAAK;oCACrB,cAAc;mEACiB,WAAW,CAAC,KAAK;sCAC9C,WAAW,CAAC,KAAK;;2BAE5B,WAAW,CAAC,KAAK;;;;;mBAKzB,CAAC;iBACT;qBAAI;oBACH,OAAO;2BACQ,cAAc;;+BAEV,WAAW,CAAC,KAAK,KAAK,cAAc,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAA,CAAC,CAAA,oCAAoC,CAAA,CAAC,CAAA,EAAE;6BAC/G,WAAW,CAAC,KAAK;;0CAEJ,WAAW,CAAC,KAAK;sCACrB,cAAc;qEACiB,WAAW,CAAC,KAAK;wCAC9C,WAAW,CAAC,KAAK;;6BAE5B,WAAW,CAAC,KAAK;;;;;qBAKzB,CAAC;iBACX;SACJ;IACH,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,2BAA2B;SAC9D,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO;8CACqC,IAAA,kBAAQ,EAAC,KAAK,CAAC,KAAK,CAAC;;;;4CAIvB,KAAK,CAAC,KAAK;uCAChB,KAAK,CAAC,KAAK;wBAC1B,KAAK,CAAC,KAAK;;UAEzB,WAAW;;;;;;;;;oBASD,KAAK,CAAC,KAAK;gCACC,KAAK,CAAC,KAAK;0BACjB,KAAK,CAAC,KAAK;sBACf,KAAK,CAAC,KAAK;;;;;uBAKV,KAAK,CAAC,KAAK;;;;;;OAM3B,CAAC;AACR,CAAC;AA9GD,4CA8GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function get_ts_content(table: any, componentName_class: string, componentName: string, Config: any): string;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_ts_content = void 0;
|
|
4
|
+
function get_ts_content(table, componentName_class, componentName, Config) {
|
|
5
|
+
let validators = table.table_descriptions.les_colonnes.map((une_colonne) => {
|
|
6
|
+
if (une_colonne["Key"] != 'PRI' && !(une_colonne["Field"] == "created_at" && une_colonne["Field"] == "updated_at" && une_colonne["Default"] != "")) {
|
|
7
|
+
if (une_colonne["Null"] == "NO") {
|
|
8
|
+
return une_colonne["Field"] + ': ["", Validators.required]';
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return une_colonne["Field"] + ': [""]';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}).filter((une_colonne) => une_colonne != undefined).join(",\n");
|
|
16
|
+
return `import { Component, OnDestroy, OnInit, signal } from '@angular/core';
|
|
17
|
+
import { FormGroup, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
18
|
+
import { ApiService } from '../../../service/api/api.service';
|
|
19
|
+
import { CommonModule } from '@angular/common';
|
|
20
|
+
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
21
|
+
import { NgSelectModule } from '@ng-select/ng-select';
|
|
22
|
+
@Component({
|
|
23
|
+
selector: 'app-${componentName}',
|
|
24
|
+
standalone: true, // Composant autonome
|
|
25
|
+
imports: [CommonModule, ReactiveFormsModule, NgSelectModule], // Dépendances importées
|
|
26
|
+
templateUrl: './${componentName}.component.html',
|
|
27
|
+
styleUrls: ['./${componentName}.component.${Config.style}']
|
|
28
|
+
})
|
|
29
|
+
export class ${componentName_class}Component implements OnInit, OnDestroy {
|
|
30
|
+
reactiveForm_add_${table.table} !: FormGroup;
|
|
31
|
+
submitted=signal(false);
|
|
32
|
+
loading_add_${table.table} =signal(false);
|
|
33
|
+
form_details: any = {}
|
|
34
|
+
loading_get_details_add_${table.table}_form = signal(false);
|
|
35
|
+
constructor(private formBuilder: FormBuilder,public api:ApiService, public activeModal: NgbActiveModal) { }
|
|
36
|
+
|
|
37
|
+
ngOnInit(): void {
|
|
38
|
+
console.groupCollapsed("${componentName_class}Component");
|
|
39
|
+
this.get_details_add_${table.table}_form()
|
|
40
|
+
this.init_form()
|
|
41
|
+
}
|
|
42
|
+
ngOnDestroy(): void {
|
|
43
|
+
console.groupEnd();
|
|
44
|
+
}
|
|
45
|
+
init_form() {
|
|
46
|
+
this.reactiveForm_add_${table.table} = this.formBuilder.group({
|
|
47
|
+
${validators}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// acces facile au champs de votre formulaire
|
|
52
|
+
get f(): any { return this.reactiveForm_add_${table.table} .controls; }
|
|
53
|
+
// validation du formulaire
|
|
54
|
+
onSubmit_add_${table.table} () {
|
|
55
|
+
this.submitted.set(true);
|
|
56
|
+
console.log(this.reactiveForm_add_${table.table} .value)
|
|
57
|
+
// stop here if form is invalid
|
|
58
|
+
if (this.reactiveForm_add_${table.table} .invalid) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
var ${table.table} =this.reactiveForm_add_${table.table} .value
|
|
62
|
+
this.add_${table.table} (${table.table} )
|
|
63
|
+
}
|
|
64
|
+
// vider le formulaire
|
|
65
|
+
onReset_add_${table.table} () {
|
|
66
|
+
this.submitted.set(false);
|
|
67
|
+
this.reactiveForm_add_${table.table} .reset();
|
|
68
|
+
}
|
|
69
|
+
async add_${table.table}(${table.table}: any) {
|
|
70
|
+
this.loading_add_${table.table}.set(true);
|
|
71
|
+
try {
|
|
72
|
+
const reponse = await this.api.api_post("${table.table}", ${table.table});
|
|
73
|
+
if (reponse && reponse.success) {
|
|
74
|
+
console.log("Opération effectuée avec succés sur la table ${table.table}. Réponse= ", reponse);
|
|
75
|
+
this.onReset_add_${table.table}();
|
|
76
|
+
this.api.Swal_success(reponse.message || "Opération éffectuée avec succés");
|
|
77
|
+
this.activeModal.close(reponse.data);
|
|
78
|
+
} else {
|
|
79
|
+
console.log("L'opération sur la table ${table.table} a échoué. Réponse= ", reponse);
|
|
80
|
+
this.api.Swal_error(reponse?.message || "L'opération a echoué");
|
|
81
|
+
}
|
|
82
|
+
} catch (error: any) {
|
|
83
|
+
console.error(error);
|
|
84
|
+
this.api.Swal_error(error?.error?.message || "L'opération a echoué");
|
|
85
|
+
} finally {
|
|
86
|
+
this.loading_add_${table.table}.set(false);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async get_details_add_${table.table}_form() {
|
|
91
|
+
this.loading_get_details_add_${table.table}_form.set(true);
|
|
92
|
+
try {
|
|
93
|
+
const reponse = await this.api.api_get("${table.table}/getformdetails");
|
|
94
|
+
if (reponse && reponse.success) {
|
|
95
|
+
this.form_details = reponse.data;
|
|
96
|
+
console.log("Opération effectuée avec succés sur la table ${table.table}. Réponse= ", reponse);
|
|
97
|
+
} else {
|
|
98
|
+
console.log("L'opération sur la table ${table.table} a échoué. Réponse= ", reponse);
|
|
99
|
+
this.api.Swal_error(reponse?.message || "L'opération a echoué");
|
|
100
|
+
}
|
|
101
|
+
} catch (error: any) {
|
|
102
|
+
console.error(error);
|
|
103
|
+
this.api.Swal_error(error?.error?.message || "L'opération a echoué");
|
|
104
|
+
} finally {
|
|
105
|
+
this.loading_get_details_add_${table.table}_form.set(false);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
`;
|
|
110
|
+
}
|
|
111
|
+
exports.get_ts_content = get_ts_content;
|
|
112
|
+
//# sourceMappingURL=add.ts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.ts.js","sourceRoot":"","sources":["add.ts.ts"],"names":[],"mappings":";;;AAAA,SAAgB,cAAc,CAAC,KAAU,EAAE,mBAA2B,EAAE,aAAqB,EAAE,MAAW;IACxG,IAAI,UAAU,GAAG,KAAK,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAgB,EAAE,EAAE;QAC9E,IAAI,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CA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;;;yBAOlC,KAAK,CAAC,KAAK;;;;0BAIV,KAAK,CAAC,KAAK;mCACF,KAAK,CAAC,KAAK;;gDAEE,KAAK,CAAC,KAAK;;;oEAGS,KAAK,CAAC,KAAK;;gDAE/B,KAAK,CAAC,KAAK;;;;;;;qCAOtB,KAAK,CAAC,KAAK;;;;CAI/C,CAAA;AACD,CAAC;AA1GD,wCA0GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function get_html_content(table: any): string;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_html_content = void 0;
|
|
4
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
5
|
+
// 🔹 Fonction utilitaire pour formater les noms des champs
|
|
6
|
+
function formatFieldName(field) {
|
|
7
|
+
return field
|
|
8
|
+
.split("_") // Séparer par "_"
|
|
9
|
+
.map(word => word.charAt(0).toUpperCase() + word.slice(1)) // Mettre la première lettre en majuscule
|
|
10
|
+
.join(" "); // Réassembler avec un espace
|
|
11
|
+
}
|
|
12
|
+
function get_html_content(table) {
|
|
13
|
+
let all_colonne = table.table_descriptions.les_colonnes
|
|
14
|
+
.map((une_colonne) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
let formattedField = formatFieldName(une_colonne.Field); // Appliquer la transformation
|
|
17
|
+
let attribut_select = (_b = (_a = une_colonne === null || une_colonne === void 0 ? void 0 : une_colonne.referenced_table) === null || _a === void 0 ? void 0 : _a.les_colonnes.find((col) => !col.Field.toLowerCase().includes('id'))) === null || _b === void 0 ? void 0 : _b.Field;
|
|
18
|
+
switch (une_colonne.Key) {
|
|
19
|
+
case "PRI":
|
|
20
|
+
return "";
|
|
21
|
+
case "MUL":
|
|
22
|
+
if (une_colonne.referenced_table) {
|
|
23
|
+
return `
|
|
24
|
+
<!-- Champ ${formattedField} (Clé étrangère vers ${une_colonne.referenced_table.table_name}) -->
|
|
25
|
+
<div class="form-group col-sm-12 mb-2">
|
|
26
|
+
<label for="${une_colonne.Field}">${formatFieldName(une_colonne.referenced_table.table_name)} <span class="text-danger">*</span></label>
|
|
27
|
+
<ng-select id="${une_colonne.Field}" [ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"
|
|
28
|
+
formControlName="${une_colonne.Field}" [items]="form_details?.${une_colonne.referenced_table.table_name}" bindLabel="${attribut_select}" bindValue="${une_colonne.referenced_table.cle_primaire.Field}" placeholder="Sélectionnez ${formatFieldName(une_colonne.referenced_table.table_name)}" virtualScroll="true">
|
|
29
|
+
</ng-select>
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
33
|
+
<div class="invalid-feedback">
|
|
34
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
35
|
+
<div>Ce champ est obligatoire</div>
|
|
36
|
+
}
|
|
37
|
+
</div>
|
|
38
|
+
}
|
|
39
|
+
</div>`;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return `<!-- Erreur : La clé étrangère ${une_colonne.Field} de la table ${table.table} n'est pas référencée -->`;
|
|
43
|
+
}
|
|
44
|
+
default:
|
|
45
|
+
if (une_colonne.Field === "created_at" && une_colonne.Default === "CURRENT_TIMESTAMP") {
|
|
46
|
+
return "";
|
|
47
|
+
}
|
|
48
|
+
if (une_colonne.type == 'date' || une_colonne.type == 'timestamp') {
|
|
49
|
+
return `
|
|
50
|
+
<!-- Champ ${formattedField} -->
|
|
51
|
+
<div class="form-group col-sm-12 mb-2">
|
|
52
|
+
<label for="${une_colonne.Field}">${formattedField} ${(une_colonne["Null"] == "NO") ? '<span class="text-danger">*</span>' : ''}</label>
|
|
53
|
+
<input id="${une_colonne.Field}" class="form-control"
|
|
54
|
+
type="date"
|
|
55
|
+
formControlName="${une_colonne.Field}"
|
|
56
|
+
placeholder="${formattedField}"
|
|
57
|
+
[ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"/>
|
|
58
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
59
|
+
<div class="invalid-feedback">
|
|
60
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
61
|
+
<div>Ce champ est obligatoire</div>
|
|
62
|
+
}
|
|
63
|
+
</div>
|
|
64
|
+
}
|
|
65
|
+
</div>`;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return `
|
|
69
|
+
<!-- Champ ${formattedField} -->
|
|
70
|
+
<div class="form-group col-sm-12 mb-2">
|
|
71
|
+
<label for="${une_colonne.Field}">${formattedField} ${(une_colonne["Null"] == "NO") ? '<span class="text-danger">*</span>' : ''}</label>
|
|
72
|
+
<input id="${une_colonne.Field}" class="form-control"
|
|
73
|
+
type="text"
|
|
74
|
+
formControlName="${une_colonne.Field}"
|
|
75
|
+
placeholder="${formattedField}"
|
|
76
|
+
[ngClass]="{ 'is-invalid': submitted() && f.${une_colonne.Field}.errors }"/>
|
|
77
|
+
@if (submitted() && f.${une_colonne.Field}.errors) {
|
|
78
|
+
<div class="invalid-feedback">
|
|
79
|
+
@if (f.${une_colonne.Field}.errors.required) {
|
|
80
|
+
<div>Ce champ est obligatoire</div>
|
|
81
|
+
}
|
|
82
|
+
</div>
|
|
83
|
+
}
|
|
84
|
+
</div>`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
.join("\n");
|
|
89
|
+
return `<div class="modal-header" data-bs-theme="ligth">
|
|
90
|
+
<h1 class="modal-title fs-5">Modifier ${(0, strings_1.classify)(table.table)}</h1>
|
|
91
|
+
<button type="button" class="btn-close" aria-label="Close" (click)="activeModal.close()"></button>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="modal-body">
|
|
94
|
+
<form [formGroup]="reactiveForm_edit_${table.table}" (ngSubmit)="onSubmit_edit_${table.table}()" #form_edit_${table.table}="ngForm" class="row">
|
|
95
|
+
${all_colonne}
|
|
96
|
+
</form>
|
|
97
|
+
</div>
|
|
98
|
+
<!-- Footer -->
|
|
99
|
+
<div class="modal-footer border-0 pt-0">
|
|
100
|
+
<button type="button" class="btn btn-outline-secondary px-4" (click)="activeModal.close()">
|
|
101
|
+
Annuler
|
|
102
|
+
</button>
|
|
103
|
+
<button type="button" class="btn btn-primary px-4" [disabled]="
|
|
104
|
+
loading_edit_${table.table}() ||
|
|
105
|
+
loading_get_details_edit_${table.table}_form() ||reactiveForm_edit_${table.table}.pristine
|
|
106
|
+
" (click)="form_edit_${table.table}.ngSubmit.emit()">
|
|
107
|
+
@if(loading_edit_${table.table}()){
|
|
108
|
+
<span>
|
|
109
|
+
<i class="bi bi-hourglass-split me-1"></i> Enregistrement...
|
|
110
|
+
</span>
|
|
111
|
+
}
|
|
112
|
+
@if(!loading_edit_${table.table}()){
|
|
113
|
+
<span>
|
|
114
|
+
<i class="bi bi-check-circle me-1"></i> Enregistrer
|
|
115
|
+
</span>
|
|
116
|
+
}
|
|
117
|
+
</button>
|
|
118
|
+
</div>`;
|
|
119
|
+
}
|
|
120
|
+
exports.get_html_content = get_html_content;
|
|
121
|
+
//# sourceMappingURL=edit.html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.html.js","sourceRoot":"","sources":["edit.html.ts"],"names":[],"mappings":";;;AAAA,oEAAkE;AAElE,2DAA2D;AAC3D,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK;SACT,KAAK,CAAC,GAAG,CAAC,CAAC,kBAAkB;SAC7B,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,yCAAyC;SACnG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,6BAA6B;AAC7C,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAU;IACzC,IAAI,WAAW,GAAG,KAAK,CAAC,kBAAkB,CA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table: any, componentName_class: string, componentName: string, Config: any): string;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_ts_content = void 0;
|
|
4
|
+
function get_ts_content(table, componentName_class, componentName, Config) {
|
|
5
|
+
let validators_update = table.table_descriptions.les_colonnes.map((une_colonne) => {
|
|
6
|
+
if (une_colonne["Key"] != 'PRI' && !(une_colonne["Field"] == "created_at" && une_colonne["Default"] != "")) {
|
|
7
|
+
if (une_colonne["Null"] == "NO") {
|
|
8
|
+
return `${une_colonne["Field"]} : [${table.table}_to_edit.${une_colonne["Field"]}, Validators.required]`;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return `${une_colonne["Field"]} : [${table.table}_to_edit.${une_colonne["Field"]}]`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}).filter((une_colonne) => une_colonne != undefined).join(",\n");
|
|
16
|
+
table.description.map((une_colonne) => {
|
|
17
|
+
return `${une_colonne}: ["", Validators.required]`;
|
|
18
|
+
}).join(",\n");
|
|
19
|
+
return `import { Component, Input, OnDestroy, OnInit, signal } from '@angular/core';
|
|
20
|
+
import { FormGroup, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
|
|
21
|
+
import { ApiService } from '../../../service/api/api.service';
|
|
22
|
+
import { CommonModule } from '@angular/common';
|
|
23
|
+
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
|
24
|
+
import { NgSelectModule } from '@ng-select/ng-select';
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'app-${componentName}',
|
|
27
|
+
standalone: true, // Composant autonome
|
|
28
|
+
imports: [CommonModule, ReactiveFormsModule, NgSelectModule], // Dépendances importées
|
|
29
|
+
templateUrl: './${componentName}.component.html',
|
|
30
|
+
styleUrls: ['./${componentName}.component.${Config.style}']
|
|
31
|
+
})
|
|
32
|
+
export class ${componentName_class}Component implements OnInit, OnDestroy {
|
|
33
|
+
reactiveForm_edit_${table.table} !: FormGroup;
|
|
34
|
+
submitted=signal(false);
|
|
35
|
+
loading_edit_${table.table}=signal(false);
|
|
36
|
+
@Input()
|
|
37
|
+
${table.table}_to_edit: any;
|
|
38
|
+
form_details: any = {}
|
|
39
|
+
loading_get_details_edit_${table.table}_form =signal(false);
|
|
40
|
+
constructor(private formBuilder: FormBuilder, public api: ApiService, public activeModal: NgbActiveModal) {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
ngOnInit(): void {
|
|
44
|
+
console.groupCollapsed("${componentName_class}Component");
|
|
45
|
+
this.get_details_edit_${table.table}_form()
|
|
46
|
+
this.update_form(this.${table.table}_to_edit)
|
|
47
|
+
}
|
|
48
|
+
ngOnDestroy(): void {
|
|
49
|
+
console.groupEnd();
|
|
50
|
+
}
|
|
51
|
+
// mise à jour du formulaire
|
|
52
|
+
update_form(${table.table}_to_edit:any) {
|
|
53
|
+
this.reactiveForm_edit_${table.table} = this.formBuilder.group({
|
|
54
|
+
${validators_update}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// acces facile au champs de votre formulaire
|
|
59
|
+
get f(): any { return this.reactiveForm_edit_${table.table} .controls; }
|
|
60
|
+
// validation du formulaire
|
|
61
|
+
onSubmit_edit_${table.table}() {
|
|
62
|
+
this.submitted.set(true);
|
|
63
|
+
console.log(this.reactiveForm_edit_${table.table}.value)
|
|
64
|
+
// stop here if form is invalid
|
|
65
|
+
if (this.reactiveForm_edit_${table.table}.invalid) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
var ${table.table} = this.reactiveForm_edit_${table.table}.value
|
|
69
|
+
this.edit_${table.table}(${table.table})
|
|
70
|
+
}
|
|
71
|
+
// vider le formulaire
|
|
72
|
+
onReset_edit_${table.table}() {
|
|
73
|
+
this.submitted.set(false);
|
|
74
|
+
this.reactiveForm_edit_${table.table}.reset();
|
|
75
|
+
}
|
|
76
|
+
async edit_${table.table}(${table.table}: any) {
|
|
77
|
+
this.loading_edit_${table.table}.set(true);
|
|
78
|
+
try {
|
|
79
|
+
const reponse = await this.api.api_put("${table.table}/" + this.${table.table}_to_edit.id, ${table.table});
|
|
80
|
+
if (reponse && reponse.success) {
|
|
81
|
+
this.activeModal.close(reponse.data);
|
|
82
|
+
console.log("Opération effectuée avec succés sur la table ${table.table}. Réponse= ", reponse);
|
|
83
|
+
this.api.Swal_success(reponse.message || "Opération éffectuée avec succés");
|
|
84
|
+
} else {
|
|
85
|
+
console.log("L'opération sur la table ${table.table} a échoué. Réponse= ", reponse);
|
|
86
|
+
this.api.Swal_error(reponse?.message || "L'opération a echoué");
|
|
87
|
+
}
|
|
88
|
+
} catch (error: any) {
|
|
89
|
+
console.error(error);
|
|
90
|
+
this.api.Swal_error(error?.error?.message || "L'opération a echoué");
|
|
91
|
+
} finally {
|
|
92
|
+
this.loading_edit_${table.table}.set(false);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async get_details_edit_${table.table}_form() {
|
|
97
|
+
this.loading_get_details_edit_${table.table}_form.set(true);
|
|
98
|
+
try {
|
|
99
|
+
const reponse = await this.api.api_get("${table.table}/getformdetails");
|
|
100
|
+
if (reponse && reponse.success) {
|
|
101
|
+
this.form_details = reponse.data;
|
|
102
|
+
console.log("Opération effectuée avec succés sur la table ${table.table}. Réponse= ", reponse);
|
|
103
|
+
} else {
|
|
104
|
+
console.log("L'opération sur la table ${table.table} a échoué. Réponse= ", reponse);
|
|
105
|
+
this.api.Swal_error(reponse?.message || "L'opération a echoué");
|
|
106
|
+
}
|
|
107
|
+
} catch (error: any) {
|
|
108
|
+
console.error(error);
|
|
109
|
+
this.api.Swal_error(error?.error?.message || "L'opération a echoué");
|
|
110
|
+
} finally {
|
|
111
|
+
this.loading_get_details_edit_${table.table}_form.set(false);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}`;
|
|
115
|
+
}
|
|
116
|
+
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iBAEhB,KAAK,CAAC,KAAK;;IAExB,KAAK,CAAC,KAAK;;6BAEc,KAAK,CAAC,KAAK;;;;;gCAKR,mBAAmB;8BACrB,KAAK,CAAC,KAAK;8BACX,KAAK,CAAC,KAAK;;;;;;gBAMzB,KAAK,CAAC,KAAK;+BACI,KAAK,CAAC,KAAK;YAC9B,iBAAiB;;;;;iDAKoB,KAAK,CAAC,KAAK;;kBAE1C,KAAK,CAAC,KAAK;;2CAEc,KAAK,CAAC,KAAK;;mCAEnB,KAAK,CAAC,KAAK;;;YAGlC,KAAK,CAAC,KAAK,6BAA6B,KAAK,CAAC,KAAK;kBAC7C,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK;;;iBAG3B,KAAK,CAAC,KAAK;;+BAEG,KAAK,CAAC,KAAK;;cAE5B,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK;wBAChB,KAAK,CAAC,KAAK;;gDAEa,KAAK,CAAC,KAAK,aAAa,KAAK,CAAC,KAAK,gBAAgB,KAAK,CAAC,KAAK;;;oEAG1C,KAAK,CAAC,KAAK;;;gDAG/B,KAAK,CAAC,KAAK;;;;;;;0BAOjC,KAAK,CAAC,KAAK;;;;2BAIV,KAAK,CAAC,KAAK;oCACF,KAAK,CAAC,KAAK;;gDAEC,KAAK,CAAC,KAAK;;;oEAGS,KAAK,CAAC,KAAK;;gDAE/B,KAAK,CAAC,KAAK;;;;;;;sCAOrB,KAAK,CAAC,KAAK;;;EAG/C,CAAA;AACF,CAAC;AA/GD,wCA+GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function get_html_content(table: any): string;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.get_html_content = void 0;
|
|
4
|
+
const strings_1 = require("@angular-devkit/core/src/utils/strings");
|
|
5
|
+
function get_html_content(table) {
|
|
6
|
+
let colonnes_carte = [table.description.find((col) => col.toLowerCase() !== 'id')];
|
|
7
|
+
return `<div
|
|
8
|
+
class="d-flex align-items-center justify-content-between bg-white shadow-sm p-4 rounded rounded-2 mb-4 border border-1">
|
|
9
|
+
<div class="d-flex align-items-center">
|
|
10
|
+
<i class="bi bi-arrow-left text-secondary fs-3 me-2" (click)="api.retour()"></i>
|
|
11
|
+
<div class="fs-5">${(strings_1.classify)(table.table)} - {{${table.table}.length}}</div>
|
|
12
|
+
<div class="d-flex gap-1 justify-content-end ms-3">
|
|
13
|
+
<ng-select [multiple]="true" [closeOnSelect]="false" placeholder="Rechercher ici ..." notFoundText="Aucun résultat"
|
|
14
|
+
class="no-limit" [(ngModel)]="filter.text" (search)="filter_change($event)" (change)="filter_change()"
|
|
15
|
+
style="min-width: 300px;">
|
|
16
|
+
</ng-select>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="d-flex">
|
|
20
|
+
<button class="btn btn-primary" (click)="openModal_add_${table.table}()"><i class="bi bi-plus-square-dotted"></i>
|
|
21
|
+
${(strings_1.classify)(table.table)}</button>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
<!-- Liste des éléments -->
|
|
25
|
+
<!-- Loading state -->
|
|
26
|
+
@if (loading_get_${table.table}()) {
|
|
27
|
+
<ng-container >
|
|
28
|
+
<div class="text-center py-5">
|
|
29
|
+
<div class="spinner-border text-primary" role="status">
|
|
30
|
+
<span class="visually-hidden">Chargement en cours...</span>
|
|
31
|
+
</div>
|
|
32
|
+
<p class="mt-2 text-muted fs-5">Chargement en cours...</p>
|
|
33
|
+
</div>
|
|
34
|
+
</ng-container>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
<!-- contenu sous format carte -->
|
|
38
|
+
@if (!loading_get_${table.table}() && ${table.table}.length > 0) {
|
|
39
|
+
<div class="row g-4" >
|
|
40
|
+
@for (one_${table.table} of list; track one_${table.table}) {
|
|
41
|
+
<ng-container>
|
|
42
|
+
<div class="col-sm-6 col-md-4 col-lg-4">
|
|
43
|
+
<div class="card shadow-sm h-100 border-0 rounded-3 transition-hover position-relative">
|
|
44
|
+
<div class="card-body p-4">
|
|
45
|
+
<!-- Menu trois points (actions) -->
|
|
46
|
+
<div class="position-absolute top-0 end-0 m-2">
|
|
47
|
+
<div class="dropdown">
|
|
48
|
+
<button type="button" class="btn btn-light btn-sm rounded-circle" data-bs-toggle="dropdown" aria-expanded="false">
|
|
49
|
+
<i class="bi bi-three-dots-vertical"></i>
|
|
50
|
+
</button>
|
|
51
|
+
<ul class="dropdown-menu dropdown-menu-end shadow-sm rounded-3">
|
|
52
|
+
<li>
|
|
53
|
+
<button class="dropdown-item d-flex align-items-center" type="button"
|
|
54
|
+
(click)="openModal_edit_${table.table}(one_${table.table})">
|
|
55
|
+
<i class="bi bi-pencil me-2 text-primary"></i> Modifier
|
|
56
|
+
</button>
|
|
57
|
+
</li>
|
|
58
|
+
<li>
|
|
59
|
+
<button class="dropdown-item d-flex align-items-center" type="button">
|
|
60
|
+
<i class="bi bi-eye me-2 text-primary"></i> Détails
|
|
61
|
+
</button>
|
|
62
|
+
</li>
|
|
63
|
+
</ul>
|
|
64
|
+
</div>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<!-- Contenu de la carte -->
|
|
68
|
+
${colonnes_carte.length === 0
|
|
69
|
+
? `<h5 class="card-title text-start fw-semibold text-dark mb-3">
|
|
70
|
+
Aucun champ affichable
|
|
71
|
+
</h5>`
|
|
72
|
+
: colonnes_carte.map((col) => `
|
|
73
|
+
<h5 class="card-title text-start fw-semibold text-dark mb-3">
|
|
74
|
+
{{ one_${table.table}.${col} || '${col} indisponible' }}
|
|
75
|
+
</h5>`).join('\n')}
|
|
76
|
+
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</ng-container>
|
|
81
|
+
}
|
|
82
|
+
</div>
|
|
83
|
+
}
|
|
84
|
+
<!-- Empty state -->
|
|
85
|
+
@if (!loading_get_${table.table}() && ${table.table}.length === 0) {
|
|
86
|
+
<div class="text-center py-5">
|
|
87
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80" fill="#6c757d" class="bi bi-info-circle mb-3"
|
|
88
|
+
viewBox="0 0 16 16">
|
|
89
|
+
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16" />
|
|
90
|
+
<path
|
|
91
|
+
d="m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0" />
|
|
92
|
+
</svg>
|
|
93
|
+
<p class="fs-5 text-muted">Pas de données</p>
|
|
94
|
+
</div>
|
|
95
|
+
}`;
|
|
96
|
+
}
|
|
97
|
+
exports.get_html_content = get_html_content;
|
|
98
|
+
//# sourceMappingURL=list.html.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.html.js","sourceRoot":"","sources":["list.html.ts"],"names":[],"mappings":";;;AAAA,oEAAkE;AAClE,SAAgB,gBAAgB,CAAC,KAAU;IACzC,IAAI,cAAc,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IAExF,OAAO;;;;wBAIe,CAAC,kBAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,KAAK,CAAC,KAAK;;;;;;;;;6DASN,KAAK,CAAC,KAAK;QAChE,CAAC,kBAAQ,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;;;;;mBAKZ,KAAK,CAAC,KAAK;;;;;;;;;;;;oBAYV,KAAK,CAAC,KAAK,SAAS,KAAK,CAAC,KAAK;;cAErC,KAAK,CAAC,KAAK,uBAAuB,KAAK,CAAC,KAAK;;;;;;;;;;;;;;8CAcb,KAAK,CAAC,KAAK,QAAQ,KAAK,CAAC,KAAK;;;;;;;;;;;;;;YAchE,cAAc,CAAC,MAAM,KAAK,CAAC;QACjC,CAAC,CAAC;;uBAEe;QACjB,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC;;6BAEZ,KAAK,CAAC,KAAK,IAAI,GAAG,QAAQ,GAAG;wBAClC,CAAC,CAAC,IAAI,CAAC,IAAI,CAC/B;;;;;;;;;;oBAUgB,KAAK,CAAC,KAAK,SAAS,KAAK,CAAC,KAAK;;;;;;;;;;EAUjD,CAAA;AACF,CAAC;AA7FD,4CA6FC"}
|