diff --git a/src/app/_modules/advisories/tree/advisory/advisories-tree-advisory.component.ts b/src/app/_modules/advisories/tree/advisory/advisories-tree-advisory.component.ts index d846ab5..3507d49 100644 --- a/src/app/_modules/advisories/tree/advisory/advisories-tree-advisory.component.ts +++ b/src/app/_modules/advisories/tree/advisory/advisories-tree-advisory.component.ts @@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core'; import {AdvisoriesService} from "@app/_services/advisories.service"; import {FormsService, ListsService} from "@app/_services"; import {Subscription} from "rxjs"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'advisories-tree-advisory', @@ -17,7 +18,7 @@ export class AdvisoriesTreeAdvisoryComponent { public touched = false; - constructor(private advisoriesService: AdvisoriesService, private listsService: ListsService, private formsService: FormsService) { + constructor(private advisoriesService: AdvisoriesService, private listsService: ListsService, private formsService: FormsService, private dialog: DialogService) { } @@ -83,9 +84,13 @@ export class AdvisoriesTreeAdvisoryComponent { } delete() { - if (confirm(`Удалить ${this.advisory.caption}`)) this.advisoriesService.delete(this.advisory.id).subscribe(res => { - this.listsService.refresh(this.parent.id); - }); + this.dialog.confirm(`Удалить ${this.advisory.caption}`).subscribe( + resp=>{ + if (resp) this.advisoriesService.delete(this.advisory.id).subscribe(res => { + this.listsService.refresh(this.parent.id); + }); + } + ) } addAdvisory() { diff --git a/src/app/_modules/advisories/tree/company/advisories-tree-company.component.ts b/src/app/_modules/advisories/tree/company/advisories-tree-company.component.ts index 4834302..ebf1e0a 100644 --- a/src/app/_modules/advisories/tree/company/advisories-tree-company.component.ts +++ b/src/app/_modules/advisories/tree/company/advisories-tree-company.component.ts @@ -3,6 +3,7 @@ import {Router} from "@angular/router"; import {AdvisoryCompaniesService} from "@app/_services/advisory-companies.service"; import {FormsService, ListsService} from "@app/_services"; import {Subscription} from "rxjs"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'advisories-tree-company', @@ -18,7 +19,7 @@ export class AdvisoriesTreeCompanyComponent { public touched = false; - constructor(private advisoryCompaniesService: AdvisoryCompaniesService, private listsService: ListsService, private formsService: FormsService, private router: Router) { + constructor(private advisoryCompaniesService: AdvisoryCompaniesService, private listsService: ListsService, private formsService: FormsService, private router: Router, private dialog: DialogService) { } @@ -89,11 +90,14 @@ export class AdvisoriesTreeCompanyComponent { delete() { - if (confirm('Исключить организацию из списка участников комитета?')) { - this.advisoryCompaniesService.delete(this.advisoryCompany.id).subscribe(res => { - this.listsService.refresh(this.parent?.id); - }); - } + this.dialog.confirm('Исключить организацию из списка участников комитета?').subscribe( + resp=>{ + if (resp) { + this.advisoryCompaniesService.delete(this.advisoryCompany.id).subscribe(res => { + this.listsService.refresh(this.parent?.id); + }); + } + } + ) } - } diff --git a/src/app/_modules/advisories/tree/member/advisories-tree-member.component.ts b/src/app/_modules/advisories/tree/member/advisories-tree-member.component.ts index dea9840..d76489b 100644 --- a/src/app/_modules/advisories/tree/member/advisories-tree-member.component.ts +++ b/src/app/_modules/advisories/tree/member/advisories-tree-member.component.ts @@ -1,6 +1,7 @@ import {Component, Input} from '@angular/core'; import {AdvisoryMembersService} from "@app/_services/advisory-members.service"; import {ListsService} from "@app/_services"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'advisories-tree-member', @@ -11,7 +12,7 @@ export class AdvisoriesTreeMemberComponent { @Input() advisoryMember: any; @Input() parent: any; - constructor(private advisoryMembersService: AdvisoryMembersService, private listsService: ListsService) { + constructor(private advisoryMembersService: AdvisoryMembersService, private listsService: ListsService, private dialog: DialogService) { } @@ -41,12 +42,14 @@ export class AdvisoriesTreeMemberComponent { delete() { - if (confirm('Исключить сотрудника из участников комитета?')) { - this.advisoryMembersService.delete(this.advisoryMember.id).subscribe(res => { - this.listsService.refresh(this.parent?.id); - }); - } + this.dialog.confirm('Исключить сотрудника из участников комитета?').subscribe( + resp=>{ + if (resp) { + this.advisoryMembersService.delete(this.advisoryMember.id).subscribe(res => { + this.listsService.refresh(this.parent?.id); + }); + } + } + ) } - - } diff --git a/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts b/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts index cd4188a..f84dd21 100644 --- a/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts +++ b/src/app/_modules/layout/header/user-bar/header-user-bar.component.ts @@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core'; import {AuthenticationService} from "@app/_services"; import {Router} from "@angular/router"; import { PagesService } from '@app/_services/pages.service'; +import { DialogService } from '@app/_services/dialog.service'; @Component({ @@ -13,7 +14,7 @@ export class HeaderUserBarComponent { public menuItems = []; public ddHidden = true; - constructor(public authService: AuthenticationService, private router: Router, private pagesService: PagesService) { + constructor(public authService: AuthenticationService, private router: Router, private pagesService: PagesService, private dialog: DialogService) { } get user() { @@ -39,12 +40,16 @@ export class HeaderUserBarComponent { logout() { - if (confirm('Вы деествительно хотите выйти из системы?')) { - this.pagesService.editMode = false; - this.authService.logout(); - this.ddHidden = true; - this.router.navigate(['']).then(); - } + this.dialog.confirm('Вы деествительно хотите выйти из системы?').subscribe( + resp=>{ + if (resp) { + this.pagesService.editMode = false; + this.authService.logout(); + this.ddHidden = true; + this.router.navigate(['']).then(); + } + } + ) } link(link: string) { diff --git a/src/app/_modules/pages/sections/menu/page-menu.component.ts b/src/app/_modules/pages/sections/menu/page-menu.component.ts index 137c40d..862c6ec 100644 --- a/src/app/_modules/pages/sections/menu/page-menu.component.ts +++ b/src/app/_modules/pages/sections/menu/page-menu.component.ts @@ -8,6 +8,17 @@ import { DialogService } from '@app/_services/dialog.service'; styleUrls: ['page-menu.component.scss'] }) export class PageMenuComponent { + + delete() { + this.dialog.confirm('Удалить этот блок?').subscribe( + resp=>{ + if (resp) this.objectsService.destroy(this.section.id).subscribe(res => { + this.listsService.refresh(); + }); + } + ) + } + @Input() page: any; @Input() section: any; @Input() editMode: boolean; @@ -54,13 +65,5 @@ export class PageMenuComponent { }); } - delete() { - this.dialog.prompt('Удалить этот блок?').subscribe( - resp=>{ - if (resp) this.objectsService.destroy(this.section.id).subscribe(res => { - this.listsService.refresh(); - }); - } - ) - } + } diff --git a/src/app/_modules/pages/sections/types/basic/cards/items/item/cards-section-item.component.ts b/src/app/_modules/pages/sections/types/basic/cards/items/item/cards-section-item.component.ts index 3cfd02f..87f95b9 100644 --- a/src/app/_modules/pages/sections/types/basic/cards/items/item/cards-section-item.component.ts +++ b/src/app/_modules/pages/sections/types/basic/cards/items/item/cards-section-item.component.ts @@ -1,5 +1,6 @@ import {Component, Input} from '@angular/core'; import {FormsService, ListsService, ObjectsService} from "@app/_services"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'cards-section-item', @@ -11,7 +12,7 @@ export class CardsSectionItemComponent { @Input() type: any; @Input() editMode = false; - constructor(private objectsService: ObjectsService, private formsService: FormsService, private listsService: ListsService) { + constructor(private objectsService: ObjectsService, private formsService: FormsService, private listsService: ListsService, private dialog: DialogService) { } @@ -23,10 +24,13 @@ export class CardsSectionItemComponent { } delete() { - if (confirm('r u sure?')) this.objectsService.destroy(this.card.id).subscribe(res => { - this.listsService.refresh(); - }); + this.dialog.confirm('Удалить эту карточку?').subscribe( + resp=>{ + if (resp) this.objectsService.destroy(this.card.id).subscribe(res => { + this.listsService.refresh(); + }); + } + ) } - } diff --git a/src/app/_modules/pages/tree/item/pages-tree-item.component.ts b/src/app/_modules/pages/tree/item/pages-tree-item.component.ts index 52c50ae..baa13dc 100644 --- a/src/app/_modules/pages/tree/item/pages-tree-item.component.ts +++ b/src/app/_modules/pages/tree/item/pages-tree-item.component.ts @@ -2,6 +2,7 @@ import {Component, Input} from '@angular/core'; import {PagesService} from "@app/_services/pages.service"; import {FormsService, ListsService} from "@app/_services"; import {Subscription} from "rxjs"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'pages-tree-item', @@ -18,7 +19,8 @@ export class PagesTreeItemComponent { constructor( public pagesService: PagesService, private formsService: FormsService, - private listsService: ListsService) { + private listsService: ListsService, + private dialog: DialogService) { } ngOnInit() { @@ -85,26 +87,36 @@ export class PagesTreeItemComponent { } delete() { - if (confirm('r u sure?')) this.pagesService.delete(this.page.id).subscribe(res => { - this.listsService.refresh(this.parentListId); - this.refresh(); - }); - + this.dialog.confirm(`Удалить страницу ${this.page.name}?`).subscribe( + resp=>{ + if (resp) this.pagesService.delete(this.page.id).subscribe(res => { + this.listsService.refresh(this.parentListId); + this.refresh(); + }); + } + ) } restore() { - if (confirm(`Восстановить страницу ${this.page.name}?`)) this.pagesService.restore(this.page.id, {}).subscribe(res => { - this.listsService.refresh(this.parentListId); - this.refresh(); - }); - + this.dialog.confirm(`Восстановить страницу ${this.page.name}?`).subscribe( + resp=>{ + if (resp) this.pagesService.restore(this.page.id, {}).subscribe(res => { + this.listsService.refresh(this.parentListId); + this.refresh(); + }); + } + ) } clone() { - if (confirm(`Копировать страницу ${this.page.name}?`)) this.pagesService.clone(this.page.id, {recursive: true}).subscribe(res => { - this.listsService.refresh(this.parentListId); - this.refresh(); - }); + this.dialog.confirm(`Копировать страницу ${this.page.name}?`).subscribe( + resp=>{ + if (resp) this.pagesService.clone(this.page.id, {recursive: true}).subscribe(res => { + this.listsService.refresh(this.parentListId); + this.refresh(); + }); + } + ) } private refresh(){ diff --git a/src/app/_modules/publications/list/item/publications-list-item.component.ts b/src/app/_modules/publications/list/item/publications-list-item.component.ts index 373136d..2eff3b1 100644 --- a/src/app/_modules/publications/list/item/publications-list-item.component.ts +++ b/src/app/_modules/publications/list/item/publications-list-item.component.ts @@ -1,6 +1,7 @@ import {Component, Input} from '@angular/core'; import {FormsService, ListsService} from "@app/_services"; import {PublicationsService} from "@app/_services/publications.service"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'publications-list-item', @@ -12,7 +13,7 @@ export class PublicationsListItemComponent { @Input() editMode: boolean; currentPoster:any; - constructor(private publicationsService: PublicationsService, private formsService: FormsService, private listsService: ListsService) { + constructor(private publicationsService: PublicationsService, private formsService: FormsService, private listsService: ListsService, private dialog: DialogService) { } get listId() { @@ -33,12 +34,15 @@ export class PublicationsListItemComponent { } delete() { - if (confirm('R u sure?')) { - this.publicationsService.delete(this.publication.id).subscribe(res => { - this.listsService.refresh(this.listId, true); - }); - } + this.dialog.confirm('Удалить эту новость?').subscribe( + resp=>{ + if (resp) { + this.publicationsService.delete(this.publication.id).subscribe(res => { + this.listsService.refresh(this.listId, true); + }); + } + } + ) } - } diff --git a/src/app/_modules/users/list/item/users-list-item.component.ts b/src/app/_modules/users/list/item/users-list-item.component.ts index 997c64c..c3d25be 100644 --- a/src/app/_modules/users/list/item/users-list-item.component.ts +++ b/src/app/_modules/users/list/item/users-list-item.component.ts @@ -1,5 +1,6 @@ import {Component, Input} from '@angular/core'; import {FormsService, ListsService, UsersService} from "@app/_services"; +import { DialogService } from '@app/_services/dialog.service'; @Component({ selector: 'users-list-item', @@ -10,7 +11,7 @@ export class UsersListItemComponent { @Input() user: any; @Input() listId: string; - constructor(private usersService: UsersService, private formsService: FormsService, private listsService: ListsService) { + constructor(private usersService: UsersService, private formsService: FormsService, private listsService: ListsService, private dialog: DialogService) { } get role() { @@ -29,9 +30,12 @@ export class UsersListItemComponent { } delete() { - if (confirm(`Удалить пользователя ${this.user.name}?`)) this.usersService.delete(this.user.id).subscribe(res => { - this.listsService.refresh(this.listId, true); - }); + this.dialog.confirm(`Удалить пользователя ${this.user.name}?`).subscribe( + resp=>{ + if (resp) this.usersService.delete(this.user.id).subscribe(res => { + this.listsService.refresh(this.listId, true); + }); + } + ) } - } diff --git a/src/app/_services/dialog.service.ts b/src/app/_services/dialog.service.ts index 8cc8c13..7a869ad 100644 --- a/src/app/_services/dialog.service.ts +++ b/src/app/_services/dialog.service.ts @@ -26,7 +26,7 @@ export class DialogService { alert(txt:string){ this.modalAllertSubject.next(txt) } - prompt(txt:string){ + confirm(txt:string){ this.modalPromptSubject.next(txt); this.userResp = new BehaviorSubject(null) return this.userResp;