From f089b5e3d114c887b599928012888e815fc876cf Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 5 Jul 2018 09:58:15 -0400 Subject: [PATCH] inherit local base for groupings and ciphers --- src/app/organizations/ciphers.component.ts | 59 +++----------------- src/app/organizations/groupings.component.ts | 19 +------ src/app/vault/ciphers.component.ts | 6 +- src/app/vault/groupings.component.ts | 1 + 4 files changed, 14 insertions(+), 71 deletions(-) diff --git a/src/app/organizations/ciphers.component.ts b/src/app/organizations/ciphers.component.ts index d3ea4d7fc1..a2d9e31e1a 100644 --- a/src/app/organizations/ciphers.component.ts +++ b/src/app/organizations/ciphers.component.ts @@ -1,9 +1,4 @@ -import { - Component, - EventEmitter, - Input, - Output, -} from '@angular/core'; +import { Component } from '@angular/core'; import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; @@ -13,31 +8,24 @@ import { CipherService } from 'jslib/abstractions/cipher.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; -import { CiphersComponent as BaseCiphersComponent } from 'jslib/angular/components/ciphers.component'; - -import { CipherType } from 'jslib/enums/cipherType'; - import { CipherData } from 'jslib/models/data/cipherData'; import { Cipher } from 'jslib/models/domain/cipher'; import { Organization } from 'jslib/models/domain/organization'; import { CipherView } from 'jslib/models/view/cipherView'; +import { CiphersComponent as BaseCiphersComponent } from '../vault/ciphers.component'; + @Component({ selector: 'app-org-vault-ciphers', templateUrl: '../vault/ciphers.component.html', }) export class CiphersComponent extends BaseCiphersComponent { - @Input() showAddNew = true; - @Output() onAttachmentsClicked = new EventEmitter(); - @Output() onCollectionsClicked = new EventEmitter(); - organization: Organization; - cipherType = CipherType; - constructor(cipherService: CipherService, private analytics: Angulartics2, - private toasterService: ToasterService, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService, private apiService: ApiService) { - super(cipherService); + constructor(cipherService: CipherService, analytics: Angulartics2, + toasterService: ToasterService, i18nService: I18nService, + platformUtilsService: PlatformUtilsService, private apiService: ApiService) { + super(cipherService, analytics, toasterService, i18nService, platformUtilsService); } async load(filter: (cipher: CipherView) => boolean = null) { @@ -76,37 +64,4 @@ export class CiphersComponent extends BaseCiphersComponent { checkCipher(c: CipherView) { // do nothing } - - attachments(c: CipherView) { - this.onAttachmentsClicked.emit(c); - } - - collections(c: CipherView) { - this.onCollectionsClicked.emit(c); - } - - async delete(c: CipherView): Promise { - const confirmed = await this.platformUtilsService.showDialog( - this.i18nService.t('deleteItemConfirmation'), this.i18nService.t('deleteItem'), - this.i18nService.t('yes'), this.i18nService.t('no'), 'warning'); - if (!confirmed) { - return false; - } - - await this.cipherService.deleteWithServer(c.id); - this.analytics.eventTrack.next({ action: 'Deleted Cipher' }); - this.toasterService.popAsync('success', null, this.i18nService.t('deletedItem')); - this.refresh(); - } - - copy(value: string, typeI18nKey: string, aType: string) { - if (value == null) { - return; - } - - this.analytics.eventTrack.next({ action: 'Copied ' + aType.toLowerCase() + ' from listing.' }); - this.platformUtilsService.copyToClipboard(value, { doc: window.document }); - this.toasterService.popAsync('info', null, - this.i18nService.t('valueCopied', this.i18nService.t(typeI18nKey))); - } } diff --git a/src/app/organizations/groupings.component.ts b/src/app/organizations/groupings.component.ts index 9e22af6f3b..0f17ca6348 100644 --- a/src/app/organizations/groupings.component.ts +++ b/src/app/organizations/groupings.component.ts @@ -1,42 +1,29 @@ -import { - Component, - EventEmitter, - Input, - Output, -} from '@angular/core'; +import { Component } from '@angular/core'; import { ApiService } from 'jslib/abstractions/api.service'; import { CollectionService } from 'jslib/abstractions/collection.service'; import { FolderService } from 'jslib/abstractions/folder.service'; import { I18nService } from 'jslib/abstractions/i18n.service'; -import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/components/groupings.component'; - import { CollectionData } from 'jslib/models/data/collectionData'; import { Collection } from 'jslib/models/domain/collection'; import { Organization } from 'jslib/models/domain/organization'; import { CollectionView } from 'jslib/models/view/collectionView'; +import { GroupingsComponent as BaseGroupingsComponent } from '../vault/groupings.component'; + @Component({ selector: 'app-org-vault-groupings', templateUrl: '../vault/groupings.component.html', }) export class GroupingsComponent extends BaseGroupingsComponent { - @Output() onSearchTextChanged = new EventEmitter(); - organization: Organization; - searchText: string = ''; - searchPlaceholder: string = null; constructor(collectionService: CollectionService, folderService: FolderService, private apiService: ApiService, private i18nService: I18nService) { super(collectionService, folderService); } - searchTextChanged() { - this.onSearchTextChanged.emit(this.searchText); - } - async loadCollections() { if (this.organization.isAdmin) { const collections = await this.apiService.getCollections(this.organization.id); diff --git a/src/app/vault/ciphers.component.ts b/src/app/vault/ciphers.component.ts index 96ef5376dc..236e9046e5 100644 --- a/src/app/vault/ciphers.component.ts +++ b/src/app/vault/ciphers.component.ts @@ -32,9 +32,9 @@ export class CiphersComponent extends BaseCiphersComponent { cipherType = CipherType; - constructor(cipherService: CipherService, private analytics: Angulartics2, - private toasterService: ToasterService, private i18nService: I18nService, - private platformUtilsService: PlatformUtilsService) { + constructor(cipherService: CipherService, protected analytics: Angulartics2, + protected toasterService: ToasterService, protected i18nService: I18nService, + protected platformUtilsService: PlatformUtilsService) { super(cipherService); } diff --git a/src/app/vault/groupings.component.ts b/src/app/vault/groupings.component.ts index 290183019f..5d1611bb06 100644 --- a/src/app/vault/groupings.component.ts +++ b/src/app/vault/groupings.component.ts @@ -15,6 +15,7 @@ import { GroupingsComponent as BaseGroupingsComponent } from 'jslib/angular/comp }) export class GroupingsComponent extends BaseGroupingsComponent { @Output() onSearchTextChanged = new EventEmitter(); + searchText: string = ''; searchPlaceholder: string = null;