mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-04 18:37:45 +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);
|
userService, collectionService, totpService, passwordGenerationService, messagingService);
|
||||||
}
|
}
|
||||||
|
|
||||||
async load() {
|
|
||||||
await super.load();
|
|
||||||
if (!this.editMode) {
|
|
||||||
this.cipher.organizationId = this.organization.id;
|
|
||||||
}
|
|
||||||
await this.organizationChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected loadCollections() {
|
protected loadCollections() {
|
||||||
if (!this.organization.isAdmin) {
|
if (!this.organization.isAdmin) {
|
||||||
return super.loadCollections();
|
return super.loadCollections();
|
||||||
|
@ -13,12 +13,12 @@
|
|||||||
<i *ngIf="actionSpinner.loading" class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
<i *ngIf="actionSpinner.loading" class="fa fa-spinner fa-spin text-muted" title="{{'loading' | i18n}}"></i>
|
||||||
</small>
|
</small>
|
||||||
</h1>
|
</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}}
|
<i class="fa fa-plus fa-fw"></i>{{'addItem' | i18n}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<app-org-vault-ciphers (onCipherClicked)="editCipher($event)" (onAttachmentsClicked)="editCipherAttachments($event)" (onAddCipher)="addCipher()"
|
<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>
|
</app-org-vault-ciphers>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -52,7 +52,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
organization: Organization;
|
organization: Organization;
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
type: CipherType;
|
type: CipherType;
|
||||||
showAdd = true;
|
|
||||||
|
|
||||||
private modal: ModalComponent = null;
|
private modal: ModalComponent = null;
|
||||||
|
|
||||||
@ -66,7 +65,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.route.parent.params.subscribe(async (params) => {
|
this.route.parent.params.subscribe(async (params) => {
|
||||||
this.organization = await this.userService.getOrganization(params.organizationId);
|
this.organization = await this.userService.getOrganization(params.organizationId);
|
||||||
this.showAdd = this.organization.isAdmin;
|
|
||||||
this.groupingsComponent.organization = this.organization;
|
this.groupingsComponent.organization = this.organization;
|
||||||
this.ciphersComponent.organization = this.organization;
|
this.ciphersComponent.organization = this.organization;
|
||||||
|
|
||||||
@ -124,7 +122,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async clearGroupingFilters() {
|
async clearGroupingFilters() {
|
||||||
this.ciphersComponent.showAddNew = this.showAdd;
|
this.ciphersComponent.showAddNew = true;
|
||||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchVault');
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchVault');
|
||||||
await this.ciphersComponent.applyFilter();
|
await this.ciphersComponent.applyFilter();
|
||||||
this.clearFilters();
|
this.clearFilters();
|
||||||
@ -132,7 +130,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async filterCipherType(type: CipherType, load = false) {
|
async filterCipherType(type: CipherType, load = false) {
|
||||||
this.ciphersComponent.showAddNew = this.showAdd;
|
this.ciphersComponent.showAddNew = true;
|
||||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchType');
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchType');
|
||||||
const filter = (c: CipherView) => c.type === type;
|
const filter = (c: CipherView) => c.type === type;
|
||||||
if (load) {
|
if (load) {
|
||||||
@ -146,7 +144,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async filterCollection(collectionId: string, load = false) {
|
async filterCollection(collectionId: string, load = false) {
|
||||||
this.ciphersComponent.showAddNew = false;
|
this.ciphersComponent.showAddNew = true;
|
||||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
||||||
const filter = (c: CipherView) => {
|
const filter = (c: CipherView) => {
|
||||||
if (collectionId === 'unassigned') {
|
if (collectionId === 'unassigned') {
|
||||||
@ -226,7 +224,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
addCipher() {
|
addCipher() {
|
||||||
const component = this.editCipher(null);
|
const component = this.editCipher(null);
|
||||||
|
component.organizationId = this.organization.id;
|
||||||
component.type = this.type;
|
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) {
|
editCipher(cipher: CipherView) {
|
||||||
@ -238,9 +243,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
|
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
|
||||||
const childComponent = this.modal.show<AddEditComponent>(AddEditComponent, this.cipherAddEditModalRef);
|
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.organization = this.organization;
|
||||||
childComponent.cipherId = cipher == null ? null : cipher.id;
|
childComponent.cipherId = cipher == null ? null : cipher.id;
|
||||||
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
|
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
|
||||||
|
@ -187,7 +187,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async filterCollection(collectionId: string) {
|
async filterCollection(collectionId: string) {
|
||||||
this.ciphersComponent.showAddNew = false;
|
this.ciphersComponent.showAddNew = true;
|
||||||
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
this.groupingsComponent.searchPlaceholder = this.i18nService.t('searchCollection');
|
||||||
await this.ciphersComponent.load((c) => c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1);
|
await this.ciphersComponent.load((c) => c.collectionIds != null && c.collectionIds.indexOf(collectionId) > -1);
|
||||||
this.clearFilters();
|
this.clearFilters();
|
||||||
@ -327,6 +327,13 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
const component = this.editCipher(null);
|
const component = this.editCipher(null);
|
||||||
component.type = this.type;
|
component.type = this.type;
|
||||||
component.folderId = this.folderId === 'none' ? null : this.folderId;
|
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) {
|
editCipher(cipher: CipherView) {
|
||||||
|
Loading…
Reference in New Issue
Block a user