mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-06 09:20:43 +01:00
set org id and collections if filtered
This commit is contained in:
parent
69f0339bd5
commit
a24c41ff25
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 3021afc9ddae1579f2226010ee487fa3edcddb0b
|
||||
Subproject commit 0a36a211c355ada433ce9b0560c5ab85a6cead23
|
@ -40,14 +40,6 @@ export class AddEditComponent extends BaseAddEditComponent {
|
||||
userService, collectionService, totpService, passwordGenerationService, messagingService);
|
||||
}
|
||||
|
||||
async load() {
|
||||
await super.load();
|
||||
if (!this.editMode) {
|
||||
this.cipher.organizationId = this.organization.id;
|
||||
}
|
||||
await this.organizationChanged();
|
||||
}
|
||||
|
||||
protected loadCollections() {
|
||||
if (!this.organization.isAdmin) {
|
||||
return super.loadCollections();
|
||||
|
@ -13,12 +13,12 @@
|
||||
<i *ngIf="actionSpinner.loading" class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
||||
</small>
|
||||
</h1>
|
||||
<button type="button" class="btn btn-outline-primary btn-sm ml-auto" (click)="addCipher()" *ngIf="showAdd">
|
||||
<button type="button" class="btn btn-outline-primary btn-sm ml-auto" (click)="addCipher()">
|
||||
<i class="fa fa-plus fa-fw"></i>{{'addItem' | i18n}}
|
||||
</button>
|
||||
</div>
|
||||
<app-org-vault-ciphers (onCipherClicked)="editCipher($event)" (onAttachmentsClicked)="editCipherAttachments($event)" (onAddCipher)="addCipher()"
|
||||
(onCollectionsClicked)="editCipherCollections($event)" (onEventsClicked)="viewEvents($event)" [showAddNew]="showAdd">
|
||||
(onCollectionsClicked)="editCipherCollections($event)" (onEventsClicked)="viewEvents($event)">
|
||||
</app-org-vault-ciphers>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -52,7 +52,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
organization: Organization;
|
||||
collectionId: string;
|
||||
type: CipherType;
|
||||
showAdd = true;
|
||||
|
||||
private modal: ModalComponent = null;
|
||||
|
||||
@ -66,7 +65,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
ngOnInit() {
|
||||
this.route.parent.params.subscribe(async (params) => {
|
||||
this.organization = await this.userService.getOrganization(params.organizationId);
|
||||
this.showAdd = this.organization.isAdmin;
|
||||
this.groupingsComponent.organization = this.organization;
|
||||
this.ciphersComponent.organization = this.organization;
|
||||
|
||||
@ -124,7 +122,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async clearGroupingFilters() {
|
||||
this.ciphersComponent.showAddNew = this.showAdd;
|
||||
this.ciphersComponent.showAddNew = true;
|
||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchVault');
|
||||
await this.ciphersComponent.applyFilter();
|
||||
this.clearFilters();
|
||||
@ -132,7 +130,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async filterCipherType(type: CipherType, load = false) {
|
||||
this.ciphersComponent.showAddNew = this.showAdd;
|
||||
this.ciphersComponent.showAddNew = true;
|
||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchType');
|
||||
const filter = (c: CipherView) => c.type === type;
|
||||
if (load) {
|
||||
@ -146,7 +144,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async filterCollection(collectionId: string, load = false) {
|
||||
this.ciphersComponent.showAddNew = false;
|
||||
this.ciphersComponent.showAddNew = true;
|
||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
||||
const filter = (c: CipherView) => {
|
||||
if (collectionId === 'unassigned') {
|
||||
@ -226,7 +224,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
addCipher() {
|
||||
const component = this.editCipher(null);
|
||||
component.organizationId = this.organization.id;
|
||||
component.type = this.type;
|
||||
if (this.organization.isAdmin) {
|
||||
component.collections = this.groupingsComponent.collections.filter((c) => !c.readOnly);
|
||||
}
|
||||
if (this.collectionId != null) {
|
||||
component.collectionIds = [this.collectionId];
|
||||
}
|
||||
}
|
||||
|
||||
editCipher(cipher: CipherView) {
|
||||
@ -238,9 +243,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
|
||||
const childComponent = this.modal.show<AddEditComponent>(AddEditComponent, this.cipherAddEditModalRef);
|
||||
|
||||
if (this.organization.isAdmin) {
|
||||
childComponent.collections = this.groupingsComponent.collections.filter((c) => !c.readOnly);
|
||||
}
|
||||
childComponent.organization = this.organization;
|
||||
childComponent.cipherId = cipher == null ? null : cipher.id;
|
||||
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
|
||||
|
@ -187,7 +187,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async filterCollection(collectionId: string) {
|
||||
this.ciphersComponent.showAddNew = false;
|
||||
this.ciphersComponent.showAddNew = true;
|
||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
||||
await this.ciphersComponent.load((c) => c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1);
|
||||
this.clearFilters();
|
||||
@ -327,6 +327,13 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
const component = this.editCipher(null);
|
||||
component.type = this.type;
|
||||
component.folderId = this.folderId === 'none' ? null : this.folderId;
|
||||
if (this.collectionId != null) {
|
||||
const collection = this.groupingsComponent.collections.filter((c) => c.id === this.collectionId);
|
||||
if (collection.length > 0) {
|
||||
component.organizationId = collection[0].organizationId;
|
||||
component.collectionIds = [this.collectionId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editCipher(cipher: CipherView) {
|
||||
|
Loading…
Reference in New Issue
Block a user