Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/config.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ submission:
- value: default
style: text-muted
icon: fa-circle-xmark
# Whether to show submission form errors 'onload' or 'onblur'
showErrorStrategy: onblur

# Fallback language in which the UI will be rendered if the user's browser language is not an active language
fallbackLanguage: en
Expand Down
19 changes: 19 additions & 0 deletions src/app/submission/form/submission-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
OnDestroy,
SimpleChanges,
} from '@angular/core';
import { AbstractControl } from '@angular/forms';
import { AuthService } from '@dspace/core/auth/auth.service';
import { SubmissionDefinitionsModel } from '@dspace/core/config/models/config-submission-definitions.model';
import { SubmissionSectionModel } from '@dspace/core/config/models/config-submission-section.model';
Expand All @@ -24,6 +25,11 @@ import {
isNotEmpty,
isNotUndefined,
} from '@dspace/shared/utils/empty.util';
import {
DYNAMIC_ERROR_MESSAGES_MATCHER,
DynamicFormControlModel,
DynamicFormValidationService,
} from '@ng-dynamic-forms/core';
import { TranslatePipe } from '@ngx-translate/core';
import isEqual from 'lodash/isEqual';
import {
Expand All @@ -38,6 +44,7 @@ import {
switchMap,
} from 'rxjs/operators';

import { environment } from '../../../environments/environment';
import { ThemedLoadingComponent } from '../../shared/loading/themed-loading.component';
import { UploaderOptions } from '../../shared/upload/uploader/uploader-options.model';
import { SubmissionObjectEntry } from '../objects/submission-objects.reducer';
Expand Down Expand Up @@ -67,6 +74,18 @@ import { ThemedSubmissionUploadFilesComponent } from './submission-upload-files/
ThemedSubmissionUploadFilesComponent,
TranslatePipe,
],
providers: environment.submission.showErrorStrategy === 'onload' ? [
// Always show validation errors, even if input hasn't been
// blurred yet
DynamicFormValidationService,
{
provide: DYNAMIC_ERROR_MESSAGES_MATCHER,
useValue: (
_control: AbstractControl,
_model: DynamicFormControlModel,
hasFocus: boolean) => !hasFocus,
},
] : [],
})
export class SubmissionFormComponent implements OnChanges, OnDestroy {

Expand Down
1 change: 1 addition & 0 deletions src/config/default-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ export class DefaultAppConfig implements AppConfig {
],
},
},
showErrorStrategy: 'onblur',
};

// Fallback language in which the UI will be rendered if the user's browser language is not an active language
Expand Down
3 changes: 3 additions & 0 deletions src/config/submission-config.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ export interface ConfidenceIconConfig extends Config {
icon: string;
}

type ShowErrorStrategy = 'onload' | 'onblur';

export interface SubmissionConfig extends Config {
autosave: AutosaveConfig;
duplicateDetection: DuplicateDetectionConfig;
typeBind: TypeBindConfig;
icons: IconsConfig;
showErrorStrategy: ShowErrorStrategy;
}
1 change: 1 addition & 0 deletions src/environments/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export const environment: BuildConfig = {
],
},
},
showErrorStrategy: 'onblur',
},

// NOTE: will log all redux actions and transfers in console
Expand Down