pre-select org an collection on add

This commit is contained in:
Kyle Spearrin 2018-10-30 08:56:38 -04:00
parent bc5cec82cc
commit 6627d29c7c
4 changed files with 21 additions and 8 deletions

2
jslib

@ -1 +1 @@
Subproject commit aa0b274f8fd80db620abd4a85c3086f511e19c88
Subproject commit a98a8bda9bea5b7bb4459cea9413e0f03b2aa068

View File

@ -43,6 +43,13 @@ export class AddEditComponent extends BaseAddEditComponent {
if (params.folderId) {
this.folderId = params.folderId;
}
if (params.collectionId) {
const collection = this.writeableCollections.filter((c) => c.id === params.collectionId);
if (collection != null && collection.length > 0) {
this.collectionIds = [collection[0].id];
this.organizationId = collection[0].organizationId;
}
}
if (params.type) {
const type = parseInt(params.type, null);
this.type = type;

View File

@ -10,7 +10,7 @@
[(ngModel)]="searchText" (input)="search(200)" appAutofocus>
<i class="fa fa-search"></i>
</div>
<div class="right" *ngIf="showAdd">
<div class="right">
<button type="button" appBlurClick (click)="addCipher()" title="{{'addItem' | i18n}}">
<i class="fa fa-plus fa-lg fa-fw"></i>
</button>
@ -57,7 +57,7 @@
<i class="fa fa-spinner fa-spin fa-3x" *ngIf="!loaded"></i>
<ng-container *ngIf="loaded">
<p>{{'noItemsInList' | i18n}}</p>
<button (click)="addCipher()" class="btn block primary link" *ngIf="showAdd">
<button (click)="addCipher()" class="btn block primary link">
{{'addItem' | i18n}}
</button>
</ng-container>

View File

@ -45,8 +45,8 @@ const ComponentId = 'CiphersComponent';
export class CiphersComponent extends BaseCiphersComponent implements OnInit, OnDestroy {
groupingTitle: string;
state: any;
showAdd = true;
folderId: string = null;
collectionId: string = null;
type: CipherType = null;
pagedCiphers: CipherView[] = [];
nestedFolders: Array<TreeNode<FolderView>>;
@ -108,15 +108,15 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
}
await super.load((c) => c.folderId === this.folderId);
} else if (params.collectionId) {
this.showAdd = false;
this.collectionId = params.collectionId;
this.searchPlaceholder = this.i18nService.t('searchCollection');
const collectionNode = await this.collectionService.getNested(params.collectionId);
const collectionNode = await this.collectionService.getNested(this.collectionId);
if (collectionNode != null && collectionNode.node != null) {
this.groupingTitle = collectionNode.node.name;
this.nestedCollections = collectionNode.children != null && collectionNode.children.length > 0 ?
collectionNode.children : null;
}
await super.load((c) => c.collectionIds != null && c.collectionIds.indexOf(params.collectionId) > -1);
await super.load((c) => c.collectionIds != null && c.collectionIds.indexOf(this.collectionId) > -1);
} else {
this.groupingTitle = this.i18nService.t('allItems');
await super.load();
@ -195,7 +195,13 @@ export class CiphersComponent extends BaseCiphersComponent implements OnInit, On
addCipher() {
super.addCipher();
this.router.navigate(['/add-cipher'], { queryParams: { folderId: this.folderId, type: this.type } });
this.router.navigate(['/add-cipher'], {
queryParams: {
folderId: this.folderId,
type: this.type,
collectionId: this.collectionId,
},
});
}
back() {