Skip to content

Commit

Permalink
Merge pull request #3965 from tdonohue/port_2827_to_7x
Browse files Browse the repository at this point in the history
[Port dspace-7_x] use translation service to determine placeholder values of date picker
  • Loading branch information
tdonohue authored Feb 6, 2025
2 parents 9506412 + 7584b9e commit 7fab963
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
[(ngModel)]="initialYear"
[value]="year"
[invalid]="showErrorMessages"
[placeholder]='yearPlaceholder'
[placeholder]="'form.date-picker.placeholder.year' | translate"
(blur)="onBlur($event)"
(change)="onChange($event)"
(focus)="onFocus($event)"
Expand All @@ -29,7 +29,7 @@
[size]="6"
[(ngModel)]="initialMonth"
[value]="month"
[placeholder]="monthPlaceholder"
[placeholder]="'form.date-picker.placeholder.month' | translate"
[disabled]="!year || model.disabled"
(blur)="onBlur($event)"
(change)="onChange($event)"
Expand All @@ -45,7 +45,7 @@
[size]="2"
[(ngModel)]="initialDay"
[value]="day"
[placeholder]="dayPlaceholder"
[placeholder]="'form.date-picker.placeholder.day' | translate"
[disabled]="!month || model.disabled"
(blur)="onBlur($event)"
(change)="onChange($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
mockDynamicFormValidationService
} from '../../../../../testing/dynamic-form-mock-services';
import { By } from '@angular/platform-browser';
import { TranslateModule } from '@ngx-translate/core';


export const DATE_TEST_GROUP = new UntypedFormGroup({
Expand Down Expand Up @@ -51,7 +52,8 @@ describe('DsDatePickerComponent test suite', () => {

TestBed.configureTestingModule({
imports: [
NgbModule
NgbModule,
TranslateModule.forRoot(),
],
declarations: [
DsDatePickerComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@ng-dynamic-forms/core';
import { DOCUMENT } from '@angular/common';
import isEqual from 'lodash/isEqual';
import { TranslateService } from '@ngx-translate/core';


export type DatePickerFieldType = '_year' | '_month' | '_day';
Expand Down Expand Up @@ -48,17 +49,14 @@ export class DsDatePickerComponent extends DynamicFormControlComponent implement
minDay = 1;
maxDay = 31;

yearPlaceholder = 'year';
monthPlaceholder = 'month';
dayPlaceholder = 'day';

disabledMonth = true;
disabledDay = true;

private readonly fields: DatePickerFieldType[] = ['_year', '_month', '_day'];

constructor(protected layoutService: DynamicFormLayoutService,
protected validationService: DynamicFormValidationService,
protected translateService: TranslateService,
private renderer: Renderer2,
@Inject(DOCUMENT) private _document: Document
) {
Expand Down
10 changes: 10 additions & 0 deletions src/assets/i18n/de.json5
Original file line number Diff line number Diff line change
Expand Up @@ -5553,4 +5553,14 @@

// "workspace-item.delete.notification.error.content": "The workspace item could not be deleted",
"workspace-item.delete.notification.error.content": "Das Workspace-Item konnte nicht gelöscht werden.",


// "form.date-picker.placeholder.year": "Year",
"form.date-picker.placeholder.year": "Jahr",

// "form.date-picker.placeholder.month": "Month",
"form.date-picker.placeholder.month": "Monat",

// "form.date-picker.placeholder.day": "Day",
"form.date-picker.placeholder.day": "Tag",
}
6 changes: 6 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,12 @@

"form.number-picker.increment": "Increment {{field}}",

"form.date-picker.placeholder.year": "Year",

"form.date-picker.placeholder.month": "Month",

"form.date-picker.placeholder.day": "Day",

"grant-deny-request-copy.deny": "Don't send copy",

"grant-deny-request-copy.email.back": "Back",
Expand Down

0 comments on commit 7fab963

Please sign in to comment.