Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
feat(base-component): Move subscribe from init to afterCreate
Browse files Browse the repository at this point in the history
  • Loading branch information
EndyKaufman committed Oct 30, 2017
1 parent b8505b4 commit 6cc1d50
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
11 changes: 6 additions & 5 deletions libs/web/src/base/base-component/base-component.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,12 @@ export class BaseComponent implements OnInit, OnDestroy {
this.afterCreate();
this.init();
}
afterCreate() { }
afterCreate() {
if (this.accountService) {
this.accountService.account$.takeUntil(this.destroyed$).subscribe((account: any | User) => this.account = account);
this.account = this.accountService.account;
}
}
init() {
if (this.errors) {
this.errors.subscribe((data: any) => {
Expand Down Expand Up @@ -119,10 +124,6 @@ export class BaseComponent implements OnInit, OnDestroy {
if (this.tooltipTriggers === undefined) {
this.tooltipTriggers = 'hover focus';
}
if (this.accountService) {
this.accountService.account$.takeUntil(this.destroyed$).subscribe((account: any | User) => this.account = account);
this.account = this.accountService.account;
}
setTimeout((out: any) => {
if (this.focused === true) {
this.focus();
Expand Down
1 change: 1 addition & 0 deletions libs/web/src/base/base-modal/base-modal.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class BaseModalComponent extends BaseComponent {
}
}
afterCreate() {
super.afterCreate();
if (this.hideOnClose === undefined) {
this.hideOnClose = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class BaseResourceInputComponent extends BaseComponent {
super();
}
afterCreate() {
super.afterCreate();
this.translateService.onLangChange.takeUntil(this.destroyed$).subscribe(() => this.init());
if (this.lookupTooltip === undefined) {
this.lookupTooltip = this.translateService.instant('Select');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class BaseResourceSelectInputComponent extends BaseComponent {
super();
}
afterCreate() {
super.afterCreate();
if (this.select === undefined) {
this.select = this.config.select;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export class BaseResourcesGridComponent extends BaseComponent {
}
}
initAccesses(contentType?: string) {
contentType = contentType ? contentType : this.cachedResourcesService.name;
this.accessToManage = this.checkPermissions(['manage_' + contentType]);
this.accessToRead = this.accessToManage ? this.accessToManage : this.checkPermissions(['read_' + contentType]);
this.accessToAdd = this.accessToManage ? this.accessToManage : this.checkPermissions(['add_' + contentType]);
Expand Down Expand Up @@ -123,9 +124,15 @@ export class BaseResourcesGridComponent extends BaseComponent {
this.selectItem(null);
});
this.items = this.cachedResourcesService.items;
if (this.accountService) {
this.accountService.account$.takeUntil(this.destroyed$).subscribe((account: any | User) => this.initAccesses(this.cachedResourcesService.name));
}
}
if (this.accountService) {
this.accountService.account$.takeUntil(this.destroyed$).subscribe((account: any | User) => {
this.account = account;
if (this.cachedResourcesService) {
this.initAccesses(this.cachedResourcesService.name);
}
});
this.account = this.accountService.account;
}
}
focus() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class AccountProfileFormComponent extends BaseModalComponent {
this.userGroups.search();
}
afterCreate() {
super.afterCreate();
if (this.readonly === undefined) {
this.readonly = false;
}
Expand Down

0 comments on commit 6cc1d50

Please # to comment.