Converted everything to use a store

This commit is contained in:
2018-07-24 19:47:45 -04:00
parent 8eff0a6191
commit 2cccac9569
25 changed files with 280 additions and 247 deletions

View File

@ -12,7 +12,7 @@
</tr>
</thead>
<tbody>
<tr *ngFor="let c of components | async">
<tr *ngFor="let c of store.components | async">
<td>{{c.name}}</td>
<td>{{c.description}}</td>
<td>{{c.created | date}}</td>

View File

@ -4,32 +4,18 @@ import {map} from 'rxjs/operators';
import {MatDialog} from '@angular/material';
import {DeleteComponent} from '../../delete/delete.component';
import {NewComponentComponent} from '../newComponent/newComponent.component';
import {AppStore} from '../../app.store';
@Component({
selector: '',
templateUrl: './viewComponents.component.html'
})
export class ViewComponents {
components;
constructor(private db: AngularFirestore, private dialog: MatDialog) {
this.components = this.db
.collection('components')
.snapshotChanges()
.pipe(
map(rows =>
rows.map((row: any) => {
row = Object.assign({id: row.payload.doc.id, ref: row.payload.doc.ref}, row.payload.doc.data());
row.created = row.created.toDate();
return row;
})
)
);
}
constructor(private dialog: MatDialog, public store: AppStore) {}
createComponent(component?) {
if(component) {
this.dialog.open(NewComponentComponent, { data: component })
if (component) {
this.dialog.open(NewComponentComponent, {data: component});
} else {
this.dialog.open(NewComponentComponent);
}