From 64bc115109f40ac92b42af980024e36f90df6285 Mon Sep 17 00:00:00 2001 From: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Date: Fri, 8 Oct 2021 07:15:02 +1000 Subject: [PATCH] Set default ownership if Personal Ownership policy applies (#509) --- angular/src/components/add-edit.component.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/angular/src/components/add-edit.component.ts b/angular/src/components/add-edit.component.ts index 837a027994..f401bf93cc 100644 --- a/angular/src/components/add-edit.component.ts +++ b/angular/src/components/add-edit.component.ts @@ -150,18 +150,21 @@ export class AddEditComponent implements OnInit { } async init() { - const myEmail = await this.userService.getEmail(); - this.ownershipOptions.push({ name: myEmail, value: null }); + if (await this.policyService.policyAppliesToUser(PolicyType.PersonalOwnership)) { + this.allowPersonal = false; + } else { + const myEmail = await this.userService.getEmail(); + this.ownershipOptions.push({ name: myEmail, value: null }); + } + const orgs = await this.userService.getAllOrganizations(); orgs.sort(Utils.getSortFunction(this.i18nService, 'name')).forEach(o => { if (o.enabled && o.status === OrganizationUserStatusType.Confirmed) { this.ownershipOptions.push({ name: o.name, value: o.id }); } }); - - if (this.allowPersonal && await this.policyService.policyAppliesToUser(PolicyType.PersonalOwnership)) { - this.allowPersonal = false; - this.ownershipOptions.splice(0, 1); + if (!this.allowPersonal) { + this.organizationId = this.ownershipOptions[0].value; } this.writeableCollections = await this.loadCollections();