Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(date input): create new component for date input (DSP-94) #298

Merged
merged 65 commits into from Jun 9, 2021

Conversation

tobiasschweizer
Copy link
Contributor

@tobiasschweizer tobiasschweizer commented May 26, 2021

resolves DSP-94

TODO:

  • add @Input() valueRequiredValidator = true; to DateInputTextComponent
  • add @Input() valueRequiredValidator = true; to DateEditComponent
  • unsubscribe from valueChanges on component destruction (DateInputTextComponent and DateEditComponent)
  • disable era for Islamic dates
  • set day from existing date
  • move redundant set day logic in service
  • fix CSS
  • move createJDNCalendarDateFromKnoraDate to value service

following PR:

@tobiasschweizer tobiasschweizer self-assigned this May 26, 2021
Tobias Schweizer added 26 commits May 27, 2021 08:53
@tobiasschweizer
Copy link
Contributor Author

@gautschr To test this in the playground, follow these steps:

Copy link
Contributor

@gautschr gautschr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works perfectly!


// recalculate days of month when era changes
const eraChangesSubscription = this.eraControl.valueChanges.subscribe(
data => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need data here for the future or can it simply be () (also for the year and month subscriptions)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 1f5f699


.date-form-grid {
display: grid;
grid-template-columns: 49% 49%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may be trying to do this here but I would align the start and end input components side by side. Also the form error for the year overlaps the month text. It might also be nice to have "Start" and "End" above the inputs respectively if it is a period.

Screen Shot 2021-06-09 at 10 40 12

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I thought myself that side by side would be better

I'll do that in an subsequent PR.

@@ -0,0 +1,39 @@
<div [formGroup]="form">

<div class="era-radio">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd argue that this should actually be hidden in the case of an Islamic date instead of just disabled. I think UIs shouldn't show something that isn't relevant to the user regardless of whether or not they can interact with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

surely worth thinking about it ...

</mat-form-field>
<mat-form-field>
<mat-label>Month</mat-label>
<mat-select class="month" [formControlName]="'month'" (selectionChange)="_handleInput()">
Copy link
Contributor

@mdelez mdelez Jun 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a huge fan of this dropdown for months but I know why you did it. Do you think it would be possible to open a calendar that is locked to the month view for this instead? Same for the days but the calendar would be locked to the days. dismissed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand what you mean. Could we briefly talk about this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There would be more attractive ways to solve this in the UI but the main purpose of this PR was to provide a solution that works for dates of arbitrary precision and BCE and CE dates. As soon as the MatDatePicker supports this (if ever) it could be used instead.


// TODO: find better way to detect changes
const startValueSubscription = this.startDate.valueChanges.subscribe(
data => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is data needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 1f5f699


// TODO: find better way to detect changes
const endValueSubscription = this.endDate.valueChanges.subscribe(
data => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is data needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 1f5f699


this._subscriptions.push(eraChangesSubscription);

// TODO: find better way to detect changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this TODO be handled in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll consider this in a subsequent PR.


this._subscriptions.push(startValueSubscription);

// TODO: find better way to detect changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this TODO be handled in this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll consider this in a subsequent PR.

@@ -45,8 +45,6 @@ export class DateValueComponent extends BaseValueComponent implements OnInit, On

matcher = new ValueErrorStateMatcher();

dateEditable = true;

constructor(@Inject(FormBuilder) private _fb: FormBuilder,
private _valueService: ValueService) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the ValueService here anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 7a2d826

@mdelez mdelez self-requested a review June 9, 2021 10:31
@tobiasschweizer tobiasschweizer merged commit d23e844 into main Jun 9, 2021
@tobiasschweizer tobiasschweizer deleted the wip/dsp-94-date-input branch June 9, 2021 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request user requirement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants