chaqui-catalog-frontend-lib 1.1.0 → 1.1.2
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/dist/lib/catalog.module.d.ts +19 -0
- package/dist/lib/catalog.module.d.ts.map +1 -0
- package/dist/lib/catalog.module.js +50 -0
- package/dist/lib/catalog.module.js.map +1 -0
- package/dist/lib/components/catalog-items-select/catalog-items-select.component.d.ts +58 -0
- package/dist/lib/components/catalog-items-select/catalog-items-select.component.d.ts.map +1 -0
- package/dist/lib/components/catalog-items-select/catalog-items-select.component.js +147 -0
- package/dist/lib/components/catalog-items-select/catalog-items-select.component.js.map +1 -0
- package/dist/lib/components/catalog-select/catalog-select.component.d.ts +58 -0
- package/dist/lib/components/catalog-select/catalog-select.component.d.ts.map +1 -0
- package/dist/lib/components/catalog-select/catalog-select.component.js +151 -0
- package/dist/lib/components/catalog-select/catalog-select.component.js.map +1 -0
- package/dist/lib/components/index.d.ts +3 -0
- package/dist/lib/components/index.d.ts.map +1 -0
- package/dist/lib/components/index.js +3 -0
- package/dist/lib/components/index.js.map +1 -0
- package/dist/lib/config/catalog.config.d.ts +15 -0
- package/dist/lib/config/catalog.config.d.ts.map +1 -0
- package/dist/lib/config/catalog.config.js +5 -0
- package/dist/lib/config/catalog.config.js.map +1 -0
- package/dist/lib/models/catalog.model.d.ts +27 -0
- package/dist/lib/models/catalog.model.d.ts.map +1 -0
- package/dist/lib/models/catalog.model.js +2 -0
- package/dist/lib/models/catalog.model.js.map +1 -0
- package/dist/lib/models/index.d.ts +2 -0
- package/dist/lib/models/index.d.ts.map +1 -0
- package/dist/lib/models/index.js +2 -0
- package/dist/lib/models/index.js.map +1 -0
- package/dist/lib/services/catalog.service.d.ts +39 -0
- package/dist/lib/services/catalog.service.d.ts.map +1 -0
- package/dist/lib/services/catalog.service.js +83 -0
- package/dist/lib/services/catalog.service.js.map +1 -0
- package/dist/lib/services/index.d.ts +2 -0
- package/dist/lib/services/index.d.ts.map +1 -0
- package/dist/lib/services/index.js +2 -0
- package/dist/lib/services/index.js.map +1 -0
- package/dist/public-api.d.ts +9 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/public-api.js +9 -0
- package/dist/public-api.js.map +1 -0
- package/package.json +5 -2
- package/src/lib/catalog.module.ts +3 -3
- package/src/lib/components/catalog-items-select/catalog-items-select.component.ts +3 -0
- package/src/lib/components/catalog-select/catalog-select.component.css +68 -0
- package/src/lib/components/catalog-select/catalog-select.component.html +30 -0
- package/src/lib/components/catalog-select/catalog-select.component.ts +141 -0
- package/src/lib/components/index.ts +1 -0
- package/src/lib/services/catalog.service.ts +12 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModuleWithProviders } from '@angular/core';
|
|
2
|
+
import type { CatalogConfig } from './config/catalog.config.js';
|
|
3
|
+
export declare class CatalogModule {
|
|
4
|
+
/**
|
|
5
|
+
* Configura el módulo con la URL base del servicio de catálogos
|
|
6
|
+
* @param config Configuración del módulo
|
|
7
|
+
* @returns Módulo configurado con los proveedores
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // En tu app.module.ts
|
|
11
|
+
* imports: [
|
|
12
|
+
* CatalogModule.forRoot({
|
|
13
|
+
* apiBaseUrl: 'http://localhost:3001/api'
|
|
14
|
+
* })
|
|
15
|
+
* ]
|
|
16
|
+
*/
|
|
17
|
+
static forRoot(config: CatalogConfig): ModuleWithProviders<CatalogModule>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=catalog.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.module.d.ts","sourceRoot":"","sources":["../../src/lib/catalog.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAO9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,qBAKa,aAAa;IACxB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC;CAY1E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var CatalogModule_1;
|
|
8
|
+
import { NgModule } from '@angular/core';
|
|
9
|
+
import { CommonModule } from '@angular/common';
|
|
10
|
+
import { HttpClientModule } from '@angular/common/http';
|
|
11
|
+
import { CatalogItemsSelectComponent } from './components/catalog-items-select/catalog-items-select.component.js';
|
|
12
|
+
import { CatalogSelectComponent } from './components/catalog-select/catalog-select.component.js';
|
|
13
|
+
import { CatalogService } from './services/catalog.service.js';
|
|
14
|
+
import { CATALOG_CONFIG_TOKEN } from './config/catalog.config.js';
|
|
15
|
+
let CatalogModule = CatalogModule_1 = class CatalogModule {
|
|
16
|
+
/**
|
|
17
|
+
* Configura el módulo con la URL base del servicio de catálogos
|
|
18
|
+
* @param config Configuración del módulo
|
|
19
|
+
* @returns Módulo configurado con los proveedores
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // En tu app.module.ts
|
|
23
|
+
* imports: [
|
|
24
|
+
* CatalogModule.forRoot({
|
|
25
|
+
* apiBaseUrl: 'http://localhost:3001/api'
|
|
26
|
+
* })
|
|
27
|
+
* ]
|
|
28
|
+
*/
|
|
29
|
+
static forRoot(config) {
|
|
30
|
+
return {
|
|
31
|
+
ngModule: CatalogModule_1,
|
|
32
|
+
providers: [
|
|
33
|
+
CatalogService,
|
|
34
|
+
{
|
|
35
|
+
provide: CATALOG_CONFIG_TOKEN,
|
|
36
|
+
useValue: config
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
CatalogModule = CatalogModule_1 = __decorate([
|
|
43
|
+
NgModule({
|
|
44
|
+
declarations: [CatalogItemsSelectComponent, CatalogSelectComponent],
|
|
45
|
+
imports: [CommonModule, HttpClientModule],
|
|
46
|
+
exports: [CatalogItemsSelectComponent, CatalogSelectComponent]
|
|
47
|
+
})
|
|
48
|
+
], CatalogModule);
|
|
49
|
+
export { CatalogModule };
|
|
50
|
+
//# sourceMappingURL=catalog.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.module.js","sourceRoot":"","sources":["../../src/lib/catalog.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAuB,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qEAAqE,CAAC;AAClH,OAAO,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAQ3D,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,OAAO,CAAC,MAAqB;QAClC,OAAO;YACL,QAAQ,EAAE,eAAa;YACvB,SAAS,EAAE;gBACT,cAAc;gBACd;oBACE,OAAO,EAAE,oBAAoB;oBAC7B,QAAQ,EAAE,MAAM;iBACjB;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1BY,aAAa;IALzB,QAAQ,CAAC;QACR,YAAY,EAAE,CAAC,2BAA2B,EAAE,sBAAsB,CAAC;QACnE,OAAO,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;QACzC,OAAO,EAAE,CAAC,2BAA2B,EAAE,sBAAsB,CAAC;KAC/D,CAAC;GACW,aAAa,CA0BzB","sourcesContent":["import { NgModule, ModuleWithProviders } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { HttpClientModule } from '@angular/common/http';\nimport { CatalogItemsSelectComponent } from './components/catalog-items-select/catalog-items-select.component.js';\nimport { CatalogSelectComponent } from './components/catalog-select/catalog-select.component.js';\nimport { CatalogService } from './services/catalog.service.js';\nimport { CATALOG_CONFIG_TOKEN } from './config/catalog.config.js';\nimport type { CatalogConfig } from './config/catalog.config.js';\n\n@NgModule({\n declarations: [CatalogItemsSelectComponent, CatalogSelectComponent],\n imports: [CommonModule, HttpClientModule],\n exports: [CatalogItemsSelectComponent, CatalogSelectComponent]\n})\nexport class CatalogModule {\n /**\n * Configura el módulo con la URL base del servicio de catálogos\n * @param config Configuración del módulo\n * @returns Módulo configurado con los proveedores\n * \n * @example\n * // En tu app.module.ts\n * imports: [\n * CatalogModule.forRoot({\n * apiBaseUrl: 'http://localhost:3001/api'\n * })\n * ]\n */\n static forRoot(config: CatalogConfig): ModuleWithProviders<CatalogModule> {\n return {\n ngModule: CatalogModule,\n providers: [\n CatalogService,\n {\n provide: CATALOG_CONFIG_TOKEN,\n useValue: config\n }\n ]\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
|
+
import { CatalogService } from '../../services/catalog.service.js';
|
|
3
|
+
import { CatalogItem } from '../../models/catalog.model.js';
|
|
4
|
+
export declare class CatalogItemsSelectComponent implements OnInit, OnDestroy {
|
|
5
|
+
private catalogService;
|
|
6
|
+
/**
|
|
7
|
+
* ID del catálogo del cual cargar los items
|
|
8
|
+
*/
|
|
9
|
+
catalogId: number;
|
|
10
|
+
/**
|
|
11
|
+
* ID del item actualmente seleccionado (opcional)
|
|
12
|
+
*/
|
|
13
|
+
selectedItemId?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Label del input del catálogo
|
|
16
|
+
*/
|
|
17
|
+
catalogLabel: string;
|
|
18
|
+
/**
|
|
19
|
+
* Placeholder del select de items
|
|
20
|
+
*/
|
|
21
|
+
itemSelectPlaceholder: string;
|
|
22
|
+
/**
|
|
23
|
+
* Emite cuando se selecciona un item
|
|
24
|
+
*/
|
|
25
|
+
itemSelected: EventEmitter<CatalogItem>;
|
|
26
|
+
/**
|
|
27
|
+
* Emite cuando hay un error al cargar los items
|
|
28
|
+
*/
|
|
29
|
+
error: EventEmitter<string>;
|
|
30
|
+
items: CatalogItem[];
|
|
31
|
+
isLoading: boolean;
|
|
32
|
+
errorMessage: string;
|
|
33
|
+
private destroy$;
|
|
34
|
+
constructor(catalogService: CatalogService);
|
|
35
|
+
ngOnInit(): void;
|
|
36
|
+
ngOnDestroy(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Carga los items del catálogo especificado
|
|
39
|
+
*/
|
|
40
|
+
loadItems(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Maneja el cambio de catálogo
|
|
43
|
+
* @param event Evento del input
|
|
44
|
+
*/
|
|
45
|
+
onCatalogIdChange(event: any): void;
|
|
46
|
+
/**
|
|
47
|
+
* Maneja la selección de un item
|
|
48
|
+
* @param event Evento del select
|
|
49
|
+
*/
|
|
50
|
+
onItemSelected(event: any): void;
|
|
51
|
+
/**
|
|
52
|
+
* Obtiene el nombre del item para mostrar en el select
|
|
53
|
+
* @param item Item del catálogo
|
|
54
|
+
* @returns Nombre del item o ID si no hay nombre
|
|
55
|
+
*/
|
|
56
|
+
getItemDisplayName(item: CatalogItem): string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=catalog-items-select.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-items-select.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/catalog-items-select/catalog-items-select.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAI5D,qBAKa,2BAA4B,YAAW,MAAM,EAAE,SAAS;IAqCvD,OAAO,CAAC,cAAc;IApClC;;OAEG;IACM,SAAS,EAAG,MAAM,CAAC;IAE5B;;OAEG;IACM,cAAc,CAAC,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACM,YAAY,EAAE,MAAM,CAAqB;IAElD;;OAEG;IACM,qBAAqB,EAAE,MAAM,CAAwB;IAE9D;;OAEG;IACO,YAAY,4BAAmC;IAEzD;;OAEG;IACO,KAAK,uBAA8B;IAE7C,KAAK,EAAE,WAAW,EAAE,CAAM;IAC1B,SAAS,EAAE,OAAO,CAAS;IAC3B,YAAY,EAAE,MAAM,CAAM;IAE1B,OAAO,CAAC,QAAQ,CAAuB;gBAEnB,cAAc,EAAE,cAAc;IAElD,QAAQ,IAAI,IAAI;IAMhB,WAAW,IAAI,IAAI;IAKnB;;OAEG;IACH,SAAS,IAAI,IAAI;IA2BjB;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAQnC;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAShC;;;;OAIG;IACH,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM;CAG9C"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
11
|
+
import { CatalogService } from '../../services/catalog.service.js';
|
|
12
|
+
import { Subject } from 'rxjs';
|
|
13
|
+
import { takeUntil } from 'rxjs/operators';
|
|
14
|
+
let CatalogItemsSelectComponent = class CatalogItemsSelectComponent {
|
|
15
|
+
catalogService;
|
|
16
|
+
/**
|
|
17
|
+
* ID del catálogo del cual cargar los items
|
|
18
|
+
*/
|
|
19
|
+
catalogId;
|
|
20
|
+
/**
|
|
21
|
+
* ID del item actualmente seleccionado (opcional)
|
|
22
|
+
*/
|
|
23
|
+
selectedItemId;
|
|
24
|
+
/**
|
|
25
|
+
* Label del input del catálogo
|
|
26
|
+
*/
|
|
27
|
+
catalogLabel = 'ID del Catálogo';
|
|
28
|
+
/**
|
|
29
|
+
* Placeholder del select de items
|
|
30
|
+
*/
|
|
31
|
+
itemSelectPlaceholder = 'Selecciona un item';
|
|
32
|
+
/**
|
|
33
|
+
* Emite cuando se selecciona un item
|
|
34
|
+
*/
|
|
35
|
+
itemSelected = new EventEmitter();
|
|
36
|
+
/**
|
|
37
|
+
* Emite cuando hay un error al cargar los items
|
|
38
|
+
*/
|
|
39
|
+
error = new EventEmitter();
|
|
40
|
+
items = [];
|
|
41
|
+
isLoading = false;
|
|
42
|
+
errorMessage = '';
|
|
43
|
+
destroy$ = new Subject();
|
|
44
|
+
constructor(catalogService) {
|
|
45
|
+
this.catalogService = catalogService;
|
|
46
|
+
}
|
|
47
|
+
ngOnInit() {
|
|
48
|
+
if (this.catalogId) {
|
|
49
|
+
this.loadItems();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
ngOnDestroy() {
|
|
53
|
+
this.destroy$.next();
|
|
54
|
+
this.destroy$.complete();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Carga los items del catálogo especificado
|
|
58
|
+
*/
|
|
59
|
+
loadItems() {
|
|
60
|
+
if (!this.catalogId) {
|
|
61
|
+
this.errorMessage = 'Por favor ingresa un ID de catálogo válido';
|
|
62
|
+
this.error.emit(this.errorMessage);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.isLoading = true;
|
|
66
|
+
this.errorMessage = '';
|
|
67
|
+
this.items = [];
|
|
68
|
+
this.catalogService.getItemsByCatalogId(this.catalogId)
|
|
69
|
+
.pipe(takeUntil(this.destroy$))
|
|
70
|
+
.subscribe({
|
|
71
|
+
next: (items) => {
|
|
72
|
+
this.items = items;
|
|
73
|
+
this.isLoading = false;
|
|
74
|
+
},
|
|
75
|
+
error: (err) => {
|
|
76
|
+
this.isLoading = false;
|
|
77
|
+
this.errorMessage = err?.message || 'Error al cargar los items del catálogo';
|
|
78
|
+
this.error.emit(this.errorMessage);
|
|
79
|
+
console.error('Error cargando items:', err);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Maneja el cambio de catálogo
|
|
85
|
+
* @param event Evento del input
|
|
86
|
+
*/
|
|
87
|
+
onCatalogIdChange(event) {
|
|
88
|
+
const value = event.target.value;
|
|
89
|
+
this.catalogId = value ? Number(value) : null;
|
|
90
|
+
if (this.catalogId) {
|
|
91
|
+
this.loadItems();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Maneja la selección de un item
|
|
96
|
+
* @param event Evento del select
|
|
97
|
+
*/
|
|
98
|
+
onItemSelected(event) {
|
|
99
|
+
const itemId = Number(event.target.value);
|
|
100
|
+
const selectedItem = this.items.find(item => item.id === itemId);
|
|
101
|
+
if (selectedItem) {
|
|
102
|
+
this.itemSelected.emit(selectedItem);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Obtiene el nombre del item para mostrar en el select
|
|
107
|
+
* @param item Item del catálogo
|
|
108
|
+
* @returns Nombre del item o ID si no hay nombre
|
|
109
|
+
*/
|
|
110
|
+
getItemDisplayName(item) {
|
|
111
|
+
return item.name || `Item ${item.id}`;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__decorate([
|
|
115
|
+
Input(),
|
|
116
|
+
__metadata("design:type", Number)
|
|
117
|
+
], CatalogItemsSelectComponent.prototype, "catalogId", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
Input(),
|
|
120
|
+
__metadata("design:type", Number)
|
|
121
|
+
], CatalogItemsSelectComponent.prototype, "selectedItemId", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
Input(),
|
|
124
|
+
__metadata("design:type", String)
|
|
125
|
+
], CatalogItemsSelectComponent.prototype, "catalogLabel", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
Input(),
|
|
128
|
+
__metadata("design:type", String)
|
|
129
|
+
], CatalogItemsSelectComponent.prototype, "itemSelectPlaceholder", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
Output(),
|
|
132
|
+
__metadata("design:type", Object)
|
|
133
|
+
], CatalogItemsSelectComponent.prototype, "itemSelected", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
Output(),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], CatalogItemsSelectComponent.prototype, "error", void 0);
|
|
138
|
+
CatalogItemsSelectComponent = __decorate([
|
|
139
|
+
Component({
|
|
140
|
+
selector: 'catalog-items-select',
|
|
141
|
+
templateUrl: './catalog-items-select.component.html',
|
|
142
|
+
styleUrls: ['./catalog-items-select.component.css']
|
|
143
|
+
}),
|
|
144
|
+
__metadata("design:paramtypes", [CatalogService])
|
|
145
|
+
], CatalogItemsSelectComponent);
|
|
146
|
+
export { CatalogItemsSelectComponent };
|
|
147
|
+
//# sourceMappingURL=catalog-items-select.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-items-select.component.js","sourceRoot":"","sources":["../../../../src/lib/components/catalog-items-select/catalog-items-select.component.ts"],"names":[],"mappings":"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","sourcesContent":["import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';\nimport { CatalogService } from '../../services/catalog.service.js';\nimport { CatalogItem } from '../../models/catalog.model.js';\nimport { Subject } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n@Component({\n selector: 'catalog-items-select',\n templateUrl: './catalog-items-select.component.html',\n styleUrls: ['./catalog-items-select.component.css']\n})\nexport class CatalogItemsSelectComponent implements OnInit, OnDestroy {\n /**\n * ID del catálogo del cual cargar los items\n */\n @Input() catalogId!: number;\n\n /**\n * ID del item actualmente seleccionado (opcional)\n */\n @Input() selectedItemId?: number;\n\n /**\n * Label del input del catálogo\n */\n @Input() catalogLabel: string = 'ID del Catálogo';\n\n /**\n * Placeholder del select de items\n */\n @Input() itemSelectPlaceholder: string = 'Selecciona un item';\n\n /**\n * Emite cuando se selecciona un item\n */\n @Output() itemSelected = new EventEmitter<CatalogItem>();\n\n /**\n * Emite cuando hay un error al cargar los items\n */\n @Output() error = new EventEmitter<string>();\n\n items: CatalogItem[] = [];\n isLoading: boolean = false;\n errorMessage: string = '';\n\n private destroy$ = new Subject<void>();\n\n constructor(private catalogService: CatalogService) {}\n\n ngOnInit(): void {\n if (this.catalogId) {\n this.loadItems();\n }\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n /**\n * Carga los items del catálogo especificado\n */\n loadItems(): void {\n if (!this.catalogId) {\n this.errorMessage = 'Por favor ingresa un ID de catálogo válido';\n this.error.emit(this.errorMessage);\n return;\n }\n\n this.isLoading = true;\n this.errorMessage = '';\n this.items = [];\n\n this.catalogService.getItemsByCatalogId(this.catalogId)\n .pipe(takeUntil(this.destroy$))\n .subscribe({\n next: (items: CatalogItem[]) => {\n this.items = items;\n this.isLoading = false;\n },\n error: (err: any) => {\n this.isLoading = false;\n this.errorMessage = err?.message || 'Error al cargar los items del catálogo';\n this.error.emit(this.errorMessage);\n console.error('Error cargando items:', err);\n }\n });\n }\n\n /**\n * Maneja el cambio de catálogo\n * @param event Evento del input\n */\n onCatalogIdChange(event: any): void {\n const value = event.target.value;\n this.catalogId = value ? Number(value) : null as any;\n if (this.catalogId) {\n this.loadItems();\n }\n }\n\n /**\n * Maneja la selección de un item\n * @param event Evento del select\n */\n onItemSelected(event: any): void {\n const itemId = Number(event.target.value);\n const selectedItem = this.items.find(item => item.id === itemId);\n \n if (selectedItem) {\n this.itemSelected.emit(selectedItem);\n }\n }\n\n /**\n * Obtiene el nombre del item para mostrar en el select\n * @param item Item del catálogo\n * @returns Nombre del item o ID si no hay nombre\n */\n getItemDisplayName(item: CatalogItem): string {\n return item.name || `Item ${item.id}`;\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { EventEmitter, OnInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core';
|
|
2
|
+
import { CatalogService } from '../../services/catalog.service.js';
|
|
3
|
+
import { Catalog } from '../../models/catalog.model.js';
|
|
4
|
+
export declare class CatalogSelectComponent implements OnInit, OnDestroy, OnChanges {
|
|
5
|
+
private catalogService;
|
|
6
|
+
/**
|
|
7
|
+
* Lista de IDs de catálogos a mostrar en el selector
|
|
8
|
+
*/
|
|
9
|
+
catalogIds: number[];
|
|
10
|
+
/**
|
|
11
|
+
* ID del catálogo actualmente seleccionado (opcional, para valor inicial)
|
|
12
|
+
*/
|
|
13
|
+
selectedCatalogId?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Placeholder del select de catálogos
|
|
16
|
+
*/
|
|
17
|
+
placeholder: string;
|
|
18
|
+
/**
|
|
19
|
+
* Label del selector
|
|
20
|
+
*/
|
|
21
|
+
label: string;
|
|
22
|
+
/**
|
|
23
|
+
* Emite el ID del catálogo seleccionado
|
|
24
|
+
*/
|
|
25
|
+
catalogSelected: EventEmitter<number>;
|
|
26
|
+
/**
|
|
27
|
+
* Emite el objeto Catalog completo del catálogo seleccionado
|
|
28
|
+
*/
|
|
29
|
+
catalogChange: EventEmitter<Catalog>;
|
|
30
|
+
/**
|
|
31
|
+
* Emite cuando hay un error al cargar los catálogos
|
|
32
|
+
*/
|
|
33
|
+
error: EventEmitter<string>;
|
|
34
|
+
catalogs: Catalog[];
|
|
35
|
+
isLoading: boolean;
|
|
36
|
+
errorMessage: string;
|
|
37
|
+
private destroy$;
|
|
38
|
+
constructor(catalogService: CatalogService);
|
|
39
|
+
ngOnInit(): void;
|
|
40
|
+
ngOnChanges(changes: SimpleChanges): void;
|
|
41
|
+
ngOnDestroy(): void;
|
|
42
|
+
/**
|
|
43
|
+
* Carga la información de cada catálogo a partir de los IDs recibidos
|
|
44
|
+
*/
|
|
45
|
+
loadCatalogs(): void;
|
|
46
|
+
/**
|
|
47
|
+
* Maneja la selección de un catálogo en el select
|
|
48
|
+
* @param event Evento del select
|
|
49
|
+
*/
|
|
50
|
+
onCatalogSelected(event: any): void;
|
|
51
|
+
/**
|
|
52
|
+
* Obtiene el nombre del catálogo para mostrar en el select
|
|
53
|
+
* @param catalog Catálogo
|
|
54
|
+
* @returns Nombre del catálogo o ID si no hay nombre
|
|
55
|
+
*/
|
|
56
|
+
getCatalogDisplayName(catalog: Catalog): string;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=catalog-select.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-select.component.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/catalog-select/catalog-select.component.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EACZ,MAAM,EACN,SAAS,EACT,SAAS,EACT,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAIxD,qBAKa,sBAAuB,YAAW,MAAM,EAAE,SAAS,EAAE,SAAS;IA0C7D,OAAO,CAAC,cAAc;IAzClC;;OAEG;IACM,UAAU,EAAE,MAAM,EAAE,CAAM;IAEnC;;OAEG;IACM,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAEpC;;OAEG;IACM,WAAW,EAAE,MAAM,CAA4B;IAExD;;OAEG;IACM,KAAK,EAAE,MAAM,CAAc;IAEpC;;OAEG;IACO,eAAe,uBAA8B;IAEvD;;OAEG;IACO,aAAa,wBAA+B;IAEtD;;OAEG;IACO,KAAK,uBAA8B;IAE7C,QAAQ,EAAE,OAAO,EAAE,CAAM;IACzB,SAAS,EAAE,OAAO,CAAS;IAC3B,YAAY,EAAE,MAAM,CAAM;IAE1B,OAAO,CAAC,QAAQ,CAAuB;gBAEnB,cAAc,EAAE,cAAc;IAElD,QAAQ,IAAI,IAAI;IAMhB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAMzC,WAAW,IAAI,IAAI;IAKnB;;OAEG;IACH,YAAY,IAAI,IAAI;IA8BpB;;;OAGG;IACH,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI;IAWnC;;;;OAIG;IACH,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM;CAGhD"}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Component, Input, Output, EventEmitter } from '@angular/core';
|
|
11
|
+
import { CatalogService } from '../../services/catalog.service.js';
|
|
12
|
+
import { Subject, forkJoin } from 'rxjs';
|
|
13
|
+
import { takeUntil } from 'rxjs/operators';
|
|
14
|
+
let CatalogSelectComponent = class CatalogSelectComponent {
|
|
15
|
+
catalogService;
|
|
16
|
+
/**
|
|
17
|
+
* Lista de IDs de catálogos a mostrar en el selector
|
|
18
|
+
*/
|
|
19
|
+
catalogIds = [];
|
|
20
|
+
/**
|
|
21
|
+
* ID del catálogo actualmente seleccionado (opcional, para valor inicial)
|
|
22
|
+
*/
|
|
23
|
+
selectedCatalogId;
|
|
24
|
+
/**
|
|
25
|
+
* Placeholder del select de catálogos
|
|
26
|
+
*/
|
|
27
|
+
placeholder = 'Selecciona un catálogo';
|
|
28
|
+
/**
|
|
29
|
+
* Label del selector
|
|
30
|
+
*/
|
|
31
|
+
label = 'Catálogo';
|
|
32
|
+
/**
|
|
33
|
+
* Emite el ID del catálogo seleccionado
|
|
34
|
+
*/
|
|
35
|
+
catalogSelected = new EventEmitter();
|
|
36
|
+
/**
|
|
37
|
+
* Emite el objeto Catalog completo del catálogo seleccionado
|
|
38
|
+
*/
|
|
39
|
+
catalogChange = new EventEmitter();
|
|
40
|
+
/**
|
|
41
|
+
* Emite cuando hay un error al cargar los catálogos
|
|
42
|
+
*/
|
|
43
|
+
error = new EventEmitter();
|
|
44
|
+
catalogs = [];
|
|
45
|
+
isLoading = false;
|
|
46
|
+
errorMessage = '';
|
|
47
|
+
destroy$ = new Subject();
|
|
48
|
+
constructor(catalogService) {
|
|
49
|
+
this.catalogService = catalogService;
|
|
50
|
+
}
|
|
51
|
+
ngOnInit() {
|
|
52
|
+
if (this.catalogIds && this.catalogIds.length > 0) {
|
|
53
|
+
this.loadCatalogs();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
ngOnChanges(changes) {
|
|
57
|
+
if (changes['catalogIds'] && !changes['catalogIds'].firstChange) {
|
|
58
|
+
this.loadCatalogs();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ngOnDestroy() {
|
|
62
|
+
this.destroy$.next();
|
|
63
|
+
this.destroy$.complete();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Carga la información de cada catálogo a partir de los IDs recibidos
|
|
67
|
+
*/
|
|
68
|
+
loadCatalogs() {
|
|
69
|
+
if (!this.catalogIds || this.catalogIds.length === 0) {
|
|
70
|
+
this.catalogs = [];
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
this.isLoading = true;
|
|
74
|
+
this.errorMessage = '';
|
|
75
|
+
this.catalogs = [];
|
|
76
|
+
const requests = this.catalogIds.map(id => this.catalogService.getCatalogById(id));
|
|
77
|
+
forkJoin(requests)
|
|
78
|
+
.pipe(takeUntil(this.destroy$))
|
|
79
|
+
.subscribe({
|
|
80
|
+
next: (catalogs) => {
|
|
81
|
+
this.catalogs = catalogs;
|
|
82
|
+
this.isLoading = false;
|
|
83
|
+
},
|
|
84
|
+
error: (err) => {
|
|
85
|
+
this.isLoading = false;
|
|
86
|
+
this.errorMessage = err?.message || 'Error al cargar los catálogos';
|
|
87
|
+
this.error.emit(this.errorMessage);
|
|
88
|
+
console.error('Error cargando catálogos:', err);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Maneja la selección de un catálogo en el select
|
|
94
|
+
* @param event Evento del select
|
|
95
|
+
*/
|
|
96
|
+
onCatalogSelected(event) {
|
|
97
|
+
const catalogId = Number(event.target.value);
|
|
98
|
+
const selected = this.catalogs.find(c => c.id === catalogId);
|
|
99
|
+
if (selected) {
|
|
100
|
+
this.selectedCatalogId = catalogId;
|
|
101
|
+
this.catalogSelected.emit(catalogId);
|
|
102
|
+
this.catalogChange.emit(selected);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Obtiene el nombre del catálogo para mostrar en el select
|
|
107
|
+
* @param catalog Catálogo
|
|
108
|
+
* @returns Nombre del catálogo o ID si no hay nombre
|
|
109
|
+
*/
|
|
110
|
+
getCatalogDisplayName(catalog) {
|
|
111
|
+
return catalog.name || `Catálogo ${catalog.id}`;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
__decorate([
|
|
115
|
+
Input(),
|
|
116
|
+
__metadata("design:type", Array)
|
|
117
|
+
], CatalogSelectComponent.prototype, "catalogIds", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
Input(),
|
|
120
|
+
__metadata("design:type", Number)
|
|
121
|
+
], CatalogSelectComponent.prototype, "selectedCatalogId", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
Input(),
|
|
124
|
+
__metadata("design:type", String)
|
|
125
|
+
], CatalogSelectComponent.prototype, "placeholder", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
Input(),
|
|
128
|
+
__metadata("design:type", String)
|
|
129
|
+
], CatalogSelectComponent.prototype, "label", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
Output(),
|
|
132
|
+
__metadata("design:type", Object)
|
|
133
|
+
], CatalogSelectComponent.prototype, "catalogSelected", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
Output(),
|
|
136
|
+
__metadata("design:type", Object)
|
|
137
|
+
], CatalogSelectComponent.prototype, "catalogChange", void 0);
|
|
138
|
+
__decorate([
|
|
139
|
+
Output(),
|
|
140
|
+
__metadata("design:type", Object)
|
|
141
|
+
], CatalogSelectComponent.prototype, "error", void 0);
|
|
142
|
+
CatalogSelectComponent = __decorate([
|
|
143
|
+
Component({
|
|
144
|
+
selector: 'catalog-select',
|
|
145
|
+
templateUrl: './catalog-select.component.html',
|
|
146
|
+
styleUrls: ['./catalog-select.component.css']
|
|
147
|
+
}),
|
|
148
|
+
__metadata("design:paramtypes", [CatalogService])
|
|
149
|
+
], CatalogSelectComponent);
|
|
150
|
+
export { CatalogSelectComponent };
|
|
151
|
+
//# sourceMappingURL=catalog-select.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-select.component.js","sourceRoot":"","sources":["../../../../src/lib/components/catalog-select/catalog-select.component.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n Component,\n Input,\n Output,\n EventEmitter,\n OnInit,\n OnDestroy,\n OnChanges,\n SimpleChanges\n} from '@angular/core';\nimport { CatalogService } from '../../services/catalog.service.js';\nimport { Catalog } from '../../models/catalog.model.js';\nimport { Subject, forkJoin } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\n@Component({\n selector: 'catalog-select',\n templateUrl: './catalog-select.component.html',\n styleUrls: ['./catalog-select.component.css']\n})\nexport class CatalogSelectComponent implements OnInit, OnDestroy, OnChanges {\n /**\n * Lista de IDs de catálogos a mostrar en el selector\n */\n @Input() catalogIds: number[] = [];\n\n /**\n * ID del catálogo actualmente seleccionado (opcional, para valor inicial)\n */\n @Input() selectedCatalogId?: number;\n\n /**\n * Placeholder del select de catálogos\n */\n @Input() placeholder: string = 'Selecciona un catálogo';\n\n /**\n * Label del selector\n */\n @Input() label: string = 'Catálogo';\n\n /**\n * Emite el ID del catálogo seleccionado\n */\n @Output() catalogSelected = new EventEmitter<number>();\n\n /**\n * Emite el objeto Catalog completo del catálogo seleccionado\n */\n @Output() catalogChange = new EventEmitter<Catalog>();\n\n /**\n * Emite cuando hay un error al cargar los catálogos\n */\n @Output() error = new EventEmitter<string>();\n\n catalogs: Catalog[] = [];\n isLoading: boolean = false;\n errorMessage: string = '';\n\n private destroy$ = new Subject<void>();\n\n constructor(private catalogService: CatalogService) {}\n\n ngOnInit(): void {\n if (this.catalogIds && this.catalogIds.length > 0) {\n this.loadCatalogs();\n }\n }\n\n ngOnChanges(changes: SimpleChanges): void {\n if (changes['catalogIds'] && !changes['catalogIds'].firstChange) {\n this.loadCatalogs();\n }\n }\n\n ngOnDestroy(): void {\n this.destroy$.next();\n this.destroy$.complete();\n }\n\n /**\n * Carga la información de cada catálogo a partir de los IDs recibidos\n */\n loadCatalogs(): void {\n if (!this.catalogIds || this.catalogIds.length === 0) {\n this.catalogs = [];\n return;\n }\n\n this.isLoading = true;\n this.errorMessage = '';\n this.catalogs = [];\n\n const requests = this.catalogIds.map(id =>\n this.catalogService.getCatalogById(id)\n );\n\n forkJoin(requests)\n .pipe(takeUntil(this.destroy$))\n .subscribe({\n next: (catalogs: Catalog[]) => {\n this.catalogs = catalogs;\n this.isLoading = false;\n },\n error: (err: any) => {\n this.isLoading = false;\n this.errorMessage = err?.message || 'Error al cargar los catálogos';\n this.error.emit(this.errorMessage);\n console.error('Error cargando catálogos:', err);\n }\n });\n }\n\n /**\n * Maneja la selección de un catálogo en el select\n * @param event Evento del select\n */\n onCatalogSelected(event: any): void {\n const catalogId = Number(event.target.value);\n const selected = this.catalogs.find(c => c.id === catalogId);\n\n if (selected) {\n this.selectedCatalogId = catalogId;\n this.catalogSelected.emit(catalogId);\n this.catalogChange.emit(selected);\n }\n }\n\n /**\n * Obtiene el nombre del catálogo para mostrar en el select\n * @param catalog Catálogo\n * @returns Nombre del catálogo o ID si no hay nombre\n */\n getCatalogDisplayName(catalog: Catalog): string {\n return catalog.name || `Catálogo ${catalog.id}`;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,0DAA0D,CAAC;AACzE,cAAc,8CAA8C,CAAC","sourcesContent":["export * from './catalog-items-select/catalog-items-select.component.js';\nexport * from './catalog-select/catalog-select.component.js';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuración de la librería de Catálogos
|
|
3
|
+
*/
|
|
4
|
+
export interface CatalogConfig {
|
|
5
|
+
/**
|
|
6
|
+
* URL base del servicio de catálogos
|
|
7
|
+
* Ejemplo: 'http://localhost:3001/api'
|
|
8
|
+
*/
|
|
9
|
+
apiBaseUrl: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Token de inyección para la configuración
|
|
13
|
+
*/
|
|
14
|
+
export declare const CATALOG_CONFIG_TOKEN = "CATALOG_CONFIG";
|
|
15
|
+
//# sourceMappingURL=catalog.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.config.d.ts","sourceRoot":"","sources":["../../../src/lib/config/catalog.config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.config.js","sourceRoot":"","sources":["../../../src/lib/config/catalog.config.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC","sourcesContent":["/**\n * Configuración de la librería de Catálogos\n */\nexport interface CatalogConfig {\n /**\n * URL base del servicio de catálogos\n * Ejemplo: 'http://localhost:3001/api'\n */\n apiBaseUrl: string;\n}\n\n/**\n * Token de inyección para la configuración\n */\nexport const CATALOG_CONFIG_TOKEN = 'CATALOG_CONFIG';\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interfaz para representar un Catálogo
|
|
3
|
+
*/
|
|
4
|
+
export interface Catalog {
|
|
5
|
+
id: number;
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Interfaz para representar un Item de Catálogo
|
|
11
|
+
*/
|
|
12
|
+
export interface CatalogItem {
|
|
13
|
+
id: number;
|
|
14
|
+
catalogId: number;
|
|
15
|
+
name: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interfaz para la respuesta de error de la API
|
|
21
|
+
*/
|
|
22
|
+
export interface ApiErrorResponse {
|
|
23
|
+
message: string;
|
|
24
|
+
status?: number;
|
|
25
|
+
error?: any;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=catalog.model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.model.d.ts","sourceRoot":"","sources":["../../../src/lib/models/catalog.model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.model.js","sourceRoot":"","sources":["../../../src/lib/models/catalog.model.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interfaz para representar un Catálogo\n */\nexport interface Catalog {\n id: number;\n name: string;\n description?: string;\n}\n\n/**\n * Interfaz para representar un Item de Catálogo\n */\nexport interface CatalogItem {\n id: number;\n catalogId: number;\n name: string;\n description?: string;\n [key: string]: any;\n}\n\n/**\n * Interfaz para la respuesta de error de la API\n */\nexport interface ApiErrorResponse {\n message: string;\n status?: number;\n error?: any;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC","sourcesContent":["export * from './catalog.model.js';\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HttpClient } from '@angular/common/http';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { Catalog, CatalogItem } from '../models/catalog.model.js';
|
|
4
|
+
import type { CatalogConfig } from '../config/catalog.config.js';
|
|
5
|
+
export declare class CatalogService {
|
|
6
|
+
private http;
|
|
7
|
+
private apiBaseUrl;
|
|
8
|
+
constructor(http: HttpClient, config: CatalogConfig);
|
|
9
|
+
/**
|
|
10
|
+
* Obtiene todos los catálogos disponibles
|
|
11
|
+
* @returns Observable con la lista de catálogos
|
|
12
|
+
*/
|
|
13
|
+
getCatalogs(): Observable<Catalog[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Obtiene un catálogo específico por su ID
|
|
16
|
+
* @param catalogId ID del catálogo
|
|
17
|
+
* @returns Observable con los datos del catálogo
|
|
18
|
+
*/
|
|
19
|
+
getCatalogById(catalogId: number): Observable<Catalog>;
|
|
20
|
+
/**
|
|
21
|
+
* Obtiene todos los items de un catálogo específico
|
|
22
|
+
* @param catalogId ID del catálogo
|
|
23
|
+
* @returns Observable con la lista de items
|
|
24
|
+
*/
|
|
25
|
+
getItemsByCatalogId(catalogId: number): Observable<CatalogItem[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Obtiene un item específico por su ID
|
|
28
|
+
* @param itemId ID del item
|
|
29
|
+
* @returns Observable con los datos del item
|
|
30
|
+
*/
|
|
31
|
+
getItemById(itemId: number): Observable<CatalogItem>;
|
|
32
|
+
/**
|
|
33
|
+
* Maneja los errores de las peticiones HTTP
|
|
34
|
+
* @param error Error de la petición
|
|
35
|
+
* @returns Observable con el error
|
|
36
|
+
*/
|
|
37
|
+
private handleError;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=catalog.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.service.d.ts","sourceRoot":"","sources":["../../../src/lib/services/catalog.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAc,MAAM,MAAM,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAoB,MAAM,4BAA4B,CAAC;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,qBAGa,cAAc;IAIvB,OAAO,CAAC,IAAI;IAHd,OAAO,CAAC,UAAU,CAAS;gBAGjB,IAAI,EAAE,UAAU,EACM,MAAM,EAAE,aAAa;IAKrD;;;OAGG;IACH,WAAW,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;IAOpC;;;;OAIG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC;IAOtD;;;;OAIG;IACH,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,EAAE,CAAC;IAOjE;;;;OAIG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC;IAOpD;;;;OAIG;IACH,OAAO,CAAC,WAAW;CASpB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Injectable, Inject } from '@angular/core';
|
|
14
|
+
import { HttpClient } from '@angular/common/http';
|
|
15
|
+
import { throwError } from 'rxjs';
|
|
16
|
+
import { catchError } from 'rxjs/operators';
|
|
17
|
+
import { CATALOG_CONFIG_TOKEN } from '../config/catalog.config.js';
|
|
18
|
+
let CatalogService = class CatalogService {
|
|
19
|
+
http;
|
|
20
|
+
apiBaseUrl;
|
|
21
|
+
constructor(http, config) {
|
|
22
|
+
this.http = http;
|
|
23
|
+
this.apiBaseUrl = config.apiBaseUrl;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Obtiene todos los catálogos disponibles
|
|
27
|
+
* @returns Observable con la lista de catálogos
|
|
28
|
+
*/
|
|
29
|
+
getCatalogs() {
|
|
30
|
+
return this.http.get(`${this.apiBaseUrl}/catalogs`)
|
|
31
|
+
.pipe(catchError(this.handleError));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Obtiene un catálogo específico por su ID
|
|
35
|
+
* @param catalogId ID del catálogo
|
|
36
|
+
* @returns Observable con los datos del catálogo
|
|
37
|
+
*/
|
|
38
|
+
getCatalogById(catalogId) {
|
|
39
|
+
return this.http.get(`${this.apiBaseUrl}/catalogs/${catalogId}`)
|
|
40
|
+
.pipe(catchError(this.handleError));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Obtiene todos los items de un catálogo específico
|
|
44
|
+
* @param catalogId ID del catálogo
|
|
45
|
+
* @returns Observable con la lista de items
|
|
46
|
+
*/
|
|
47
|
+
getItemsByCatalogId(catalogId) {
|
|
48
|
+
return this.http.get(`${this.apiBaseUrl}/catalogs/${catalogId}/items`)
|
|
49
|
+
.pipe(catchError(this.handleError));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Obtiene un item específico por su ID
|
|
53
|
+
* @param itemId ID del item
|
|
54
|
+
* @returns Observable con los datos del item
|
|
55
|
+
*/
|
|
56
|
+
getItemById(itemId) {
|
|
57
|
+
return this.http.get(`${this.apiBaseUrl}/items/${itemId}`)
|
|
58
|
+
.pipe(catchError(this.handleError));
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Maneja los errores de las peticiones HTTP
|
|
62
|
+
* @param error Error de la petición
|
|
63
|
+
* @returns Observable con el error
|
|
64
|
+
*/
|
|
65
|
+
handleError(error) {
|
|
66
|
+
const errorResponse = {
|
|
67
|
+
message: error.message || 'Error en la petición',
|
|
68
|
+
status: error.status,
|
|
69
|
+
error: error.error
|
|
70
|
+
};
|
|
71
|
+
console.error('Error en CatalogService:', errorResponse);
|
|
72
|
+
return throwError(() => errorResponse);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
CatalogService = __decorate([
|
|
76
|
+
Injectable({
|
|
77
|
+
providedIn: 'root'
|
|
78
|
+
}),
|
|
79
|
+
__param(1, Inject(CATALOG_CONFIG_TOKEN)),
|
|
80
|
+
__metadata("design:paramtypes", [HttpClient, Object])
|
|
81
|
+
], CatalogService);
|
|
82
|
+
export { CatalogService };
|
|
83
|
+
//# sourceMappingURL=catalog.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.service.js","sourceRoot":"","sources":["../../../src/lib/services/catalog.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAc,UAAU,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAM5D,IAAM,cAAc,GAApB,MAAM,cAAc;IAIf;IAHF,UAAU,CAAS;IAE3B,YACU,IAAgB,EACM,MAAqB;QAD3C,SAAI,GAAJ,IAAI,CAAY;QAGxB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAY,GAAG,IAAI,CAAC,UAAU,WAAW,CAAC;aAC3D,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,SAAiB;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,GAAG,IAAI,CAAC,UAAU,aAAa,SAAS,EAAE,CAAC;aACtE,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,mBAAmB,CAAC,SAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAgB,GAAG,IAAI,CAAC,UAAU,aAAa,SAAS,QAAQ,CAAC;aAClF,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,MAAc;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAc,GAAG,IAAI,CAAC,UAAU,UAAU,MAAM,EAAE,CAAC;aACpE,IAAI,CACH,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAC7B,CAAC;IACN,CAAC;IAED;;;;OAIG;IACK,WAAW,CAAC,KAAU;QAC5B,MAAM,aAAa,GAAqB;YACtC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,sBAAsB;YAChD,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;QACF,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;QACzD,OAAO,UAAU,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAvEY,cAAc;IAH1B,UAAU,CAAC;QACV,UAAU,EAAE,MAAM;KACnB,CAAC;IAMG,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;qCADf,UAAU;GAJf,cAAc,CAuE1B","sourcesContent":["import { Injectable, Inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Observable, throwError } from 'rxjs';\nimport { catchError } from 'rxjs/operators';\nimport { Catalog, CatalogItem, ApiErrorResponse } from '../models/catalog.model.js';\nimport { CATALOG_CONFIG_TOKEN } from '../config/catalog.config.js';\nimport type { CatalogConfig } from '../config/catalog.config.js';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class CatalogService {\n private apiBaseUrl: string;\n\n constructor(\n private http: HttpClient,\n @Inject(CATALOG_CONFIG_TOKEN) config: CatalogConfig\n ) {\n this.apiBaseUrl = config.apiBaseUrl;\n }\n\n /**\n * Obtiene todos los catálogos disponibles\n * @returns Observable con la lista de catálogos\n */\n getCatalogs(): Observable<Catalog[]> {\n return this.http.get<Catalog[]>(`${this.apiBaseUrl}/catalogs`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Obtiene un catálogo específico por su ID\n * @param catalogId ID del catálogo\n * @returns Observable con los datos del catálogo\n */\n getCatalogById(catalogId: number): Observable<Catalog> {\n return this.http.get<Catalog>(`${this.apiBaseUrl}/catalogs/${catalogId}`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Obtiene todos los items de un catálogo específico\n * @param catalogId ID del catálogo\n * @returns Observable con la lista de items\n */\n getItemsByCatalogId(catalogId: number): Observable<CatalogItem[]> {\n return this.http.get<CatalogItem[]>(`${this.apiBaseUrl}/catalogs/${catalogId}/items`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Obtiene un item específico por su ID\n * @param itemId ID del item\n * @returns Observable con los datos del item\n */\n getItemById(itemId: number): Observable<CatalogItem> {\n return this.http.get<CatalogItem>(`${this.apiBaseUrl}/items/${itemId}`)\n .pipe(\n catchError(this.handleError)\n );\n }\n\n /**\n * Maneja los errores de las peticiones HTTP\n * @param error Error de la petición\n * @returns Observable con el error\n */\n private handleError(error: any) {\n const errorResponse: ApiErrorResponse = {\n message: error.message || 'Error en la petición',\n status: error.status,\n error: error.error\n };\n console.error('Error en CatalogService:', errorResponse);\n return throwError(() => errorResponse);\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './catalog.service.js';\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exporta todos los módulos, servicios y componentes públicos de la librería
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/catalog.module.js';
|
|
5
|
+
export * from './lib/services/index.js';
|
|
6
|
+
export * from './lib/models/index.js';
|
|
7
|
+
export * from './lib/components/index.js';
|
|
8
|
+
export * from './lib/config/catalog.config.js';
|
|
9
|
+
//# sourceMappingURL=public-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exporta todos los módulos, servicios y componentes públicos de la librería
|
|
3
|
+
*/
|
|
4
|
+
export * from './lib/catalog.module.js';
|
|
5
|
+
export * from './lib/services/index.js';
|
|
6
|
+
export * from './lib/models/index.js';
|
|
7
|
+
export * from './lib/components/index.js';
|
|
8
|
+
export * from './lib/config/catalog.config.js';
|
|
9
|
+
//# sourceMappingURL=public-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC","sourcesContent":["/**\n * Exporta todos los módulos, servicios y componentes públicos de la librería\n */\nexport * from './lib/catalog.module.js';\nexport * from './lib/services/index.js';\nexport * from './lib/models/index.js';\nexport * from './lib/components/index.js';\nexport * from './lib/config/catalog.config.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chaqui-catalog-frontend-lib",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "Librería Angular para consumir el servicio de catálogos",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"description": "Librería Angular para consumir el servicio de catálogos, los componentes son standalone",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "ISC",
|
|
@@ -35,8 +35,11 @@
|
|
|
35
35
|
"typescript": "~5.6.0",
|
|
36
36
|
"zone.js": "^0.15.0"
|
|
37
37
|
},
|
|
38
|
+
"main": "./dist/public-api.js",
|
|
39
|
+
"types": "./dist/public-api.d.ts",
|
|
38
40
|
"exports": {
|
|
39
41
|
".": {
|
|
42
|
+
"types": "./dist/public-api.d.ts",
|
|
40
43
|
"import": "./dist/public-api.js",
|
|
41
44
|
"require": "./dist/public-api.js"
|
|
42
45
|
}
|
|
@@ -2,14 +2,14 @@ import { NgModule, ModuleWithProviders } from '@angular/core';
|
|
|
2
2
|
import { CommonModule } from '@angular/common';
|
|
3
3
|
import { HttpClientModule } from '@angular/common/http';
|
|
4
4
|
import { CatalogItemsSelectComponent } from './components/catalog-items-select/catalog-items-select.component.js';
|
|
5
|
+
import { CatalogSelectComponent } from './components/catalog-select/catalog-select.component.js';
|
|
5
6
|
import { CatalogService } from './services/catalog.service.js';
|
|
6
7
|
import { CATALOG_CONFIG_TOKEN } from './config/catalog.config.js';
|
|
7
8
|
import type { CatalogConfig } from './config/catalog.config.js';
|
|
8
9
|
|
|
9
10
|
@NgModule({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports: [CatalogItemsSelectComponent]
|
|
11
|
+
imports: [CommonModule, HttpClientModule, CatalogItemsSelectComponent, CatalogSelectComponent],
|
|
12
|
+
exports: [CatalogItemsSelectComponent, CatalogSelectComponent]
|
|
13
13
|
})
|
|
14
14
|
export class CatalogModule {
|
|
15
15
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
1
2
|
import { Component, Input, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
3
|
import { CatalogService } from '../../services/catalog.service.js';
|
|
3
4
|
import { CatalogItem } from '../../models/catalog.model.js';
|
|
@@ -6,6 +7,8 @@ import { takeUntil } from 'rxjs/operators';
|
|
|
6
7
|
|
|
7
8
|
@Component({
|
|
8
9
|
selector: 'catalog-items-select',
|
|
10
|
+
standalone: true,
|
|
11
|
+
imports: [CommonModule],
|
|
9
12
|
templateUrl: './catalog-items-select.component.html',
|
|
10
13
|
styleUrls: ['./catalog-items-select.component.css']
|
|
11
14
|
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.catalog-select-container {
|
|
2
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
3
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
4
|
+
sans-serif;
|
|
5
|
+
-webkit-font-smoothing: antialiased;
|
|
6
|
+
-moz-osx-font-smoothing: grayscale;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.form-group {
|
|
10
|
+
margin-bottom: 1.5rem;
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.form-label {
|
|
16
|
+
margin-bottom: 0.5rem;
|
|
17
|
+
font-weight: 500;
|
|
18
|
+
color: #333;
|
|
19
|
+
font-size: 0.95rem;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.form-select {
|
|
23
|
+
padding: 0.75rem;
|
|
24
|
+
border: 1px solid #ddd;
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
font-size: 1rem;
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.form-select:focus {
|
|
32
|
+
outline: none;
|
|
33
|
+
border-color: #0066cc;
|
|
34
|
+
box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.form-select:disabled {
|
|
38
|
+
background-color: #f5f5f5;
|
|
39
|
+
color: #999;
|
|
40
|
+
cursor: not-allowed;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.loading {
|
|
44
|
+
color: #666;
|
|
45
|
+
font-style: italic;
|
|
46
|
+
padding: 0.75rem;
|
|
47
|
+
text-align: center;
|
|
48
|
+
background-color: #f0f0f0;
|
|
49
|
+
border-radius: 4px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.error-message {
|
|
53
|
+
color: #d32f2f;
|
|
54
|
+
background-color: #ffebee;
|
|
55
|
+
padding: 0.75rem;
|
|
56
|
+
border-radius: 4px;
|
|
57
|
+
border-left: 4px solid #d32f2f;
|
|
58
|
+
font-size: 0.9rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.no-items {
|
|
62
|
+
color: #666;
|
|
63
|
+
padding: 0.75rem;
|
|
64
|
+
text-align: center;
|
|
65
|
+
background-color: #f5f5f5;
|
|
66
|
+
border-radius: 4px;
|
|
67
|
+
font-style: italic;
|
|
68
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<div class="catalog-select-container">
|
|
2
|
+
<div class="form-group">
|
|
3
|
+
<label for="catalogSelect" class="form-label">{{ label }}</label>
|
|
4
|
+
|
|
5
|
+
<div *ngIf="isLoading" class="loading">
|
|
6
|
+
Cargando catálogos...
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div *ngIf="errorMessage && !isLoading" class="error-message">
|
|
10
|
+
{{ errorMessage }}
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<select
|
|
14
|
+
*ngIf="!isLoading && !errorMessage"
|
|
15
|
+
id="catalogSelect"
|
|
16
|
+
class="form-select"
|
|
17
|
+
[value]="selectedCatalogId || ''"
|
|
18
|
+
(change)="onCatalogSelected($event)"
|
|
19
|
+
>
|
|
20
|
+
<option value="">{{ placeholder }}</option>
|
|
21
|
+
<option *ngFor="let catalog of catalogs" [value]="catalog.id">
|
|
22
|
+
{{ getCatalogDisplayName(catalog) }}
|
|
23
|
+
</option>
|
|
24
|
+
</select>
|
|
25
|
+
|
|
26
|
+
<div *ngIf="!isLoading && catalogs.length === 0 && !errorMessage && catalogIds.length > 0" class="no-items">
|
|
27
|
+
No hay catálogos disponibles
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
Input,
|
|
4
|
+
Output,
|
|
5
|
+
EventEmitter,
|
|
6
|
+
OnInit,
|
|
7
|
+
OnDestroy,
|
|
8
|
+
OnChanges,
|
|
9
|
+
SimpleChanges
|
|
10
|
+
} from '@angular/core';
|
|
11
|
+
import { CommonModule } from '@angular/common';
|
|
12
|
+
import { CatalogService } from '../../services/catalog.service.js';
|
|
13
|
+
import { Catalog } from '../../models/catalog.model.js';
|
|
14
|
+
import { Subject, forkJoin } from 'rxjs';
|
|
15
|
+
import { takeUntil } from 'rxjs/operators';
|
|
16
|
+
|
|
17
|
+
@Component({
|
|
18
|
+
selector: 'catalog-select',
|
|
19
|
+
standalone: true,
|
|
20
|
+
imports: [CommonModule],
|
|
21
|
+
templateUrl: './catalog-select.component.html',
|
|
22
|
+
styleUrls: ['./catalog-select.component.css']
|
|
23
|
+
})
|
|
24
|
+
export class CatalogSelectComponent implements OnInit, OnDestroy, OnChanges {
|
|
25
|
+
/**
|
|
26
|
+
* Lista de IDs de catálogos a mostrar en el selector
|
|
27
|
+
*/
|
|
28
|
+
@Input() catalogIds: number[] = [];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* ID del catálogo actualmente seleccionado (opcional, para valor inicial)
|
|
32
|
+
*/
|
|
33
|
+
@Input() selectedCatalogId?: number;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Placeholder del select de catálogos
|
|
37
|
+
*/
|
|
38
|
+
@Input() placeholder: string = 'Selecciona un catálogo';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Label del selector
|
|
42
|
+
*/
|
|
43
|
+
@Input() label: string = 'Catálogo';
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Emite el ID del catálogo seleccionado
|
|
47
|
+
*/
|
|
48
|
+
@Output() catalogSelected = new EventEmitter<number>();
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Emite el objeto Catalog completo del catálogo seleccionado
|
|
52
|
+
*/
|
|
53
|
+
@Output() catalogChange = new EventEmitter<Catalog>();
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Emite cuando hay un error al cargar los catálogos
|
|
57
|
+
*/
|
|
58
|
+
@Output() error = new EventEmitter<string>();
|
|
59
|
+
|
|
60
|
+
catalogs: Catalog[] = [];
|
|
61
|
+
isLoading: boolean = false;
|
|
62
|
+
errorMessage: string = '';
|
|
63
|
+
|
|
64
|
+
private destroy$ = new Subject<void>();
|
|
65
|
+
|
|
66
|
+
constructor(private catalogService: CatalogService) {}
|
|
67
|
+
|
|
68
|
+
ngOnInit(): void {
|
|
69
|
+
if (this.catalogIds && this.catalogIds.length > 0) {
|
|
70
|
+
this.loadCatalogs();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
75
|
+
if (changes['catalogIds'] && !changes['catalogIds'].firstChange) {
|
|
76
|
+
this.loadCatalogs();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
ngOnDestroy(): void {
|
|
81
|
+
this.destroy$.next();
|
|
82
|
+
this.destroy$.complete();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Carga la información de cada catálogo a partir de los IDs recibidos
|
|
87
|
+
*/
|
|
88
|
+
loadCatalogs(): void {
|
|
89
|
+
if (!this.catalogIds || this.catalogIds.length === 0) {
|
|
90
|
+
this.catalogs = [];
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.isLoading = true;
|
|
95
|
+
this.errorMessage = '';
|
|
96
|
+
this.catalogs = [];
|
|
97
|
+
|
|
98
|
+
const requests = this.catalogIds.map(id =>
|
|
99
|
+
this.catalogService.getCatalogById(id)
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
forkJoin(requests)
|
|
103
|
+
.pipe(takeUntil(this.destroy$))
|
|
104
|
+
.subscribe({
|
|
105
|
+
next: (catalogs: Catalog[]) => {
|
|
106
|
+
this.catalogs = catalogs;
|
|
107
|
+
this.isLoading = false;
|
|
108
|
+
},
|
|
109
|
+
error: (err: any) => {
|
|
110
|
+
this.isLoading = false;
|
|
111
|
+
this.errorMessage = err?.message || 'Error al cargar los catálogos';
|
|
112
|
+
this.error.emit(this.errorMessage);
|
|
113
|
+
console.error('Error cargando catálogos:', err);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Maneja la selección de un catálogo en el select
|
|
120
|
+
* @param event Evento del select
|
|
121
|
+
*/
|
|
122
|
+
onCatalogSelected(event: any): void {
|
|
123
|
+
const catalogId = Number(event.target.value);
|
|
124
|
+
const selected = this.catalogs.find(c => c.id === catalogId);
|
|
125
|
+
|
|
126
|
+
if (selected) {
|
|
127
|
+
this.selectedCatalogId = catalogId;
|
|
128
|
+
this.catalogSelected.emit(catalogId);
|
|
129
|
+
this.catalogChange.emit(selected);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Obtiene el nombre del catálogo para mostrar en el select
|
|
135
|
+
* @param catalog Catálogo
|
|
136
|
+
* @returns Nombre del catálogo o ID si no hay nombre
|
|
137
|
+
*/
|
|
138
|
+
getCatalogDisplayName(catalog: Catalog): string {
|
|
139
|
+
return catalog.name || `Catálogo ${catalog.id}`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -30,6 +30,18 @@ export class CatalogService {
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Obtiene un catálogo específico por su ID
|
|
35
|
+
* @param catalogId ID del catálogo
|
|
36
|
+
* @returns Observable con los datos del catálogo
|
|
37
|
+
*/
|
|
38
|
+
getCatalogById(catalogId: number): Observable<Catalog> {
|
|
39
|
+
return this.http.get<Catalog>(`${this.apiBaseUrl}/catalogs/${catalogId}`)
|
|
40
|
+
.pipe(
|
|
41
|
+
catchError(this.handleError)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
33
45
|
/**
|
|
34
46
|
* Obtiene todos los items de un catálogo específico
|
|
35
47
|
* @param catalogId ID del catálogo
|