UNPKG

tfabrica

Version:

library for TFabrica - TechSol

143 lines 6.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tfabrica_crud_field_model_1 = require("./tfabrica.crud.field.model"); var tfabrica_crud_filter_value_1 = require("./tfabrica.crud.filter.value"); require("rxjs/Rx"); var rxjs_1 = require("rxjs"); var TfabricaCrudReport = (function () { function TfabricaCrudReport() { this.titleSubject = new rxjs_1.BehaviorSubject(""); this.readedRows = new Array(); this.fields = new Array(); } TfabricaCrudReport.prototype.setFromJson = function (json) { this.connectionString = json.connectionString; //this.fields = json.fields; this.setFieldsFromJson(json.fields); if (this.fields == undefined) this.fields = new Array(); this.readedRows = json.readedRows; this.setFieldsToDisplay(); this.message = json.message; this.success = json.success; this.title = json.title; this.titleSubject.next(this.title); this.executeImmediately = json.executeImmediately; this.selectRead = json.selectRead; this.updateTableName = json.updateTableName; this.setFields(this.fields); this.filters = json.filters; this.composedCommand = json.composedCommand; // this.canShow = json.canShow; this.canAdd = json.canAdd; this.canRemove = json.canRemove; this.canUpdate = json.canUpdate; this.canSearch = json.canSearch; //this.canFilter = json.canFilter; this.canManageCustom = json.canManageCustom; this.customFunction = json.customFunciton; }; TfabricaCrudReport.prototype.setFieldsFromJson = function (jsonFields) { //console.log("setFieldsFromJson"); //console.log(jsonFields); this.fields = new Array(); var that = this; try { jsonFields.forEach(function (entry) { var field = new tfabrica_crud_field_model_1.TfabricaCrudField(); field.name = entry.name; field.label = entry.label; field.type = entry.type; field.display = entry.display; field.conversionFunction = entry.conversionFunction; field.isUpdate = entry.isUpdate; field.isKey = entry.isKey; field.style = entry.style; that.fields.push(field); }); } catch (Err) { } }; TfabricaCrudReport.prototype.setFieldsToDisplay = function () { var that = this; this.fieldsToDisplay = new Array(); var position = 0; try { this.fields.forEach(function (entry) { position++; if (entry.display) { if (entry.position == 0 || entry.position == undefined) entry.position = position; //console.log("setFieldsToDisplay()"); //console.log(entry); that.fieldsToDisplay.push(entry); } }); this.fieldsToDisplay.sort(tfabrica_crud_field_model_1.TfabricaCrudField.compare); } catch (Err) { } }; TfabricaCrudReport.prototype.setFields = function (fieldsInput) { console.log("setFields:"); console.log(fieldsInput); this.fields = new Array(); var that = this; try { fieldsInput.forEach(function (entry) { var field = new tfabrica_crud_field_model_1.TfabricaCrudField(); field.name = entry.name; field.label = entry.label; field.type = entry.type; field.display = entry.display; field.conversionFunction = entry.conversionFunction; field.isUpdate = entry.isUpdate; field.isKey = entry.isKey; field.style = entry.style; field.position = entry.position; that.fields.push(field); }); //this.fields = fields; this.fields.sort(tfabrica_crud_field_model_1.TfabricaCrudField.compare); this.setFieldsToDisplay(); return this.fields; } catch (Err) { } }; TfabricaCrudReport.prototype.getFields = function () { this.fields.sort(tfabrica_crud_field_model_1.TfabricaCrudField.compare); return this.fields; }; TfabricaCrudReport.prototype.getFieldsToDisplay = function () { try { this.fieldsToDisplay.sort(tfabrica_crud_field_model_1.TfabricaCrudField.compare); } catch (Err) { } return this.fieldsToDisplay; }; TfabricaCrudReport.prototype.setFiltersValuesFromUserParameters = function (parameters) { var that = this; try { that.filters.forEach(function (filter) { if (filter.userParameterField != undefined && filter.userParameterField != "") { if (filter.values == undefined) filter.values = new Array(); parameters.forEach(function (userParameter) { if (userParameter.key == filter.userParameterField) { userParameter.values.forEach(function (userParameterValue) { var actValue = new tfabrica_crud_filter_value_1.TfabricaCrudFilterValue(); actValue.value = userParameterValue.value; actValue.label = userParameterValue.label; actValue.isSelected = false; filter.values.push(actValue); }); } }); } }); } catch (Err) { } }; return TfabricaCrudReport; }()); exports.TfabricaCrudReport = TfabricaCrudReport; //# sourceMappingURL=tfabrica.crud.report.model.js.map