|
|
|
@ -621,7 +621,7 @@ abp generate-proxy |
|
|
|
|
|
|
|
This command generates the service proxy for the author service and the related model (DTO) classes: |
|
|
|
|
|
|
|
 |
|
|
|
 |
|
|
|
|
|
|
|
### AuthorComponent |
|
|
|
|
|
|
|
@ -630,8 +630,7 @@ Open the `/src/app/author/author.component.ts` file and replace the content as b |
|
|
|
```js |
|
|
|
import { Component, OnInit } from '@angular/core'; |
|
|
|
import { ListService, PagedResultDto } from '@abp/ng.core'; |
|
|
|
import { AuthorDto } from './models'; |
|
|
|
import { AuthorService } from './services'; |
|
|
|
import { AuthorService, AuthorDto } from '@proxy/authors'; |
|
|
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms'; |
|
|
|
import { NgbDateNativeAdapter, NgbDateAdapter } from '@ng-bootstrap/ng-bootstrap'; |
|
|
|
import { ConfirmationService, Confirmation } from '@abp/ng.theme.shared'; |
|
|
|
@ -649,7 +648,7 @@ export class AuthorComponent implements OnInit { |
|
|
|
|
|
|
|
form: FormGroup; |
|
|
|
|
|
|
|
selectedAuthor = new AuthorDto(); |
|
|
|
selectedAuthor = {} as AuthorDto; |
|
|
|
|
|
|
|
constructor( |
|
|
|
public readonly list: ListService, |
|
|
|
@ -659,7 +658,7 @@ export class AuthorComponent implements OnInit { |
|
|
|
) {} |
|
|
|
|
|
|
|
ngOnInit(): void { |
|
|
|
const authorStreamCreator = (query) => this.authorService.getListByInput(query); |
|
|
|
const authorStreamCreator = (query) => this.authorService.getList(query); |
|
|
|
|
|
|
|
this.list.hookToQuery(authorStreamCreator).subscribe((response) => { |
|
|
|
this.author = response; |
|
|
|
@ -667,13 +666,13 @@ export class AuthorComponent implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
createAuthor() { |
|
|
|
this.selectedAuthor = new AuthorDto(); |
|
|
|
this.selectedAuthor = {} as AuthorDto; |
|
|
|
this.buildForm(); |
|
|
|
this.isModalOpen = true; |
|
|
|
} |
|
|
|
|
|
|
|
editAuthor(id: string) { |
|
|
|
this.authorService.getById(id).subscribe((author) => { |
|
|
|
this.authorService.get(id).subscribe((author) => { |
|
|
|
this.selectedAuthor = author; |
|
|
|
this.buildForm(); |
|
|
|
this.isModalOpen = true; |
|
|
|
@ -697,14 +696,14 @@ export class AuthorComponent implements OnInit { |
|
|
|
|
|
|
|
if (this.selectedAuthor.id) { |
|
|
|
this.authorService |
|
|
|
.updateByIdAndInput(this.form.value, this.selectedAuthor.id) |
|
|
|
.update(this.selectedAuthor.id, this.form.value) |
|
|
|
.subscribe(() => { |
|
|
|
this.isModalOpen = false; |
|
|
|
this.form.reset(); |
|
|
|
this.list.get(); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.authorService.createByInput(this.form.value).subscribe(() => { |
|
|
|
this.authorService.create(this.form.value).subscribe(() => { |
|
|
|
this.isModalOpen = false; |
|
|
|
this.form.reset(); |
|
|
|
this.list.get(); |
|
|
|
@ -716,7 +715,7 @@ export class AuthorComponent implements OnInit { |
|
|
|
this.confirmation.warn('::AreYouSureToDelete', '::AreYouSure') |
|
|
|
.subscribe((status) => { |
|
|
|
if (status === Confirmation.Status.confirm) { |
|
|
|
this.authorService.deleteById(id).subscribe(() => this.list.get()); |
|
|
|
this.authorService.delete(id).subscribe(() => this.list.get()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|