bitfront-library
Version:
Angular CLI project with components and classes used by other Angular projects of the BIT foundation.
64 lines • 2.73 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseDialogFormComponent = void 0;
var core_1 = require("@angular/core");
var shared_1 = require("../../shared");
var i0 = require("@angular/core");
/**
* Componente base para implementar diálogos con un formulario. Típico caso de representación de sublistas
*/
var BaseDialogFormComponent = /** @class */ (function () {
function BaseDialogFormComponent() {
this.onSaveItem = new core_1.EventEmitter(true);
this.onDeleteItem = new core_1.EventEmitter(true);
this.onClose = new core_1.EventEmitter(true);
}
BaseDialogFormComponent.prototype.ngOnInit = function () {
if (!this.item) {
this.item = {};
}
this.myForm = this.createFormGroup();
};
BaseDialogFormComponent.prototype.saveItem = function () {
var mensajeConfirmacion = this.item.id
? "Està segur que desitja modificar aquest element?"
: "Està segur que desitja inserir el nou element?";
if (confirm(mensajeConfirmacion)) {
Object.assign(this.item, this.myForm.value);
this.onSaveItem.emit(this.item);
}
};
BaseDialogFormComponent.prototype.deleteItem = function () {
if (confirm("Està segur que desitja eliminar aquest element?")) {
this.onDeleteItem.emit(this.item.id);
}
};
BaseDialogFormComponent.prototype.closeForm = function () {
this.onClose.emit(this.item);
};
Object.defineProperty(BaseDialogFormComponent.prototype, "isEditMode", {
get: function () {
return this.mode === shared_1.FormType.Update;
},
enumerable: false,
configurable: true
});
BaseDialogFormComponent.ɵfac = function BaseDialogFormComponent_Factory(t) { return new (t || BaseDialogFormComponent)(); };
BaseDialogFormComponent.ɵdir = i0.ɵɵdefineDirective({ type: BaseDialogFormComponent, inputs: { display: "display", mode: "mode" }, outputs: { onSaveItem: "onSaveItem", onDeleteItem: "onDeleteItem", onClose: "onClose" } });
return BaseDialogFormComponent;
}());
exports.BaseDialogFormComponent = BaseDialogFormComponent;
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseDialogFormComponent, [{
type: core_1.Directive
}], null, { display: [{
type: core_1.Input
}], mode: [{
type: core_1.Input
}], onSaveItem: [{
type: core_1.Output
}], onDeleteItem: [{
type: core_1.Output
}], onClose: [{
type: core_1.Output
}] }); })();
//# sourceMappingURL=base-dialog-form.component.js.map