Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
#216 add conformation message to tag delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Shakhov committed Jul 12, 2017
1 parent fe36436 commit bd652f4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/app/tags/tag/tag.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class="button-18px"
mdl-button
mdl-button-type="icon"
(click)="remove()"
(click)="showRemoveDialog()"
[disabled]="loading"
>
<mdl-icon>delete</mdl-icon>
Expand Down
28 changes: 19 additions & 9 deletions src/app/tags/tag/tag.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Taggable } from '../../shared/interfaces/taggable.interface';
import { Tag } from '../../shared/models';
import { NotificationService, TagService } from '../../shared/services';
import { DialogService } from '../../dialog/dialog-module/dialog.service';


@Component({
Expand All @@ -19,6 +20,7 @@ export class TagComponent {
public loading: boolean;

constructor(
private dialogService: DialogService,
private notificationService: NotificationService,
private tagService: TagService
) {
Expand All @@ -30,7 +32,23 @@ export class TagComponent {
this.onTagEdit.emit(this.tag);
}

public remove(): void {
public showRemoveDialog(): void {
this.dialogService.confirm('TAG_DELETE_CONFIRMATION')
.subscribe(
() => this.remove(),
() => {}
);
}

public onCopySuccess(): void {
this.notificationService.message('COPY_SUCCESS');
}

public onCopyFail(): void {
this.notificationService.message('COPY_FAIL');
}

private remove(): void {
this.loading = true;

this.tagService.remove({
Expand All @@ -41,12 +59,4 @@ export class TagComponent {
.finally(() => this.loading = false)
.subscribe(() => this.onTagRemove.emit(this.tag));
}

public onCopySuccess(): void {
this.notificationService.message('COPY_SUCCESS');
}

public onCopyFail(): void {
this.notificationService.message('COPY_FAIL');
}
}
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,5 +578,6 @@
"TAG_CATEGORY_NAME": "Category name",
"TAG_ALREADY_EXISTS": "Tag already exists",
"NO_TAGS": "No tags",
"EDIT_TAG": "Edit tag"
"EDIT_TAG": "Edit tag",
"TAG_DELETE_CONFIRMATION": "Are you sure you want to delete this tag?"
}
3 changes: 2 additions & 1 deletion src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -578,5 +578,6 @@
"TAG_CATEGORY_NAME": "Название категории",
"TAG_ALREADY_EXISTS": "Тег уже существует",
"NO_TAGS": "Нет тегов",
"EDIT_TAG": "Редактировать тег"
"EDIT_TAG": "Редактировать тег",
"TAG_DELETE_CONFIRMATION": "Вы действительно хотите удалить этот тег?"
}

0 comments on commit bd652f4

Please sign in to comment.