UNPKG

bitcitawebfrontlib-ibsalut

Version:

Angular CLI project used by other Angular projects in the bitcita web project.<br />

185 lines 12.9 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var core_2 = require("@ngx-translate/core"); var campanya_service_1 = require("../../common/service/campanya.service"); var reservar_cita_paso_1 = require("./reservar-cita-paso"); var domain_1 = require("../../common/data/domain"); var message_service_1 = require("../../shared/service/message.service"); var idioma_1 = require("../../shared/data/idioma"); var error_1 = require("../../shared/data/error"); var general_utils_service_1 = require("../../shared/service/general-utils.service"); var SeleccionarServicioComponent = /** @class */ (function (_super) { __extends(SeleccionarServicioComponent, _super); function SeleccionarServicioComponent(campanyaService, translate, message) { var _this = _super.call(this, "SeleccionarServicioComponent", campanyaService) || this; _this.campanyaService = campanyaService; _this.translate = translate; _this.message = message; _this.soloUnServicio = false; _this.soloUnSitio = false; return _this; } /// Comportamiento general del paso (sobrescribe lo definido en ReservaCitaPaso) /// SeleccionarServicioComponent.prototype.loadDatosInicio = function () { this.loadCampañas(); }; SeleccionarServicioComponent.prototype.loadCampañas = function () { var _this = this; this.campanyaService.findServicios(this.peticion.referencia).subscribe(function (result) { if (result.length == 1) { // si solo hay un servicio, se preselecciona y se oculta la seleccion de servicios _this.soloUnServicio = true; _this.peticion.servicioId = +result[0].value; } _this.listServicio = general_utils_service_1.GeneralUtils.addOpcionVacia(result); _this.loadSitios(); }); }; SeleccionarServicioComponent.prototype.loadSitios = function () { var _this = this; // Cargar sitios this.campanyaService.findSitios(this.peticion.referencia).subscribe(function (result) { if (result.length == 1) { _this.soloUnSitio = true; _this.peticion.sitioId = +result[0].value; _this.listSitio = result; } else { _this.peticion.sitioId = null; _this.listSitio = general_utils_service_1.GeneralUtils.addOpcionVacia(result); } if (_this.peticion.servicioId) { _this.changeServicio(); } else { _this.loadEntidades(); } }); }; SeleccionarServicioComponent.prototype.validarPaso = function () { var _this = this; if (this.peticion.servicioId && this.peticion.sitioId && this.peticion.entidadId) { return true; } else { this.translate.get("error.servicioSitioEntidad").subscribe(function (result) { var err = new error_1.Error(null, idioma_1.Idioma.esCatalanSeleccionado() ? result : null, idioma_1.Idioma.esEspanyolSeleccionado() ? result : null, null, true); _this.message.sendError(err); }); } }; SeleccionarServicioComponent.prototype.updateReservaCita = function () { if (this.listServicio) { this.resumen.servicioNombre = general_utils_service_1.GeneralUtils.getOptionText(this.listServicio, this.peticion.servicioId); } if (this.listSitio) { this.resumen.sitioNombre = general_utils_service_1.GeneralUtils.getOptionText(this.listSitio, this.peticion.sitioId); } if (this.listEntidad) { this.resumen.entidadNombre = general_utils_service_1.GeneralUtils.getOptionText(this.listEntidad, this.peticion.entidadId); } if (this.listRecurso) { this.resumen.recursoNombre = general_utils_service_1.GeneralUtils.getOptionText(this.listRecurso, this.peticion.recursoId); } }; SeleccionarServicioComponent.prototype.resetActions = function () { // Inicializar campos seleccionados en objeto peticion // Si hay más de un sitio se debe seleccionar uno if (!this.soloUnSitio) this.peticion.sitioId = null; this.peticion.entidadId = null; this.peticion.recursoId = null; this.listEntidad = null; this.listRecurso = null; if (this.soloUnServicio) { // Si solo hay un servicio, se preselecciona this.changeServicio(); // al hacer reset (volver al primer paso) existe el valor peticion.servicioId // se recarga la informacion del servicio en el resumen y la lista de entidades del servicio } }; SeleccionarServicioComponent.prototype.back = function () { window.history.back(); }; /// Comportamiento propio de este paso /// SeleccionarServicioComponent.prototype.changeServicio = function () { var _this = this; if (this.peticion.servicioId) { this.campanyaService.findServicio(this.peticion.referencia, this.peticion.servicioId).subscribe(function (result) { _this.resumen.servicio = result; }); this.loadEntidades(); } }; SeleccionarServicioComponent.prototype.changeSitio = function () { this.loadEntidades(); }; SeleccionarServicioComponent.prototype.loadEntidades = function () { var _this = this; if (this.peticion.servicioId && this.peticion.sitioId) { this.campanyaService .findEntidades(this.peticion.referencia, this.peticion.servicioId, this.peticion.sitioId) .subscribe(function (result) { if (result.length == 1) { _this.peticion.entidadId = +result[0].value; _this.listEntidad = result; _this.changeEntidad(); } else { _this.peticion.entidadId = null; _this.listEntidad = general_utils_service_1.GeneralUtils.addOpcionVacia(result); } }); } else { this.translate.get("info.seleccioneServicioSitio").subscribe(function (result) { _this.listEntidad = [new domain_1.Domain(null, result)]; }); } }; SeleccionarServicioComponent.prototype.changeEntidad = function () { var _this = this; if (this.peticion.entidadId && this.resumen.servicio && this.resumen.servicio.permiteSeleccionRecurso) { this.campanyaService .findRecursosDeEntidad(this.peticion.referencia, this.peticion.entidadId, this.peticion.servicioId) .subscribe(function (result) { // La seleccion del recurso es opcional _this.listRecurso = general_utils_service_1.GeneralUtils.addOpcionVacia(result); }); } }; SeleccionarServicioComponent = __decorate([ core_1.Component({ selector: "bci-seleccionar-servicio", template: "\n <div class=\"paso\" [style.display]=\"visible?'block':'none'\">\n <h4><span class=\"fa fa-check-square-o\"></span>&nbsp;&nbsp;<span translate=\"titulo.seleccionarServicio\">Introducció i selecció de servei</span></h4>\n \n <!-- ng-template #SeleccionarServicioCustom><ng-content select=\"[SeleccionarServicioCustom]\"></ng-content></ng-template>\n <ng-container *ngTemplateOutlet=\"SeleccionarServicioCustom\"></ng-container -->\n <ng-container *ngIf=\"textoServicioSeleccion\">\n <div class=\"contenedor-texto-dinamico ql-editor\">\n <div class=\"row\">\n <div [innerHTML]=\"textoServicioSeleccion | sanitizeInnerHtml\" class=\"col-sm-12\"></div>\n </div>\n </div>\n </ng-container>\n <ng-container *ngIf=\"textoServicioQueNecesito\">\n <div class=\"contenedor-texto-dinamico ql-editor\">\n <div class=\"row\">\n <div [innerHTML]=\"textoServicioQueNecesito | sanitizeInnerHtml\" class=\"col-sm-12\"></div>\n </div>\n </div>\n </ng-container>\n <ng-container *ngIf=\"textoOficinaSeleccion\">\n <div class=\"contenedor-texto-dinamico ql-editor\">\n <div class=\"row\">\n <div [innerHTML]=\"textoOficinaSeleccion | sanitizeInnerHtml\" class=\"col-sm-12\"></div>\n </div>\n </div>\n </ng-container>\n\n <div class=\"row\">\n <div class=\"col-sm-9 col-md-6\">\n <div class=\"form-group\" *ngIf=\"!soloUnServicio\">\n <label id=\"servicioLabel\" for=\"servicioId\" translate=\"seleccionar.servicio\">Seleccioni un servei</label>\n <p-dropdown id=\"servicioId\" [options]=\"listServicio\" [(ngModel)]=\"peticion.servicioId\" [autoWidth]=\"false\" (onChange)=\"changeServicio()\"></p-dropdown>\n </div>\n <div class=\"form-group\">\n <label id=\"sitioLabel\" for=\"sitioId\" translate=\"seleccionar.sitio\">Seleccioni un lloc</label>\n <p-dropdown id=\"sitioId\" [options]=\"listSitio\" [(ngModel)]=\"peticion.sitioId\" [autoWidth]=\"false\" (onChange)=\"changeSitio ()\"></p-dropdown>\n </div>\n <div class=\"form-group\">\n <label id=\"entidadLabel\" for=\"entidadId\" translate=\"seleccionar.entidad\">Seleccioni una oficina</label>\n <p-dropdown id=\"entidadId\" [options]=\"listEntidad\" [(ngModel)]=\"peticion.entidadId\" [autoWidth]=\"false\" (onChange)=\"changeEntidad ()\"></p-dropdown>\n </div>\n <div *ngIf=\"listRecurso\" class=\"form-group\">\n <label id=\"recursoLabel\" for=\"recursoId\" translate=\"seleccionar.recurso\">Seleccioni un tècnic</label>\n <p-dropdown id=\"recursoId\" [options]=\"listRecurso\" [(ngModel)]=\"peticion.recursoId\" [autoWidth]=\"false\"></p-dropdown>\n </div>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-xs-12\">\n <div class=\"btn-navegar\">\n <button class=\"btn btn-default pull-left\" (click)=\"back();\" *ngIf=\"existePasoAnterior\"><span class=\"fa fa-chevron-left\"></span>&nbsp;&nbsp;<span translate=\"btn.volver\">Tornar</span></button>\n <button class=\"btn btn-success pull-right\" (click)=\"goToPasoSiguiente();\"><span translate=\"btn.continuar\">Continua</span>&nbsp;&nbsp;<span class=\"fa fa-chevron-right\"></span></button>\n </div>\n </div>\n </div>\n </div>\n " }), __metadata("design:paramtypes", [campanya_service_1.CampanyaService, core_2.TranslateService, message_service_1.MessageService]) ], SeleccionarServicioComponent); return SeleccionarServicioComponent; }(reservar_cita_paso_1.ReservarCitaPaso)); exports.SeleccionarServicioComponent = SeleccionarServicioComponent; //# sourceMappingURL=1-seleccionar-servicio.component.js.map