Full crud with the delete
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import {Component, Input, OnInit} from '@angular/core';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { FormlyFieldConfig } from '@ngx-formly/core'
|
||||
import { FormlyJsonschema } from '@ngx-formly/core/json-schema';
|
||||
import { Router } from '@angular/router';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
|
||||
import { CrudService } from '../crud.service'
|
||||
import {BehaviorSubject} from "rxjs";
|
||||
import {JsonschemasService} from "../jsonschemas.service";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { JsonschemasService } from "../jsonschemas.service";
|
||||
|
||||
export interface Model {
|
||||
email: string;
|
||||
@@ -35,7 +35,8 @@ export class CardComponent implements OnInit {
|
||||
constructor(private crudService: CrudService,
|
||||
private jsonSchemasService: JsonschemasService,
|
||||
private formlyJsonschema: FormlyJsonschema,
|
||||
private router: Router
|
||||
private router: Router,
|
||||
private route: ActivatedRoute,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -70,6 +71,14 @@ export class CardComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
onDelete() {
|
||||
this._loading$.next(true);
|
||||
this.crudService.delete(this.resource!, this.model).subscribe((model: any) => {
|
||||
this._loading$.next(false);
|
||||
this.router.navigate(['../'], {relativeTo: this.route});
|
||||
});
|
||||
}
|
||||
|
||||
isCreateForm() {
|
||||
return this.resource_id === null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user