Skip to content

Commit dd00c23

Browse files
committed
[chandu] implemented list-view state update trigger event
1 parent 119c3e9 commit dd00c23

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<app-list-view [gridDataSource]="gridDataSource$ | async"></app-list-view>
1+
<app-list-view
2+
[gridDataSource]="gridDataSource$ | async"
3+
(updatePeridoicElement)="onUpdatePeridoicElement($event)"
4+
></app-list-view>

src/app/grid-list/container/list-base/list-base.component.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { getGridList } from '../../store/selectors/grid-list.selectors';
77
import { loadGridLists } from '../../store/actions/grid-list.actions';
88
import { FormArray } from '@angular/forms';
99
import { buildFormGroup } from 'src/app/models/periodic-element-work';
10+
import { Update } from '@ngrx/entity';
11+
import { PeriodicElement } from 'src/app/models/periodic-element';
1012

1113
@Component({
1214
selector: 'app-list-base',
@@ -23,9 +25,11 @@ export class ListBaseComponent implements OnInit {
2325
this.gridDataSource$ = this.store.pipe(
2426
takeUntil(this.alive),
2527
select(getGridList),
26-
map(elements => new FormArray(elements.map(buildFormGroup)))
28+
map((elements) => new FormArray(elements.map(buildFormGroup)))
2729
);
2830

29-
this.store.dispatch(loadGridLists())
31+
this.store.dispatch(loadGridLists());
3032
}
33+
34+
onUpdatePeridoicElement(event: Update<PeriodicElement>) {}
3135
}

src/app/grid-list/presentationals/list-view/list-view.component.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@ import {
44
Input,
55
OnChanges,
66
SimpleChanges,
7+
EventEmitter,
8+
Output,
79
} from '@angular/core';
810
import { FormGroup, FormArray, Form } from '@angular/forms';
911
import { noop } from 'rxjs';
1012
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
13+
import { PeriodicElement } from 'src/app/models/periodic-element';
14+
import { Update } from '@ngrx/entity';
1115

1216
@Component({
1317
selector: 'app-list-view',
@@ -16,6 +20,7 @@ import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
1620
})
1721
export class ListViewComponent implements OnChanges {
1822
@Input() gridDataSource: FormArray;
23+
@Output() updatePeridoicElement = new EventEmitter<Update<PeriodicElement>>();
1924

2025
gridForm: FormGroup;
2126

@@ -42,4 +47,11 @@ export class ListViewComponent implements OnChanges {
4247
event.currentIndex
4348
);
4449
}
50+
51+
updateFormInState(form: FormGroup) {
52+
this.updatePeridoicElement.emit({
53+
id: form.get('id').value,
54+
changes: form.value,
55+
} as Update<PeriodicElement>);
56+
}
4557
}

0 commit comments

Comments
 (0)