import { ActionTypes, RoleActions } from '../../../actions/role'; import { Component, StatefulView, guid, DateHelper } from '@dezrez/core'; import { DataTable, IDataTableSettings } from '../../../components/datatable'; import { Dezrez } from '@dezrez/typings-rezi'; import { IState } from '../../../store'; import { Subscription } from 'rxjs/Subscription'; import TenantRole = Dezrez.Core.DataContracts.External.Api.Role.Query.Get.Group.TenantRoleDataContract; import { petsConfig } from './pets-config'; @Component({ view: require('./pets.html') }) export default class LetInformation extends StatefulView { tenantRoleId: number; lettingsId: number; table = ko.observable(); loaded = ko.observable(); tenantSubscription: Subscription; tenantRole: TenantRole; constructor() { super(); } activate() { this.subscriptions(); } deactivate() { super.deactivate(); this.store.dispatch(RoleActions.clear()); } detached() { super.deactivate(); this.store.dispatch(RoleActions.clear()); } subscriptions() { const self = this; self.tenantSubscription = self.store.select(r => r.role.Tenant).subscribe((role: TenantRole) => { if (role) { self.loaded(true); self.tenantRole = role; self.createTable(); } }); } createTable() { this.table(petsConfig.construct(this.tenantRole)); } }