UNPKG

tfabrica

Version:

library for TFabrica - TechSol

142 lines 6.66 kB
"use strict"; 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 http_1 = require("@angular/http"); var material_1 = require("@angular/material"); var material_2 = require("@angular/material"); var tfabrica_crud_service_1 = require("./tfabrica.crud.service"); var tfabrica_crud_report_model_1 = require("./tfabrica.crud.report.model"); var tfabrica_shared_service_1 = require("../main/tfabrica.shared.service"); var tfabrica_message_dialog_component_1 = require("../main/tfabrica.message.dialog.component"); var tfabrica_message_model_1 = require("../models/tfabrica.message.model"); var tfabrica_crud_selectfields_component_1 = require("./tfabrica.crud.selectfields.component"); var tfabrica_crud_filterfields_component_1 = require("./tfabrica.crud.filterfields.component"); var TfabricaCrudReadComponent = (function () { function TfabricaCrudReadComponent(_http, _sharedService, _crudService, dialog, snackBar) { this._http = _http; this._sharedService = _sharedService; this._crudService = _crudService; this.dialog = dialog; this.snackBar = snackBar; this.initReportData(); } TfabricaCrudReadComponent.prototype.ngOnInit = function () { }; TfabricaCrudReadComponent.prototype.initReportData = function () { var that = this; this.report = new tfabrica_crud_report_model_1.TfabricaCrudReport(); that._sharedService.returnSelectedVoice().properties.forEach(function (entry) { console.log(entry); if (entry.key == "Report") { //console.log(JSON.parse(entry.value.toString())); that.report.setFromJson(JSON.parse(entry.value.toString())); that._crudService.initFromReport(that.report); } }); if (that.report.executeImmediately) { this.extractData(); } }; TfabricaCrudReadComponent.prototype.extractData = function () { var _this = this; var that = this; that.loading = true; this._crudService.readData(that.report).subscribe(function (reportData) { that.report = reportData; console.log(that.report); console.log(that.report.fields); that.loading = false; //this.router.navigate(['/main', { outlets: { 'main': ['home'] } }]); if (that.report.success) { } else { _this.snackBar.open(that.report.message, "", { duration: 2000, }); var newMsg = new tfabrica_message_model_1.TfabricaMessage(); newMsg.message = that.report.message; newMsg.success = false; _this.displayMessage(newMsg); } }, function (err) { // Log errors if any console.log(err); that.loading = false; }); }; TfabricaCrudReadComponent.prototype.displayMessage = function (message) { //this.filtersmenu.toggle(); var dialogConfig = new material_1.MdDialogConfig(); dialogConfig.data = message; var dialogRef = this.dialog.open(tfabrica_message_dialog_component_1.TfabricaMessageDialogComponent, dialogConfig); dialogRef.afterClosed().subscribe(function (result) { console.log(result); if (result != null) { } }); }; TfabricaCrudReadComponent.prototype.openSearch = function () { var _this = this; //this.filtersmenu.toggle(); var dialogConfig = new material_1.MdDialogConfig(); //dialogConfig.width = "95%"; //dialogConfig.height = "95%"; var dialogRef = this.dialog.open(tfabrica_crud_filterfields_component_1.TfabricaCrudFilterFieldsComponent, dialogConfig); dialogRef.afterClosed().subscribe(function (result) { console.log(result); if (result != null) { } _this.extractData(); }); }; TfabricaCrudReadComponent.prototype.startSearch = function () { this.filtersmenu.toggle(); }; TfabricaCrudReadComponent.prototype.openFieldsList = function () { //this.fieldsmenu.toggle(); var _this = this; var dialogConfig = new material_1.MdDialogConfig(); var dialogRef = this.dialog.open(tfabrica_crud_selectfields_component_1.TfabricaCrudSelectFieldsComponent, dialogConfig); dialogRef.afterClosed().subscribe(function (result) { console.log(result); if (result != null) { _this.report.setFields(result); _this._crudService.setFields(_this.report.fields); } }); }; TfabricaCrudReadComponent.prototype.setFieldsList = function () { this.fieldsmenu.toggle(); }; return TfabricaCrudReadComponent; }()); __decorate([ core_1.ViewChild('trightfiltersmenu'), __metadata("design:type", Object) ], TfabricaCrudReadComponent.prototype, "filtersmenu", void 0); __decorate([ core_1.ViewChild('trightfieldsmenu'), __metadata("design:type", Object) ], TfabricaCrudReadComponent.prototype, "fieldsmenu", void 0); TfabricaCrudReadComponent = __decorate([ core_1.Component({ selector: 't-crud-read', template: require('./tfabrica.crud.read.component.html') }), __metadata("design:paramtypes", [http_1.Http, tfabrica_shared_service_1.TfabricaSharedService, tfabrica_crud_service_1.TfabricaCrudService, material_1.MdDialog, material_2.MdSnackBar]) ], TfabricaCrudReadComponent); exports.TfabricaCrudReadComponent = TfabricaCrudReadComponent; //# sourceMappingURL=tfabrica.crud.read.component.js.map