Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add pattern and inputmode to text-field component

Oliver Günther5d8e93f06237
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
index ca37ada1780..8eda9f3598b 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.html
@@ -43,6 +43,8 @@
(ngModelChange)="startDateChanged$.next($event)"
[disabled]="!isSchedulable"
[showClearButton]="currentlyActivatedDateField === 'start'"
+ [pattern]="datePattern"
+ inputmode="numeric"
(focusin)="setCurrentActivatedField('start')"
></spot-text-field>
<button
@@ -69,6 +71,8 @@
(ngModelChange)="endDateChanged$.next($event)"
[disabled]="!isSchedulable"
[showClearButton]="currentlyActivatedDateField === 'end'"
+ [pattern]="datePattern"
+ inputmode="numeric"
(focusin)="setCurrentActivatedField('end')"
></spot-text-field>
<button
@@ -94,6 +98,8 @@
[ngClass]="{'op-datepicker-modal--date-field_current' : showFieldAsActive('duration')}"
[ngModel]="durationFocused ? duration : displayedDuration"
[showClearButton]="durationFocused"
+ pattern="\d*"
+ inputmode="numeric"
(ngModelChange)="durationChanges$.next($event)"
[disabled]="!isSchedulable"
(focusin)="handleDurationFocusIn()"
diff --git a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
index 4c4bbbb78a8..c3028de2924 100644
--- a/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/multi-date-modal/multi-date.modal.ts
@@ -151,6 +151,8 @@ export class MultiDateModalComponent extends OpModalComponent implements AfterVi
htmlId = '';
+ datePattern = '[0-9]{4}-[0-9]{2}-[0-9]{2}';
+
dates:{ [key in DateKeys]:string|null } = {
start: null,
end: null,
diff --git a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.html b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.html
index b5bbe54f05a..4442a33715b 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.html
+++ b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.html
@@ -38,6 +38,8 @@
[(ngModel)]="date"
(ngModelChange)="dateChangedManually$.next()"
[showClearButton]="true"
+ [pattern]="datePattern"
+ inputmode="numeric"
></spot-text-field>
<button
slot="action"
diff --git a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
index 5c3e46b9b1e..449072c18cc 100644
--- a/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
+++ b/frontend/src/app/shared/components/datepicker/single-date-modal/single-date.modal.ts
@@ -114,6 +114,8 @@ export class SingleDateModalComponent extends OpModalComponent implements AfterV
htmlId = '';
+ datePattern = '[0-9]{4}-[0-9]{2}-[0-9]{2}';
+
date:string|null = null;
dateChangedManually$ = new Subject<void>();
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.html b/frontend/src/app/spot/components/text-field/text-field.component.html
index 982f06fc115..209ba77c5cd 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.html
+++ b/frontend/src/app/spot/components/text-field/text-field.component.html
@@ -2,6 +2,8 @@
<input
class="spot-text-field--input"
[attr.name]="name"
+ [attr.pattern]="pattern"
+ [attr.inputmode]="inputmode"
[disabled]="disabled"
[placeholder]="placeholder"
[ngModel]="value"
diff --git a/frontend/src/app/spot/components/text-field/text-field.component.ts b/frontend/src/app/spot/components/text-field/text-field.component.ts
index 3ae31666c4b..08c1f7d874b 100644
--- a/frontend/src/app/spot/components/text-field/text-field.component.ts
+++ b/frontend/src/app/spot/components/text-field/text-field.component.ts
@@ -67,6 +67,10 @@ export class SpotTextFieldComponent implements ControlValueAccessor {
*/
@Input() public value = '';
+ @Input() public pattern:string|undefined;
+
+ @Input() public inputmode:string = 'text';
+
valueChanged(value:string):void {
this.writeValue(value);
this.onChange(value);