"use strict"; var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); var _, done = false; for (var i = decorators.length - 1; i >= 0; i--) { var context = {}; for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; for (var p in contextIn.access) context.access[p] = contextIn.access[p]; context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); if (kind === "accessor") { if (result === void 0) continue; if (result === null || typeof result !== "object") throw new TypeError("Object expected"); if (_ = accept(result.get)) descriptor.get = _; if (_ = accept(result.set)) descriptor.set = _; if (_ = accept(result.init)) initializers.unshift(_); } else if (_ = accept(result)) { if (kind === "field") initializers.unshift(_); else descriptor[key] = _; } } if (target) Object.defineProperty(target, contextIn.name, descriptor); done = true; }; var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { var useValue = arguments.length > 2; for (var i = 0; i < initializers.length; i++) { value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); } return useValue ? value : void 0; }; var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BasicEntryFormComponent = void 0; var Basic_Entry_form_1 = require("./Basic-Entry-form"); var core_1 = require("@angular/core"); var Basic_Master_View_1 = require("./Basic-Master-View"); var kendo_svg_icons_1 = require("@progress/kendo-svg-icons"); var BasicEntryFormComponent = function () { var _classDecorators = [(0, core_1.Component)({ selector: 'app-basic-entry-form', templateUrl: './Basic-Entry-Form.component.html', styles: ["\n .form-row-wrapper {\n display: flex;\n flex-wrap: wrap;\n }\n\n .form-row {\n width: 50%;\n box-sizing: border-box;\n padding: 0.5rem;\n height: 90px;\n }\n "], standalone: false, })]; var _classDescriptor; var _classExtraInitializers = []; var _classThis; var _ItemSaved_decorators; var _ItemSaved_initializers = []; var _ItemSaved_extraInitializers = []; var BasicEntryFormComponent = _classThis = /** @class */ (function () { function BasicEntryFormComponent_1(http, qcs, intl, _apiService, apiService, notificationService, LoadingPanelService, elementRef) { this.http = http; this.qcs = qcs; this.intl = intl; this._apiService = _apiService; this.apiService = apiService; this.notificationService = notificationService; this.LoadingPanelService = LoadingPanelService; this.elementRef = elementRef; this.icons = [kendo_svg_icons_1.saveIcon, kendo_svg_icons_1.gearIcon, kendo_svg_icons_1.fileExcelIcon, kendo_svg_icons_1.filePdfIcon, kendo_svg_icons_1.searchIcon, kendo_svg_icons_1.cancelIcon]; this.payLoad = ''; this.ItemSaved = __runInitializers(this, _ItemSaved_initializers, new core_1.EventEmitter()); this.opened = (__runInitializers(this, _ItemSaved_extraInitializers), true); this.dataSaved = false; this.formWidth = 846; this.saveUrl = this._apiService.base_url; } BasicEntryFormComponent_1.prototype.ngOnInit = function () { this.basicMasterView = new Basic_Master_View_1.BasicMasterView(); this.form = this.qcs.toFormGroup(this.basicMasterView); this.opened = false; }; BasicEntryFormComponent_1.prototype.SetMasterView = function (msview) { this.basicMasterView = msview; if (this.basicMasterView.entryFrom.formWidth == null || this.basicMasterView.entryFrom.formWidth == undefined) { this.basicMasterView.entryFrom.formWidth = 450; } //this.form = this.qcs.toFormGroup(this.basicMasterView); //this.opened = false; }; BasicEntryFormComponent_1.prototype.onSubmit = function () { var _this = this; this.notificationService.confirm('Do you sure you want to save?', function () { _this.payLoad = JSON.stringify(_this.form.value); _this.basicMasterView.entryFrom.controls.forEach(function (x) { if (x.controlType == Basic_Entry_form_1.EnumDynamicControlType.DropDownEnumData) { x.value = String(_this.form.controls[x.controlID].value); } else if (x.controlType == Basic_Entry_form_1.EnumDynamicControlType.CheckBox) { if (_this.form.controls[x.controlID].value == 1) { x.value = '1'; } else { x.value = '0'; } } else if (x.controlType == Basic_Entry_form_1.EnumDynamicControlType.DateTime) { var ddate = _this.intl.parseDate(_this.form.controls[x.controlID].value); x.value = ddate.toDateString(); } else { x.value = String(_this.form.controls[x.controlID].value); } }); _this.LoadingPanelService.ShowLoadingPanel = true; _this.scrollToTop(); //console.log(this.basicMasterView.entryFrom); //return; _this._apiService.httpPost('/BasicBuilder/SaveItem', _this.basicMasterView.entryFrom).subscribe(function (response) { _this.ItemSaved.emit(response); }, function (x) { _this.LoadingPanelService.ShowLoadingPanel = false; _this.notificationService.showError(x.error); _this.close(); }, function () { _this.LoadingPanelService.ShowLoadingPanel = false; _this.notificationService.showSuccess('Data Saved Successfully'); _this.close(); if (_this.basicMasterView.entryFrom.isNew = true) { _this.ClearData(); _this.form = _this.qcs.toFormGroup(_this.basicMasterView); _this.AutogeneratedCode(); } }); }, function () { // User canceled, do nothing //this.notificationService.showInfo('Save operation canceled.'); }); }; BasicEntryFormComponent_1.prototype.close = function () { this.ClearData(); this.opened = false; }; //EditComplete(): Observable { // return this.http.get(this.urlofMasterData + "/GetMasterViewData/" + // this._MasterView.EntryFrom.SourceObject + "/" + "Get/Null") //} BasicEntryFormComponent_1.prototype.ClearData = function () { this.basicMasterView.entryFrom.controls.forEach(function (x) { x.value = ''; x.isNew = true; }); }; BasicEntryFormComponent_1.prototype.AutogeneratedCode = function () { var _this = this; this.basicMasterView.entryFrom.controls.forEach(function (x) { if (x.codeAutoGenerate == true && x.isNew == true) { var tier = -1; var parentid = -1; if (_this.basicMasterView.fromViewType == Basic_Master_View_1.EnumFormView.TreeView) { tier = _this.basicMasterView.entryFrom.treeTier; if (tier != 1) { parentid = _this.basicMasterView.entryFrom.parentID; } } _this.LoadingPanelService.ShowLoadingPanel = true; _this.qcs.GetNextCode(tier, parentid).subscribe(function (data) { x.value = data; _this.form.controls[x.controlID].setValue(data); _this.LoadingPanelService.ShowLoadingPanel = false; }, function (x) { _this.LoadingPanelService.ShowLoadingPanel = false; _this.notificationService.showError('System could not generate Code. Error: ' + x.error); }); } }); }; BasicEntryFormComponent_1.prototype.PrepareCaption = function () { //debugger if (this.basicMasterView.fromViewType == Basic_Master_View_1.EnumFormView.ListView) { this.formCaption = 'New ' + this.basicMasterView.entryFrom.caption; } else { if (this.basicMasterView.treeViewTierNames == undefined || this.basicMasterView.treeViewTierNames.length == 0) { var splitedValue = this.basicMasterView.entryFrom.caption.split('|'); //console.log(splitedValue); if (splitedValue.length >= this.TreeViewSlectedTier) { this.formCaption = 'New ' + splitedValue[this.TreeViewSlectedTier - 1]; } else { this.formCaption = 'New ' + this.basicMasterView.entryFrom.caption; } } else { //debugger this.formCaption = 'New ' + this.basicMasterView.treeViewTierNames[this.basicMasterView.entryFrom.treeTier - 1].tierName; if (this.basicMasterView.entryFrom.iDValue > 0) { this.formCaption = 'Edit ' + this.basicMasterView.treeViewTierNames[this.basicMasterView.entryFrom.treeTier - 1].tierName; } } } }; BasicEntryFormComponent_1.prototype.NewItem = function () { this.basicMasterView = this.qcs.getMasterView(); this.basicMasterView.entryFrom.isNew = true; this.ClearData(); this.form = this.qcs.toFormGroup(this.basicMasterView); this.AutogeneratedCode(); this.open(); }; BasicEntryFormComponent_1.prototype.open = function () { this.formHeight = 350; this.formWidth = 650; if (this.basicMasterView.entryFrom.formHeight == undefined || this.basicMasterView.entryFrom.formHeight == 0) { this.formHeight = (this.basicMasterView.entryFrom.controls.length + 1.2) * 100; if (this.formHeight > 375) { this.formHeight = 375; } } else { this.formHeight = this.basicMasterView.entryFrom.formHeight; } //for width if (this.basicMasterView.entryFrom.formWidth == undefined || this.basicMasterView.entryFrom.formWidth == 0) { // } else { this.formWidth = this.basicMasterView.entryFrom.formWidth; } this.opened = true; }; BasicEntryFormComponent_1.prototype.scrollToTop = function () { var element = this.elementRef.nativeElement; element.scrollIntoView({ behavior: 'smooth', block: 'start' }); }; return BasicEntryFormComponent_1; }()); __setFunctionName(_classThis, "BasicEntryFormComponent"); (function () { var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0; _ItemSaved_decorators = [(0, core_1.Output)()]; __esDecorate(null, null, _ItemSaved_decorators, { kind: "field", name: "ItemSaved", static: false, private: false, access: { has: function (obj) { return "ItemSaved" in obj; }, get: function (obj) { return obj.ItemSaved; }, set: function (obj, value) { obj.ItemSaved = value; } }, metadata: _metadata }, _ItemSaved_initializers, _ItemSaved_extraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers); BasicEntryFormComponent = _classThis = _classDescriptor.value; if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata }); __runInitializers(_classThis, _classExtraInitializers); })(); return BasicEntryFormComponent = _classThis; }(); exports.BasicEntryFormComponent = BasicEntryFormComponent; //# sourceMappingURL=Basic-Entry-Form.component.js.map