migrating accept families for enterprise setup component (#8895)
This commit is contained in:
parent
82a83ead98
commit
b672b038b7
|
@ -1,51 +1,37 @@
|
||||||
<div class="container page-content">
|
<div class="tw-container">
|
||||||
<div class="page-header">
|
<h1 bitTypography="h1">{{ "sponsoredFamiliesOffer" | i18n }}</h1>
|
||||||
<h1>{{ "sponsoredFamiliesOffer" | i18n }}</h1>
|
<div *ngIf="loading" class="tw-mt-5 tw-flex tw-justify-center">
|
||||||
</div>
|
|
||||||
<div *ngIf="loading" class="mt-5 d-flex justify-content-center">
|
|
||||||
<i
|
<i
|
||||||
class="bwi bwi-spinner bwi-spin bwi-2x text-muted"
|
class="bwi bwi-spinner bwi-spin bwi-2x tw-text-muted"
|
||||||
title="{{ 'loading' | i18n }}"
|
title="{{ 'loading' | i18n }}"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
></i>
|
></i>
|
||||||
<span class="sr-only">{{ "loading" | i18n }}</span>
|
<span class="tw-sr-only">{{ "loading" | i18n }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!loading && badToken" class="mt-5 d-flex justify-content-center">
|
<div *ngIf="!loading && badToken" class="tw-mt-5 tw-flex tw-justify-center">
|
||||||
<span>{{ "badToken" | i18n }}</span>
|
<span>{{ "badToken" | i18n }}</span>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form [bitSubmit]="submit" [formGroup]="formGroup" *ngIf="!loading && !badToken">
|
||||||
#form
|
<p bitTypography="body1">{{ "acceptBitwardenFamiliesHelp" | i18n }}</p>
|
||||||
(ngSubmit)="submit()"
|
<bit-form-field class="tw-w-1/2">
|
||||||
[appApiAction]="formPromise"
|
<bit-label>{{ "sponsoredFamiliesSelectOffer" | i18n }}</bit-label>
|
||||||
ngNativeValidate
|
<bit-select formControlName="selectedFamilyOrganizationId">
|
||||||
*ngIf="!loading && !badToken"
|
<bit-option value="" label="-- {{ 'select' | i18n }} --" disabled></bit-option>
|
||||||
|
<bit-option value="createNew" label="{{ 'newFamiliesOrganization' | i18n }}"></bit-option>
|
||||||
|
<bit-option
|
||||||
|
*ngFor="let o of existingFamilyOrganizations$ | async"
|
||||||
|
[label]="o.name"
|
||||||
|
[value]="o.id"
|
||||||
>
|
>
|
||||||
<p>
|
</bit-option>
|
||||||
<span>{{ "acceptBitwardenFamiliesHelp" | i18n }}</span>
|
</bit-select>
|
||||||
</p>
|
</bit-form-field>
|
||||||
<div class="form-group col-6">
|
<div *ngIf="showNewOrganization">
|
||||||
<label for="availableSponsorshipOrg">{{ "sponsoredFamiliesSelectOffer" | i18n }}</label>
|
|
||||||
<select
|
|
||||||
id="availableSponsorshipOrg"
|
|
||||||
name="Available Sponsorship Organization"
|
|
||||||
[(ngModel)]="selectedFamilyOrganizationId"
|
|
||||||
class="form-control"
|
|
||||||
required
|
|
||||||
>
|
|
||||||
<option value="" disabled>-- {{ "select" | i18n }} --</option>
|
|
||||||
<option value="createNew">{{ "newFamiliesOrganization" | i18n }}</option>
|
|
||||||
<option *ngFor="let o of existingFamilyOrganizations$ | async" [ngValue]="o.id">
|
|
||||||
{{ o.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="showNewOrganization" class="col-12">
|
|
||||||
<app-organization-plans></app-organization-plans>
|
<app-organization-plans></app-organization-plans>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-6" *ngIf="!showNewOrganization">
|
<div class="w-1/2" *ngIf="!showNewOrganization">
|
||||||
<button class="btn btn-primary mt-2 btn-submit" [disabled]="form.loading" type="submit">
|
<button bitButton buttonType="primary" bitFormButton type="submit">
|
||||||
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
|
{{ "acceptOffer" | i18n }}
|
||||||
<span>{{ "acceptOffer" | i18n }}</span>
|
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
import { Component, OnDestroy, OnInit, ViewChild } from "@angular/core";
|
||||||
|
import { FormBuilder, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
import { lastValueFrom, Observable, Subject } from "rxjs";
|
import { lastValueFrom, Observable, Subject } from "rxjs";
|
||||||
import { first, map, takeUntil } from "rxjs/operators";
|
import { first, map, takeUntil } from "rxjs/operators";
|
||||||
|
@ -43,7 +44,6 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
loading = true;
|
loading = true;
|
||||||
badToken = false;
|
badToken = false;
|
||||||
formPromise: Promise<any>;
|
|
||||||
|
|
||||||
token: string;
|
token: string;
|
||||||
existingFamilyOrganizations: Organization[];
|
existingFamilyOrganizations: Organization[];
|
||||||
|
@ -54,7 +54,9 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||||
_selectedFamilyOrganizationId = "";
|
_selectedFamilyOrganizationId = "";
|
||||||
|
|
||||||
private _destroy = new Subject<void>();
|
private _destroy = new Subject<void>();
|
||||||
|
formGroup = this.formBuilder.group({
|
||||||
|
selectedFamilyOrganizationId: ["", Validators.required],
|
||||||
|
});
|
||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
|
@ -65,6 +67,7 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||||
private validationService: ValidationService,
|
private validationService: ValidationService,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
|
private formBuilder: FormBuilder,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
|
@ -101,6 +104,9 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||||
this.selectedFamilyOrganizationId = "createNew";
|
this.selectedFamilyOrganizationId = "createNew";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.formGroup.valueChanges.pipe(takeUntil(this._destroy)).subscribe((val) => {
|
||||||
|
this.selectedFamilyOrganizationId = val.selectedFamilyOrganizationId;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy(): void {
|
ngOnDestroy(): void {
|
||||||
|
@ -108,11 +114,9 @@ export class FamiliesForEnterpriseSetupComponent implements OnInit, OnDestroy {
|
||||||
this._destroy.complete();
|
this._destroy.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit() {
|
submit = async () => {
|
||||||
this.formPromise = this.doSubmit(this._selectedFamilyOrganizationId);
|
await this.doSubmit(this._selectedFamilyOrganizationId);
|
||||||
await this.formPromise;
|
};
|
||||||
this.formPromise = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
get selectedFamilyOrganizationId() {
|
get selectedFamilyOrganizationId() {
|
||||||
return this._selectedFamilyOrganizationId;
|
return this._selectedFamilyOrganizationId;
|
||||||
|
|
Loading…
Reference in New Issue