bitfront-library
Version:
Angular CLI project with components and classes used by other Angular projects of the BIT foundation.
159 lines • 10.2 kB
JavaScript
;
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 (Object.prototype.hasOwnProperty.call(b, 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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigFormComponent = void 0;
var core_1 = require("@angular/core");
var forms_1 = require("@angular/forms");
var router_1 = require("@angular/router");
var config_1 = require("../shared/data/config");
var configuracion_service_1 = require("../shared/service/configuracion.service");
var message_service_1 = require("../../shared/service/message.service");
var toolbar_service_1 = require("../../shared/service/toolbar.service");
var base_form_component_1 = require("../../base/component/base-form.component");
var custom_validators_service_1 = require("../../shared/service/custom-validators.service");
var i0 = require("@angular/core");
var i1 = require("../shared/service/configuracion.service");
var i2 = require("@angular/router");
var i3 = require("../../shared/service/message.service");
var i4 = require("../../shared/service/toolbar.service");
var i5 = require("@angular/forms");
var i6 = require("../../shared/component/bit-header.component");
var i7 = require("primeng/accordion");
var i8 = require("../../shared/component/form/bit-text.component");
var i9 = require("../../shared/component/form/bit-textarea.component");
var i10 = require("../../shared/component/bit-footer.component");
/**
* Componente que implementa un formulario para insertar, modificar, eliminar y/o consultar un elemento de tipo Usuario.
*/
var ConfigFormComponent = /** @class */ (function (_super) {
__extends(ConfigFormComponent, _super);
function ConfigFormComponent(configService, router, activatedRoute, messageService, toolbarService, formBuilder) {
var _this = _super.call(this, configService, router, activatedRoute, messageService, toolbarService) || this;
_this.configService = configService;
_this.router = router;
_this.activatedRoute = activatedRoute;
_this.messageService = messageService;
_this.toolbarService = toolbarService;
_this.formBuilder = formBuilder;
_this.object = config_1.Config.newObject();
_this.myForm = _this.formBuilder.group({
codigo: [_this.object.codigo, [forms_1.Validators.required, custom_validators_service_1.CustomValidators.etiquetaValidator]],
valor: [_this.object.valor, []]
});
return _this;
}
/** Inicializa la ficha: lee el elemento con el id indicado e inicializa el componente. */
ConfigFormComponent.prototype.ngOnInit = function () {
var _this = this;
var id;
this.subscribeParams = this.activatedRoute.params.subscribe(function (params) {
_this.init(params["id"]);
});
};
/** Cierra la ficha: libera memoria, desvincula subscripciones, etc. */
ConfigFormComponent.prototype.ngOnDestroy = function () {
if (this.subscribeParams) {
this.subscribeParams.unsubscribe(); // necesario para evitar memory leaks
}
};
ConfigFormComponent.prototype.init = function (id) {
_super.prototype.init.call(this, id);
//definimos la miga de pan en el OnInit porque necesitamos saber si estamos editando o creando un unevo usuario
this.breadcrumb = [];
this.breadcrumb.push({ label: "Desenvolupament" });
this.breadcrumb.push({ label: "Configuració", url: "developer/config" });
if (!id) {
this.breadcrumb.push({ label: "Nou paràmetre" });
}
else {
this.breadcrumb.push({ label: "Edició de paràmetre" });
}
};
/** Limpia el formulario. */
ConfigFormComponent.prototype.cleanForm = function () {
_super.prototype.cleanForm.call(this);
this.object = config_1.Config.newObject();
};
/** Cierra el formulario y vuelve a la pantalla anterior. */
ConfigFormComponent.prototype.goBack = function () {
this.router.navigate(["developer/config"]);
};
Object.defineProperty(ConfigFormComponent.prototype, "diagnostic", {
/** Información de debug. */
get: function () {
return JSON.stringify(this.object);
},
enumerable: false,
configurable: true
});
ConfigFormComponent.prototype.save = function () {
Object.assign(this.object, this.myForm.value);
_super.prototype.save.call(this);
};
ConfigFormComponent.ɵfac = function ConfigFormComponent_Factory(t) { return new (t || ConfigFormComponent)(i0.ɵɵdirectiveInject(i1.ConfiguracionService), i0.ɵɵdirectiveInject(i2.Router), i0.ɵɵdirectiveInject(i2.ActivatedRoute), i0.ɵɵdirectiveInject(i3.MessageService), i0.ɵɵdirectiveInject(i4.ToolbarService), i0.ɵɵdirectiveInject(i5.FormBuilder)); };
ConfigFormComponent.ɵcmp = i0.ɵɵdefineComponent({ type: ConfigFormComponent, selectors: [["config-form"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 14, vars: 10, consts: [[3, "breadcrumb", "onToolbarButtonPressed"], ["role", "form", 3, "formGroup", "submit"], ["id", "seccion_0", 1, "form-group", "has-feedback"], [1, "acordeon", 3, "multiple"], ["header", "Dades del par\u00E0metre", 3, "selected"], [1, "row", "separador"], [1, "col-sm-12"], ["nombre", "codigo", 3, "readOnly", "control"], ["nombre", "valor", 3, "control"], ["type", "form", 3, "paginator", "status", "messages"]], template: function ConfigFormComponent_Template(rf, ctx) { if (rf & 1) {
i0.ɵɵelementStart(0, "bit-header", 0);
i0.ɵɵlistener("onToolbarButtonPressed", function ConfigFormComponent_Template_bit_header_onToolbarButtonPressed_0_listener($event) { return ctx.onToolbarButtonPressed($event); });
i0.ɵɵelementEnd();
i0.ɵɵelementStart(1, "form", 1);
i0.ɵɵlistener("submit", function ConfigFormComponent_Template_form_submit_1_listener() { return ctx.save(); });
i0.ɵɵelementStart(2, "div", 2);
i0.ɵɵelementStart(3, "p-accordion", 3);
i0.ɵɵelementStart(4, "p-accordionTab", 4);
i0.ɵɵelementStart(5, "div", 5);
i0.ɵɵelementStart(6, "div", 6);
i0.ɵɵelementStart(7, "bit-text", 7);
i0.ɵɵtext(8, "\u00A0\u00A0Codi");
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementStart(9, "div", 5);
i0.ɵɵelementStart(10, "div", 6);
i0.ɵɵelementStart(11, "bit-textarea", 8);
i0.ɵɵtext(12, "\u00A0\u00A0Valor");
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelementEnd();
i0.ɵɵelement(13, "bit-footer", 9);
} if (rf & 2) {
i0.ɵɵproperty("breadcrumb", ctx.breadcrumb);
i0.ɵɵadvance(1);
i0.ɵɵproperty("formGroup", ctx.myForm);
i0.ɵɵadvance(2);
i0.ɵɵproperty("multiple", true);
i0.ɵɵadvance(1);
i0.ɵɵproperty("selected", true);
i0.ɵɵadvance(3);
i0.ɵɵproperty("readOnly", ctx.isEditMode)("control", ctx.myForm.controls.codigo);
i0.ɵɵadvance(4);
i0.ɵɵproperty("control", ctx.myForm.controls.valor);
i0.ɵɵadvance(2);
i0.ɵɵproperty("paginator", false)("status", ctx.status)("messages", ctx.messages);
} }, directives: [i6.BitHeaderComponent, i5.ɵangular_packages_forms_forms_ba, i5.NgControlStatusGroup, i5.FormGroupDirective, i7.Accordion, i7.AccordionTab, i8.BitTextComponent, i9.BitTextAreaComponent, i10.BitFooterComponent], encapsulation: 2 });
return ConfigFormComponent;
}(base_form_component_1.BaseFormComponent));
exports.ConfigFormComponent = ConfigFormComponent;
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ConfigFormComponent, [{
type: core_1.Component,
args: [{
selector: "config-form",
template: "\n <bit-header [breadcrumb]=\"breadcrumb\" (onToolbarButtonPressed)=\"onToolbarButtonPressed($event)\"></bit-header>\n\n <form role=\"form\" [formGroup]=\"myForm\" (submit)=\"save()\">\n\n <div class=\"form-group has-feedback\" id=\"seccion_0\">\n <p-accordion class=\"acordeon\" [multiple]=\"true\">\n <p-accordionTab header=\"Dades del paràmetre\" [selected]=\"true\">\n <div class=\"row separador\">\n <div class=\"col-sm-12\">\n <bit-text [readOnly]=\"isEditMode\" nombre=\"codigo\" [control]=\"myForm.controls.codigo\"> Codi</bit-text>\n </div>\n </div>\n <div class=\"row separador\">\n <div class=\"col-sm-12\">\n <bit-textarea nombre=\"valor\" [control]=\"myForm.controls.valor\"> Valor</bit-textarea>\n </div>\n </div>\n </p-accordionTab>\n </p-accordion>\n </div>\n </form>\n\n <bit-footer [paginator]=\"false\" type=\"form\" [status]=\"status\" [messages]=\"messages\"></bit-footer>\n "
}]
}], function () { return [{ type: i1.ConfiguracionService }, { type: i2.Router }, { type: i2.ActivatedRoute }, { type: i3.MessageService }, { type: i4.ToolbarService }, { type: i5.FormBuilder }]; }, null); })();
//# sourceMappingURL=config-form.component.js.map