From 0682269e34fdbb3bf6e0a5773b026246b48521ed Mon Sep 17 00:00:00 2001 From: Addison Beck Date: Mon, 19 Jul 2021 09:56:31 -0400 Subject: [PATCH] Resolved Safari Date/Time Issues In Send (#992) * cleaned up date and time logic for Send * updated jslib * set up change detection for initial form values on data swap --- jslib | 2 +- src/app/app.module.ts | 15 ++++++---- src/app/send/add-edit.component.html | 36 +++-------------------- src/app/send/add-edit.component.ts | 2 -- src/app/send/efflux-dates.component.html | 35 ++++++++++++++++++++++ src/app/send/efflux-dates.component.ts | 37 ++++++++++++++++++++++++ 6 files changed, 86 insertions(+), 41 deletions(-) create mode 100644 src/app/send/efflux-dates.component.html create mode 100644 src/app/send/efflux-dates.component.ts diff --git a/jslib b/jslib index 119699b8..58be5796 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 119699b82c26296cdd518c0c66e0cd3d61586309 +Subproject commit 58be5796b0c2b19aacf52d4a1c179aeb80924443 diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 2a4616e2..741f0564 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -9,7 +9,7 @@ import { ServicesModule } from './services.module'; import { DragDropModule } from '@angular/cdk/drag-drop'; import { DatePipe } from '@angular/common'; import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; @@ -61,6 +61,7 @@ import { VaultComponent } from './vault/vault.component'; import { ViewComponent } from './vault/view.component'; import { AddEditComponent as SendAddEditComponent } from './send/add-edit.component'; +import { EffluxDatesComponent as SendEffluxDatesComponent } from './send/efflux-dates.component'; import { SendComponent } from './send/send.component'; import { NavComponent } from './layout/nav.component'; @@ -158,14 +159,15 @@ registerLocaleData(localeZhTw, 'zh-TW'); @NgModule({ imports: [ - BrowserModule, - BrowserAnimationsModule, - FormsModule, AppRoutingModule, + BrowserAnimationsModule, + BrowserModule, + DragDropModule, + FormsModule, + InfiniteScrollModule, + ReactiveFormsModule, ServicesModule, ToasterModule.forRoot(), - InfiniteScrollModule, - DragDropModule, ], declarations: [ A11yTitleDirective, @@ -200,6 +202,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); SearchCiphersPipe, SelectCopyDirective, SendAddEditComponent, + SendEffluxDatesComponent, SendComponent, SetPasswordComponent, SettingsComponent, diff --git a/src/app/send/add-edit.component.html b/src/app/send/add-edit.component.html index 623b2312..9b3d00b7 100644 --- a/src/app/send/add-edit.component.html +++ b/src/app/send/add-edit.component.html @@ -66,38 +66,10 @@
-
-
-
- - - {{'deletionDateDesc' | i18n}} -
-
- - - {{'deletionDateDesc' | i18n}} -
-
- - - {{'expirationDateDesc' | i18n}} -
-
- - - {{'expirationDateDesc' | i18n}} -
-
-
+ +
diff --git a/src/app/send/add-edit.component.ts b/src/app/send/add-edit.component.ts index b8397bcd..3bbc4663 100644 --- a/src/app/send/add-edit.component.ts +++ b/src/app/send/add-edit.component.ts @@ -30,8 +30,6 @@ export class AddEditComponent extends BaseAddEditComponent { const send = await this.loadSend(); this.send = await send.decrypt(); this.hasPassword = this.send.password != null && this.send.password.trim() !== ''; - this.deletionDate = this.dateToString(this.send.deletionDate); - this.expirationDate = this.dateToString(this.send.expirationDate); } cancel() { diff --git a/src/app/send/efflux-dates.component.html b/src/app/send/efflux-dates.component.html new file mode 100644 index 00000000..a0f8218a --- /dev/null +++ b/src/app/send/efflux-dates.component.html @@ -0,0 +1,35 @@ + +
+
+
+ + + {{'deletionDateDesc' | i18n}} +
+
+ + + {{'deletionDateDesc' | i18n}} +
+
+ + + {{'expirationDateDesc' | i18n}} +
+
+ + + {{'expirationDateDesc' | i18n}} +
+
+
+
+ diff --git a/src/app/send/efflux-dates.component.ts b/src/app/send/efflux-dates.component.ts new file mode 100644 index 00000000..272c4603 --- /dev/null +++ b/src/app/send/efflux-dates.component.ts @@ -0,0 +1,37 @@ +import { DatePipe } from '@angular/common'; + +import { + Component, + OnChanges, + SimpleChanges, +} from '@angular/core'; + +import { ControlContainer, NgForm } from '@angular/forms'; + +import { I18nService } from 'jslib-common/abstractions/i18n.service'; +import { PlatformUtilsService } from 'jslib-common/abstractions/platformUtils.service'; + +import { EffluxDatesComponent as BaseEffluxDatesComponent } from 'jslib-angular/components/send/efflux-dates.component'; + +@Component({ + selector: 'app-send-efflux-dates', + templateUrl: 'efflux-dates.component.html', + viewProviders: [{ provide: ControlContainer, useExisting: NgForm }], +}) +export class EffluxDatesComponent extends BaseEffluxDatesComponent implements OnChanges { + constructor(protected i18nService: I18nService, protected platformUtilsService: PlatformUtilsService, + protected datePipe: DatePipe) { + super(i18nService, platformUtilsService, datePipe); + } + + // We reuse the same form on desktop and just swap content, so need to watch these to maintin proper values. + ngOnChanges() { + if (this.initialExpirationDate) { + this.defaultExpirationDateTime.setValue( + this.datePipe.transform(new Date(this.initialExpirationDate), 'yyyy-MM-ddTHH:mm')); + } else { + this.defaultExpirationDateTime.setValue(null); + } + this.defaultDeletionDateTime.setValue(this.datePipe.transform(new Date(this.initialDeletionDate), 'yyyy-MM-ddTHH:mm')); + } +}