From 9771d756b6a62498fe357044dffccfd4c2c67637 Mon Sep 17 00:00:00 2001 From: Mark Cooper Date: Fri, 26 Aug 2022 17:58:06 -0700 Subject: [PATCH] Enable / disable spellcheck for textarea inputs via config --- config/config.example.yml | 2 ++ .../group-registry/group-form/group-form.component.ts | 2 ++ .../bitstream-formats/format-form/format-form.component.ts | 2 ++ .../collection-form/collection-form.models.ts | 6 ++++++ .../community-form/community-form.component.ts | 5 +++++ .../shared/form/builder/parsers/textarea-field-parser.ts | 2 ++ src/config/default-app-config.ts | 1 + src/config/form-config.interfaces.ts | 1 + src/environments/environment.test.ts | 1 + 9 files changed, 22 insertions(+) diff --git a/config/config.example.yml b/config/config.example.yml index 1e55dfda5ff..beb0f7a0c94 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -55,6 +55,8 @@ auth: # Form settings form: + # Sets the spellcheck textarea attribute value + spellCheck: true # NOTE: Map server-side validators to comparative Angular form validators validatorMap: required: required diff --git a/src/app/access-control/group-registry/group-form/group-form.component.ts b/src/app/access-control/group-registry/group-form/group-form.component.ts index b0178f12948..584b28ba1e6 100644 --- a/src/app/access-control/group-registry/group-form/group-form.component.ts +++ b/src/app/access-control/group-registry/group-form/group-form.component.ts @@ -46,6 +46,7 @@ import { followLink } from '../../../shared/utils/follow-link-config.model'; import { NoContent } from '../../../core/shared/NoContent.model'; import { Operation } from 'fast-json-patch'; import { ValidateGroupExists } from './validators/group-exists.validator'; +import { environment } from '../../../../environments/environment'; @Component({ selector: 'ds-group-form', @@ -194,6 +195,7 @@ export class GroupFormComponent implements OnInit, OnDestroy { label: groupDescription, name: 'groupDescription', required: false, + spellCheck: environment.form.spellCheck, }); this.formModel = [ this.groupName, diff --git a/src/app/admin/admin-registries/bitstream-formats/format-form/format-form.component.ts b/src/app/admin/admin-registries/bitstream-formats/format-form/format-form.component.ts index 161cfa7ecff..142f6fb83d5 100644 --- a/src/app/admin/admin-registries/bitstream-formats/format-form/format-form.component.ts +++ b/src/app/admin/admin-registries/bitstream-formats/format-form/format-form.component.ts @@ -15,6 +15,7 @@ import { Router } from '@angular/router'; import { hasValue, isEmpty } from '../../../../shared/empty.util'; import { TranslateService } from '@ngx-translate/core'; import { getBitstreamFormatsModuleRoute } from '../../admin-registries-routing-paths'; +import { environment } from '../../../../../environments/environment'; /** * The component responsible for rendering the form to create/edit a bitstream format @@ -90,6 +91,7 @@ export class FormatFormComponent implements OnInit { name: 'description', label: 'admin.registries.bitstream-formats.edit.description.label', hint: 'admin.registries.bitstream-formats.edit.description.hint', + spellCheck: environment.form.spellCheck, }), new DynamicSelectModel({ diff --git a/src/app/collection-page/collection-form/collection-form.models.ts b/src/app/collection-page/collection-form/collection-form.models.ts index 37e9d8a9a0e..1a009d95a10 100644 --- a/src/app/collection-page/collection-form/collection-form.models.ts +++ b/src/app/collection-page/collection-form/collection-form.models.ts @@ -1,5 +1,6 @@ import { DynamicFormControlModel, DynamicInputModel, DynamicTextAreaModel } from '@ng-dynamic-forms/core'; import { DynamicSelectModelConfig } from '@ng-dynamic-forms/core/lib/model/select/dynamic-select.model'; +import { environment } from '../../../environments/environment'; export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig = { id: 'entityType', @@ -26,21 +27,26 @@ export const collectionFormModels: DynamicFormControlModel[] = [ new DynamicTextAreaModel({ id: 'description', name: 'dc.description', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'abstract', name: 'dc.description.abstract', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'rights', name: 'dc.rights', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'tableofcontents', name: 'dc.description.tableofcontents', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'license', name: 'dc.rights.license', + spellCheck: environment.form.spellCheck, }) ]; diff --git a/src/app/community-page/community-form/community-form.component.ts b/src/app/community-page/community-form/community-form.component.ts index a3730fd4182..c6dd1147c34 100644 --- a/src/app/community-page/community-form/community-form.component.ts +++ b/src/app/community-page/community-form/community-form.component.ts @@ -13,6 +13,7 @@ import { CommunityDataService } from '../../core/data/community-data.service'; import { AuthService } from '../../core/auth/auth.service'; import { RequestService } from '../../core/data/request.service'; import { ObjectCacheService } from '../../core/cache/object-cache.service'; +import { environment } from '../../../environments/environment'; /** * Form used for creating and editing communities @@ -52,18 +53,22 @@ export class CommunityFormComponent extends ComColFormComponent { new DynamicTextAreaModel({ id: 'description', name: 'dc.description', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'abstract', name: 'dc.description.abstract', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'rights', name: 'dc.rights', + spellCheck: environment.form.spellCheck, }), new DynamicTextAreaModel({ id: 'tableofcontents', name: 'dc.description.tableofcontents', + spellCheck: environment.form.spellCheck, }), ]; diff --git a/src/app/shared/form/builder/parsers/textarea-field-parser.ts b/src/app/shared/form/builder/parsers/textarea-field-parser.ts index 740e94721f1..548ce567c3e 100644 --- a/src/app/shared/form/builder/parsers/textarea-field-parser.ts +++ b/src/app/shared/form/builder/parsers/textarea-field-parser.ts @@ -5,6 +5,7 @@ import { DsDynamicTextAreaModel, DsDynamicTextAreaModelConfig } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model'; +import { environment } from '../../../../../environments/environment'; export class TextareaFieldParser extends FieldParser { @@ -20,6 +21,7 @@ export class TextareaFieldParser extends FieldParser { }; textAreaModelConfig.rows = 10; + textAreaModelConfig.spellCheck = environment.form.spellCheck; this.setValues(textAreaModelConfig, fieldValue); const textAreaModel = new DsDynamicTextAreaModel(textAreaModelConfig, layout); diff --git a/src/config/default-app-config.ts b/src/config/default-app-config.ts index a6949fabe24..bc8ff14e03c 100644 --- a/src/config/default-app-config.ts +++ b/src/config/default-app-config.ts @@ -93,6 +93,7 @@ export class DefaultAppConfig implements AppConfig { // Form settings form: FormConfig = { + spellCheck: true, // NOTE: Map server-side validators to comparative Angular form validators validatorMap: { required: 'required', diff --git a/src/config/form-config.interfaces.ts b/src/config/form-config.interfaces.ts index e13fdc1c605..50769c2d2fe 100644 --- a/src/config/form-config.interfaces.ts +++ b/src/config/form-config.interfaces.ts @@ -5,5 +5,6 @@ export interface ValidatorMap { } export interface FormConfig extends Config { + spellCheck: boolean; validatorMap: ValidatorMap; } diff --git a/src/environments/environment.test.ts b/src/environments/environment.test.ts index ec49ff60091..19eec26a140 100644 --- a/src/environments/environment.test.ts +++ b/src/environments/environment.test.ts @@ -78,6 +78,7 @@ export const environment: BuildConfig = { // Form settings form: { + spellCheck: true, // NOTE: Map server-side validators to comparative Angular form validators validatorMap: { required: 'required',