From 3544c96a64ce69e5d5082de13b1e2c092dd28dd9 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 21 Jul 2018 21:58:24 -0400 Subject: [PATCH] nothing selected error --- src/app/vault/vault.component.ts | 31 +++++++++++++++++++++++++++---- src/locales/en/messages.json | 3 +++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/app/vault/vault.component.ts b/src/app/vault/vault.component.ts index a209ccb7a7..bcafdc0ee1 100644 --- a/src/app/vault/vault.component.ts +++ b/src/app/vault/vault.component.ts @@ -11,6 +11,8 @@ import { Router, } from '@angular/router'; +import { ToasterService } from 'angular2-toaster'; + import { CipherType } from 'jslib/enums/cipherType'; import { CipherView } from 'jslib/models/view/cipherView'; @@ -72,7 +74,7 @@ export class VaultComponent implements OnInit { private i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver, private tokenService: TokenService, private cryptoService: CryptoService, private messagingService: MessagingService, private userService: UserService, - private platformUtilsService: PlatformUtilsService) { } + private platformUtilsService: PlatformUtilsService, private toasterService: ToasterService) { } async ngOnInit() { this.showVerifyEmail = !(await this.tokenService.getEmailVerified()); @@ -323,6 +325,13 @@ export class VaultComponent implements OnInit { } bulkDelete() { + const selectedIds = this.ciphersComponent.getSelectedIds(); + if (selectedIds.length === 0) { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('nothingSelected')); + return; + } + if (this.modal != null) { this.modal.close(); } @@ -331,7 +340,7 @@ export class VaultComponent implements OnInit { this.modal = this.bulkDeleteModalRef.createComponent(factory).instance; const childComponent = this.modal.show(BulkDeleteComponent, this.bulkDeleteModalRef); - childComponent.cipherIds = this.ciphersComponent.getSelectedIds(); + childComponent.cipherIds = selectedIds; childComponent.onDeleted.subscribe(async () => { this.modal.close(); await this.ciphersComponent.refresh(); @@ -343,6 +352,13 @@ export class VaultComponent implements OnInit { } bulkShare() { + const selectedCiphers = this.ciphersComponent.getSelected(); + if (selectedCiphers.length === 0) { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('nothingSelected')); + return; + } + if (this.modal != null) { this.modal.close(); } @@ -351,7 +367,7 @@ export class VaultComponent implements OnInit { this.modal = this.bulkShareModalRef.createComponent(factory).instance; const childComponent = this.modal.show(BulkShareComponent, this.bulkShareModalRef); - childComponent.ciphers = this.ciphersComponent.getSelected(); + childComponent.ciphers = selectedCiphers; childComponent.onShared.subscribe(async () => { this.modal.close(); await this.ciphersComponent.refresh(); @@ -363,6 +379,13 @@ export class VaultComponent implements OnInit { } bulkMove() { + const selectedIds = this.ciphersComponent.getSelectedIds(); + if (selectedIds.length === 0) { + this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'), + this.i18nService.t('nothingSelected')); + return; + } + if (this.modal != null) { this.modal.close(); } @@ -371,7 +394,7 @@ export class VaultComponent implements OnInit { this.modal = this.bulkMoveModalRef.createComponent(factory).instance; const childComponent = this.modal.show(BulkMoveComponent, this.bulkMoveModalRef); - childComponent.cipherIds = this.ciphersComponent.getSelectedIds(); + childComponent.cipherIds = selectedIds; childComponent.onMoved.subscribe(async () => { this.modal.close(); await this.ciphersComponent.refresh(); diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index ec0ee61657..c99707d0c2 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -2334,5 +2334,8 @@ }, "refunded": { "message": "Refunded" + }, + "nothingSelected": { + "message": "You have not selected anything." } }