tfabrica
Version:
library for TFabrica - TechSol
99 lines • 4.66 kB
JavaScript
;
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 common_1 = require("@angular/common");
var tfabrica_crud_service_1 = require("./tfabrica.crud.service");
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 TfabricaCrudDetailComponent = (function () {
function TfabricaCrudDetailComponent(_http, _sharedService, _crudService, _location, dialog, snackBar) {
this._http = _http;
this._sharedService = _sharedService;
this._crudService = _crudService;
this._location = _location;
this.dialog = dialog;
this.snackBar = snackBar;
this.report = this._crudService.getReport();
this.row = this._crudService.getSelectedRow();
console.log(this.row);
this.operation = this._crudService.getOperation();
if (this.operation == "I")
this.subTitle = "Insert";
if (this.operation == "U")
this.subTitle = "Update";
}
TfabricaCrudDetailComponent.prototype.ngOnInit = function () {
};
TfabricaCrudDetailComponent.prototype.back = function () {
this._location.back();
};
TfabricaCrudDetailComponent.prototype.save = function () {
var _this = this;
var that = this;
that.loading = true;
this._crudService.updateData(that.report, that.row, that.operation).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) {
_this.snackBar.open("Updated Succesfully!", "", {
duration: 2000,
});
}
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;
});
};
TfabricaCrudDetailComponent.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) {
}
});
};
return TfabricaCrudDetailComponent;
}());
TfabricaCrudDetailComponent = __decorate([
core_1.Component({
selector: 't-crud-detail',
template: require('./tfabrica.crud.detail.component.html')
}),
__metadata("design:paramtypes", [http_1.Http,
tfabrica_shared_service_1.TfabricaSharedService,
tfabrica_crud_service_1.TfabricaCrudService,
common_1.Location,
material_1.MdDialog,
material_2.MdSnackBar])
], TfabricaCrudDetailComponent);
exports.TfabricaCrudDetailComponent = TfabricaCrudDetailComponent;
//# sourceMappingURL=tfabrica.crud.detail.component.js.map