|
@@ -8,6 +8,8 @@ import {
|
|
import { DataService } from 'src/services/data/data.service';
|
|
import { DataService } from 'src/services/data/data.service';
|
|
import { Ability } from 'src/interfaces/ability';
|
|
import { Ability } from 'src/interfaces/ability';
|
|
import { NgxSmartModalService } from 'ngx-smart-modal';
|
|
import { NgxSmartModalService } from 'ngx-smart-modal';
|
|
|
|
+import { AbilityDetailsComponent } from './ability-details/ability-details.component';
|
|
|
|
+import { DetailsService } from 'src/services/details/details.service';
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'ability-table',
|
|
selector: 'ability-table',
|
|
@@ -31,7 +33,8 @@ export class AbilityTableComponent {
|
|
|
|
|
|
public constructor(
|
|
public constructor(
|
|
public dataAccessor: DataService,
|
|
public dataAccessor: DataService,
|
|
- public ngxSmartModalService: NgxSmartModalService
|
|
|
|
|
|
+ public ngxSmartModalService: NgxSmartModalService,
|
|
|
|
+ private detailsAccesssor: DetailsService
|
|
) {}
|
|
) {}
|
|
|
|
|
|
public ngOnInit(): void {
|
|
public ngOnInit(): void {
|
|
@@ -132,4 +135,28 @@ export class AbilityTableComponent {
|
|
this.abilityToUpdate = undefined;
|
|
this.abilityToUpdate = undefined;
|
|
this.updateAbilityIndex = undefined;
|
|
this.updateAbilityIndex = undefined;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ private deleteAbility(index: number): void {
|
|
|
|
+ this.abilities.splice(index, 1);
|
|
|
|
+ this.updateDatabase();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // details panel
|
|
|
|
+
|
|
|
|
+ public openDetailsPanel(index: number): void {
|
|
|
|
+ this.detailsAccesssor.openPanel(AbilityDetailsComponent, {
|
|
|
|
+ abilities: this.abilities[index],
|
|
|
|
+ });
|
|
|
|
+ const resultSubscription = this.detailsAccesssor.result$.subscribe(
|
|
|
|
+ (result) => {
|
|
|
|
+ console.log(result);
|
|
|
|
+ if (result === 'delete') {
|
|
|
|
+ this.deleteAbility(index);
|
|
|
|
+ } else if (result === 'update') {
|
|
|
|
+ this.openAbilityModal(index);
|
|
|
|
+ }
|
|
|
|
+ resultSubscription.unsubscribe();
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ }
|
|
}
|
|
}
|