mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 16:23:44 +00:00
added date/time fallbacks for safar/ff (#290)
This commit is contained in:
@@ -37,7 +37,11 @@ export class AddEditComponent implements OnInit {
|
|||||||
disableSend = false;
|
disableSend = false;
|
||||||
send: SendView;
|
send: SendView;
|
||||||
deletionDate: string;
|
deletionDate: string;
|
||||||
|
deletionDateFallback: string;
|
||||||
|
deletionTimeFallback: string;
|
||||||
expirationDate: string;
|
expirationDate: string;
|
||||||
|
expirationDateFallback: string;
|
||||||
|
expirationTimeFallback: string;
|
||||||
hasPassword: boolean;
|
hasPassword: boolean;
|
||||||
password: string;
|
password: string;
|
||||||
showPassword = false;
|
showPassword = false;
|
||||||
@@ -89,6 +93,10 @@ export class AddEditComponent implements OnInit {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isDateTimeLocalSupported(): boolean {
|
||||||
|
return !(this.platformUtilsService.isFirefox() || this.platformUtilsService.isSafari());
|
||||||
|
}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
await this.load();
|
await this.load();
|
||||||
}
|
}
|
||||||
@@ -105,6 +113,14 @@ export class AddEditComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get expirationDateTimeFallback() {
|
||||||
|
return `${this.expirationDateFallback}T${this.expirationTimeFallback}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
get deletionDateTimeFallback() {
|
||||||
|
return `${this.deletionDateFallback}T${this.deletionTimeFallback}`;
|
||||||
|
}
|
||||||
|
|
||||||
async load() {
|
async load() {
|
||||||
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
const policies = await this.policyService.getAll(PolicyType.DisableSend);
|
||||||
const organizations = await this.userService.getAllOrganizations();
|
const organizations = await this.userService.getAllOrganizations();
|
||||||
@@ -138,11 +154,28 @@ export class AddEditComponent implements OnInit {
|
|||||||
this.hasPassword = this.send.password != null && this.send.password.trim() !== '';
|
this.hasPassword = this.send.password != null && this.send.password.trim() !== '';
|
||||||
|
|
||||||
// Parse dates
|
// Parse dates
|
||||||
this.deletionDate = this.dateToString(this.send.deletionDate);
|
if (!this.isDateTimeLocalSupported) {
|
||||||
this.expirationDate = this.dateToString(this.send.expirationDate);
|
const deletionDateParts = this.dateToSplitString(this.send.deletionDate);
|
||||||
|
this.deletionDateFallback = deletionDateParts[0];
|
||||||
|
this.deletionTimeFallback = deletionDateParts[1];
|
||||||
|
const expirationDateParts = this.dateToSplitString(this.send.expirationDate);
|
||||||
|
this.expirationDateFallback = expirationDateParts[0];
|
||||||
|
this.expirationTimeFallback = expirationDateParts[1];
|
||||||
|
} else {
|
||||||
|
this.deletionDate = this.dateToString(this.send.deletionDate);
|
||||||
|
this.expirationDate = this.dateToString(this.send.expirationDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async submit(): Promise<boolean> {
|
async submit(): Promise<boolean> {
|
||||||
|
if (!this.isDateTimeLocalSupported && this.expirationDateTimeFallback !== null) {
|
||||||
|
this.expirationDate = this.expirationDateTimeFallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isDateTimeLocalSupported && this.deletionDateTimeFallback !== null) {
|
||||||
|
this.deletionDate = this.deletionDateTimeFallback;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.disableSend) {
|
if (this.disableSend) {
|
||||||
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
this.platformUtilsService.showToast('error', this.i18nService.t('errorOccurred'),
|
||||||
this.i18nService.t('sendDisabledWarning'));
|
this.i18nService.t('sendDisabledWarning'));
|
||||||
@@ -284,6 +317,14 @@ export class AddEditComponent implements OnInit {
|
|||||||
return d == null ? null : this.datePipe.transform(d, 'yyyy-MM-ddTHH:mm');
|
return d == null ? null : this.datePipe.transform(d, 'yyyy-MM-ddTHH:mm');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected dateToSplitString(d: Date) {
|
||||||
|
if (d != null) {
|
||||||
|
const date = this.datePipe.transform(d, 'yyyy-MM-dd');
|
||||||
|
const time = this.datePipe.transform(d, 'HH:mm');
|
||||||
|
return [date, time];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected togglePasswordVisible() {
|
protected togglePasswordVisible() {
|
||||||
this.showPassword = !this.showPassword;
|
this.showPassword = !this.showPassword;
|
||||||
document.getElementById('password').focus();
|
document.getElementById('password').focus();
|
||||||
|
|||||||
Reference in New Issue
Block a user