1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-19 02:51:14 +02:00

selection highlights

This commit is contained in:
Kyle Spearrin 2018-01-27 08:52:39 -05:00
parent b0e78be1f6
commit 85d4da7def
4 changed files with 59 additions and 15 deletions

View File

@ -1,12 +1,12 @@
<div class="content"> <div class="content">
<div class="inner-content"> <div class="inner-content">
<ul> <ul>
<li> <li [ngClass]="{active: selectedAll}">
<a href="#" appStopClick (click)="all()"> <a href="#" appStopClick (click)="all()">
<i class="fa fa-fw fa-spinner"></i> {{'allItems' | i18n}} <i class="fa fa-fw fa-spinner"></i> {{'allItems' | i18n}}
</a> </a>
</li> </li>
<li> <li [ngClass]="{active: selectedFavorites}">
<a href="#" appStopClick (click)="favorites()"> <a href="#" appStopClick (click)="favorites()">
<i class="fa fa-fw fa-star"></i> {{'favorites' | i18n}} <i class="fa fa-fw fa-star"></i> {{'favorites' | i18n}}
</a> </a>
@ -14,25 +14,25 @@
</ul> </ul>
<h2><i class="fa fa-tag"></i> {{'types' | i18n}}</h2> <h2><i class="fa fa-tag"></i> {{'types' | i18n}}</h2>
<ul> <ul>
<li> <li [ngClass]="{active: selectedType === cipherType.Login}">
<a href="#" appStopClick (click)="type(cipherType.Login)"> <a href="#" appStopClick (click)="type(cipherType.Login)">
<i class="fa fa-fw fa-globe"></i> <i class="fa fa-fw fa-globe"></i>
{{'typeLogin' | i18n}} {{'typeLogin' | i18n}}
</a> </a>
</li> </li>
<li> <li [ngClass]="{active: selectedType === cipherType.Card}">
<a href="#" appStopClick (click)="type(cipherType.Card)"> <a href="#" appStopClick (click)="type(cipherType.Card)">
<i class="fa fa-fw fa-credit-card"></i> <i class="fa fa-fw fa-credit-card"></i>
{{'typeCard' | i18n}} {{'typeCard' | i18n}}
</a> </a>
</li> </li>
<li> <li [ngClass]="{active: selectedType === cipherType.Identity}">
<a href="#" appStopClick (click)="type(cipherType.Identity)"> <a href="#" appStopClick (click)="type(cipherType.Identity)">
<i class="fa fa-fw fa-id-card-o"></i> <i class="fa fa-fw fa-id-card-o"></i>
{{'typeIdentity' | i18n}} {{'typeIdentity' | i18n}}
</a> </a>
</li> </li>
<li> <li [ngClass]="{active: selectedType === cipherType.SecureNote}">
<a href="#" appStopClick (click)="type(cipherType.SecureNote)"> <a href="#" appStopClick (click)="type(cipherType.SecureNote)">
<i class="fa fa-fw fa-sticky-note-o"></i> <i class="fa fa-fw fa-sticky-note-o"></i>
{{'typeSecureNote' | i18n}} {{'typeSecureNote' | i18n}}
@ -41,7 +41,7 @@
</ul> </ul>
<h2><i class="fa fa-folder"></i> {{'folders' | i18n}}</h2> <h2><i class="fa fa-folder"></i> {{'folders' | i18n}}</h2>
<ul class="fa-ul"> <ul class="fa-ul">
<li *ngFor="let f of folders"> <li *ngFor="let f of folders" [ngClass]="{active: selectedFolder && f.id === selectedFolderId}">
<a href="#" appStopClick (click)="folder(f)"> <a href="#" appStopClick (click)="folder(f)">
<i class="fa-li fa fa-caret-right"></i> {{f.name}} <i class="fa-li fa fa-caret-right"></i> {{f.name}}
</a> </a>
@ -50,7 +50,7 @@
<div *ngIf="collections && collections.length"> <div *ngIf="collections && collections.length">
<h2><i class="fa fa-cubes"></i> {{'collections' | i18n}}</h2> <h2><i class="fa fa-cubes"></i> {{'collections' | i18n}}</h2>
<ul class="fa-ul"> <ul class="fa-ul">
<li *ngFor="let c of collections"> <li *ngFor="let c of collections" [ngClass]="{active: c.id === selectedCollectionId}">
<a href="#" appStopClick (click)="collection(c)"> <a href="#" appStopClick (click)="collection(c)">
<i class="fa-li fa fa-caret-right"></i> {{c.name}} <i class="fa-li fa fa-caret-right"></i> {{c.name}}
</a> </a>

View File

@ -30,6 +30,12 @@ export class GroupingsComponent implements OnInit {
folders: any[]; folders: any[];
collections: any[]; collections: any[];
cipherType = CipherType; cipherType = CipherType;
selectedAll: boolean = false;
selectedFavorites: boolean = false;
selectedType: CipherType = null;
selectedFolder: boolean = false;
selectedFolderId: string = null;
selectedCollectionId: string = null;
constructor(private collectionService: CollectionService, private folderService: FolderService) { constructor(private collectionService: CollectionService, private folderService: FolderService) {
// ctor // ctor
@ -41,22 +47,42 @@ export class GroupingsComponent implements OnInit {
} }
all() { all() {
this.clearSelections();
this.selectedAll = true;
this.onAllClicked.emit(); this.onAllClicked.emit();
} }
favorites() { favorites() {
this.clearSelections();
this.selectedFavorites = true;
this.onFavoritesClicked.emit(); this.onFavoritesClicked.emit();
} }
type(type: CipherType) { type(type: CipherType) {
this.clearSelections();
this.selectedType = type;
this.onCipherTypeClicked.emit(type); this.onCipherTypeClicked.emit(type);
} }
folder(folder: FolderView) { folder(folder: FolderView) {
this.clearSelections();
this.selectedFolder = true;
this.selectedFolderId = folder.id;
this.onFolderClicked.emit(folder); this.onFolderClicked.emit(folder);
} }
collection(collection: CollectionView) { collection(collection: CollectionView) {
this.clearSelections();
this.selectedCollectionId = collection.id;
this.onCollectionClicked.emit(collection); this.onCollectionClicked.emit(collection);
} }
clearSelections() {
this.selectedAll = false;
this.selectedFavorites = false;
this.selectedType = null;
this.selectedFolder = false;
this.selectedFolderId = null;
this.selectedCollectionId = null;
}
} }

View File

@ -14,6 +14,7 @@ import {
import { Location } from '@angular/common'; import { Location } from '@angular/common';
import { CiphersComponent } from './ciphers.component'; import { CiphersComponent } from './ciphers.component';
import { GroupingsComponent } from './groupings.component';
import { CipherType } from 'jslib/enums/cipherType'; import { CipherType } from 'jslib/enums/cipherType';
@ -27,6 +28,7 @@ import { FolderView } from 'jslib/models/view/folderView';
}) })
export class VaultComponent implements OnInit { export class VaultComponent implements OnInit {
@ViewChild(CiphersComponent) ciphersComponent: CiphersComponent; @ViewChild(CiphersComponent) ciphersComponent: CiphersComponent;
@ViewChild(GroupingsComponent) groupingsComponent: GroupingsComponent;
action: string; action: string;
cipherId: string = null; cipherId: string = null;
@ -53,14 +55,21 @@ export class VaultComponent implements OnInit {
} }
if (params['favorites']) { if (params['favorites']) {
this.groupingsComponent.selectedFavorites = true;
await this.filterFavorites(); await this.filterFavorites();
} else if (params['type']) { } else if (params['type']) {
await this.filterCipherType(parseInt(params['type'])); const t = parseInt(params['type']);
this.groupingsComponent.selectedType = t;
await this.filterCipherType(t);
} else if (params['folderId']) { } else if (params['folderId']) {
this.groupingsComponent.selectedFolder = true;
this.groupingsComponent.selectedFolderId = params['folderId'];
await this.filterFolder(params['folderId']); await this.filterFolder(params['folderId']);
} else if (params['collectionId']) { } else if (params['collectionId']) {
this.groupingsComponent.selectedCollectionId = params['collectionId'];
await this.filterCollection(params['collectionId']); await this.filterCollection(params['collectionId']);
} else { } else {
this.groupingsComponent.selectedAll = true;
await this.ciphersComponent.load(); await this.ciphersComponent.load();
} }
}); });
@ -73,7 +82,7 @@ export class VaultComponent implements OnInit {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = 'view'; this.action = 'view';
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
} }
editCipher(cipher: CipherView) { editCipher(cipher: CipherView) {
@ -83,7 +92,7 @@ export class VaultComponent implements OnInit {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = 'edit'; this.action = 'edit';
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
} }
addCipher() { addCipher() {
@ -93,20 +102,20 @@ export class VaultComponent implements OnInit {
this.action = 'add'; this.action = 'add';
this.cipherId = null; this.cipherId = null;
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
} }
savedCipher(cipher: CipherView) { savedCipher(cipher: CipherView) {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = 'view'; this.action = 'view';
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
this.ciphersComponent.updateCipher(cipher); this.ciphersComponent.updateCipher(cipher);
} }
deletedCipher(cipher: CipherView) { deletedCipher(cipher: CipherView) {
this.cipherId = null; this.cipherId = null;
this.action = null; this.action = null;
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
this.ciphersComponent.removeCipher(cipher.id); this.ciphersComponent.removeCipher(cipher.id);
} }
@ -117,7 +126,7 @@ export class VaultComponent implements OnInit {
cancelledAddEdit(cipher: CipherView) { cancelledAddEdit(cipher: CipherView) {
this.cipherId = cipher.id; this.cipherId = cipher.id;
this.action = this.cipherId != null ? 'view' : null; this.action = this.cipherId != null ? 'view' : null;
this.go({ action: this.action, cipherId: this.cipherId }); this.go();
} }
async clearGroupingFilters() { async clearGroupingFilters() {

View File

@ -128,6 +128,15 @@ textarea {
padding: 5px 0; padding: 5px 0;
color: $text-color; color: $text-color;
} }
&.active {
background-color: darken($background-color-alt, 5%);
border-radius: $border-radius;
margin-left: -15px;
margin-right: -15px;
padding-left: 15px;
padding-right: 15px;
}
} }
} }
} }