Browse Source

refactor(feature-management): remove ngOnChanges

pull/1660/head
TheDiaval 7 years ago
parent
commit
fd40104af2
  1. 4
      npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html
  2. 15
      npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts

4
npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.html

@ -25,8 +25,8 @@
<button #abpClose type="button" class="btn btn-secondary"> <button #abpClose type="button" class="btn btn-secondary">
{{ 'AbpFeatureManagement::Cancel' | abpLocalization }} {{ 'AbpFeatureManagement::Cancel' | abpLocalization }}
</button> </button>
<button type="button" class="btn btn-primary" (click)="save()"> <abp-button iconClass="fa fa-check" (click)="save()">
{{ 'AbpFeatureManagement::Save' | abpLocalization }} {{ 'AbpFeatureManagement::Save' | abpLocalization }}
</button> </abp-button>
</ng-template> </ng-template>
</abp-modal> </abp-modal>

15
npm/ng-packs/packages/feature-management/src/lib/components/feature-management/feature-management.component.ts

@ -11,7 +11,7 @@ import { pluck, tap } from 'rxjs/operators';
selector: 'abp-feature-management', selector: 'abp-feature-management',
templateUrl: './feature-management.component.html', templateUrl: './feature-management.component.html',
}) })
export class FeatureManagementComponent implements OnChanges { export class FeatureManagementComponent {
@Input() @Input()
providerKey: string; providerKey: string;
@ -28,6 +28,8 @@ export class FeatureManagementComponent implements OnChanges {
set visible(value: boolean) { set visible(value: boolean) {
this._visible = value; this._visible = value;
this.visibleChange.emit(value); this.visibleChange.emit(value);
if (value) this.openModal();
} }
@Output() @Output()
@ -42,16 +44,6 @@ export class FeatureManagementComponent implements OnChanges {
constructor(private store: Store) {} constructor(private store: Store) {}
ngOnChanges({ visible }: SimpleChanges): void {
if (!visible) return;
if (visible.currentValue) {
this.openModal();
} else if (this.visible && visible.currentValue === false) {
this.visible = false;
}
}
openModal() { openModal() {
if (!this.providerKey || !this.providerName) { if (!this.providerKey || !this.providerName) {
throw new Error('Provider Key and Provider Name are required.'); throw new Error('Provider Key and Provider Name are required.');
@ -66,7 +58,6 @@ export class FeatureManagementComponent implements OnChanges {
.pipe(pluck('FeatureManagementState', 'features')) .pipe(pluck('FeatureManagementState', 'features'))
.subscribe(features => { .subscribe(features => {
this.buildForm(features); this.buildForm(features);
this.visible = true;
}); });
} }

Loading…
Cancel
Save