-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-11904] - send options form (#11142)
* send options form * remove commented code * fix margin. update i18 key * remove unecessary input * remove unnecessary typing. DRY up messages
- Loading branch information
1 parent
eec84d8
commit c4d66a1
Showing
10 changed files
with
180 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
libs/tools/send/send-ui/src/send-form/components/options/send-options.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<bit-section [formGroup]="sendOptionsForm"> | ||
<bit-section-header> | ||
<h2 class="tw-mt-4" bitTypography="h5">{{ "additionalOptions" | i18n }}</h2> | ||
</bit-section-header> | ||
<bit-card> | ||
<bit-form-field> | ||
<bit-label>{{ "limitSendViews" | i18n }}</bit-label> | ||
<input bitInput type="number" formControlName="maxAccessCount" min="1" /> | ||
<bit-hint>{{ "limitSendViewsHint" | i18n }}</bit-hint> | ||
<bit-hint *ngIf="shouldShowCount" | ||
> {{ "limitSendViewsCount" | i18n: viewsLeft }}</bit-hint | ||
> | ||
</bit-form-field> | ||
<bit-form-field> | ||
<bit-label *ngIf="!hasPassword">{{ "password" | i18n }}</bit-label> | ||
<bit-label *ngIf="hasPassword">{{ "newPassword" | i18n }}</bit-label> | ||
<input bitInput type="password" formControlName="password" /> | ||
<button type="button" bitIconButton bitSuffix bitPasswordInputToggle></button> | ||
<button type="button" bitIconButton="bwi-refresh" bitSuffix></button> | ||
<bit-hint>{{ "sendPasswordDescV2" | i18n }}</bit-hint> | ||
</bit-form-field> | ||
<bit-form-control> | ||
<input bitCheckbox type="checkbox" formControlName="hideEmail" /> | ||
<bit-label>{{ "hideYourEmail" | i18n }}</bit-label> | ||
</bit-form-control> | ||
<bit-form-field> | ||
<bit-label>{{ "privateNote" | i18n }}</bit-label> | ||
<textarea bitInput rows="4" formControlName="notes"></textarea> | ||
</bit-form-field> | ||
</bit-card> | ||
</bit-section> |
95 changes: 95 additions & 0 deletions
95
libs/tools/send/send-ui/src/send-form/components/options/send-options.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { CommonModule } from "@angular/common"; | ||
import { Component, Input, OnInit } from "@angular/core"; | ||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; | ||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms"; | ||
|
||
import { JslibModule } from "@bitwarden/angular/jslib.module"; | ||
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view"; | ||
import { | ||
CardComponent, | ||
CheckboxModule, | ||
FormFieldModule, | ||
IconButtonModule, | ||
SectionComponent, | ||
SectionHeaderComponent, | ||
TypographyModule, | ||
} from "@bitwarden/components"; | ||
|
||
import { SendFormConfig } from "../../abstractions/send-form-config.service"; | ||
import { SendFormContainer } from "../../send-form-container"; | ||
|
||
@Component({ | ||
selector: "tools-send-options", | ||
templateUrl: "./send-options.component.html", | ||
standalone: true, | ||
imports: [ | ||
SectionComponent, | ||
SectionHeaderComponent, | ||
TypographyModule, | ||
JslibModule, | ||
CardComponent, | ||
FormFieldModule, | ||
ReactiveFormsModule, | ||
IconButtonModule, | ||
CheckboxModule, | ||
CommonModule, | ||
], | ||
}) | ||
export class SendOptionsComponent implements OnInit { | ||
@Input({ required: true }) | ||
config: SendFormConfig; | ||
@Input() | ||
originalSendView: SendView; | ||
sendOptionsForm = this.formBuilder.group({ | ||
maxAccessCount: [null as number], | ||
accessCount: [null as number], | ||
notes: [null as string], | ||
password: [null as string], | ||
hideEmail: [false as boolean], | ||
}); | ||
get hasPassword(): boolean { | ||
return ( | ||
this.sendOptionsForm.value.password !== null && this.sendOptionsForm.value.password !== "" | ||
); | ||
} | ||
|
||
get shouldShowCount(): boolean { | ||
return this.config.mode === "edit" && this.sendOptionsForm.value.maxAccessCount !== null; | ||
} | ||
|
||
get viewsLeft(): number { | ||
return this.sendOptionsForm.value.maxAccessCount | ||
? this.sendOptionsForm.value.maxAccessCount - this.sendOptionsForm.value.accessCount | ||
: 0; | ||
} | ||
|
||
constructor( | ||
private sendFormContainer: SendFormContainer, | ||
private formBuilder: FormBuilder, | ||
) { | ||
this.sendFormContainer.registerChildForm("sendOptionsForm", this.sendOptionsForm); | ||
this.sendOptionsForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => { | ||
this.sendFormContainer.patchSend((send) => { | ||
Object.assign(send, { | ||
maxAccessCount: value.maxAccessCount, | ||
accessCount: value.accessCount, | ||
password: value.password, | ||
hideEmail: value.hideEmail, | ||
notes: value.notes, | ||
}); | ||
return send; | ||
}); | ||
}); | ||
} | ||
ngOnInit() { | ||
if (this.sendFormContainer.originalSendView) { | ||
this.sendOptionsForm.patchValue({ | ||
maxAccessCount: this.sendFormContainer.originalSendView.maxAccessCount, | ||
accessCount: this.sendFormContainer.originalSendView.accessCount, | ||
password: this.sendFormContainer.originalSendView.password, | ||
hideEmail: this.sendFormContainer.originalSendView.hideEmail, | ||
notes: this.sendFormContainer.originalSendView.notes, | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...tools/send/send-ui/src/send-form/components/send-details/send-text-details.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.