Enable / disable spellcheck for textarea inputs via config

This commit is contained in:
Mark Cooper
2022-08-26 17:58:06 -07:00
parent ffc5ecb100
commit 9771d756b6
9 changed files with 22 additions and 0 deletions

View File

@@ -55,6 +55,8 @@ auth:
# Form settings # Form settings
form: form:
# Sets the spellcheck textarea attribute value
spellCheck: true
# NOTE: Map server-side validators to comparative Angular form validators # NOTE: Map server-side validators to comparative Angular form validators
validatorMap: validatorMap:
required: required required: required

View File

@@ -46,6 +46,7 @@ import { followLink } from '../../../shared/utils/follow-link-config.model';
import { NoContent } from '../../../core/shared/NoContent.model'; import { NoContent } from '../../../core/shared/NoContent.model';
import { Operation } from 'fast-json-patch'; import { Operation } from 'fast-json-patch';
import { ValidateGroupExists } from './validators/group-exists.validator'; import { ValidateGroupExists } from './validators/group-exists.validator';
import { environment } from '../../../../environments/environment';
@Component({ @Component({
selector: 'ds-group-form', selector: 'ds-group-form',
@@ -194,6 +195,7 @@ export class GroupFormComponent implements OnInit, OnDestroy {
label: groupDescription, label: groupDescription,
name: 'groupDescription', name: 'groupDescription',
required: false, required: false,
spellCheck: environment.form.spellCheck,
}); });
this.formModel = [ this.formModel = [
this.groupName, this.groupName,

View File

@@ -15,6 +15,7 @@ import { Router } from '@angular/router';
import { hasValue, isEmpty } from '../../../../shared/empty.util'; import { hasValue, isEmpty } from '../../../../shared/empty.util';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { getBitstreamFormatsModuleRoute } from '../../admin-registries-routing-paths'; 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 * The component responsible for rendering the form to create/edit a bitstream format
@@ -90,6 +91,7 @@ export class FormatFormComponent implements OnInit {
name: 'description', name: 'description',
label: 'admin.registries.bitstream-formats.edit.description.label', label: 'admin.registries.bitstream-formats.edit.description.label',
hint: 'admin.registries.bitstream-formats.edit.description.hint', hint: 'admin.registries.bitstream-formats.edit.description.hint',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicSelectModel({ new DynamicSelectModel({

View File

@@ -1,5 +1,6 @@
import { DynamicFormControlModel, DynamicInputModel, DynamicTextAreaModel } from '@ng-dynamic-forms/core'; import { DynamicFormControlModel, DynamicInputModel, DynamicTextAreaModel } from '@ng-dynamic-forms/core';
import { DynamicSelectModelConfig } from '@ng-dynamic-forms/core/lib/model/select/dynamic-select.model'; import { DynamicSelectModelConfig } from '@ng-dynamic-forms/core/lib/model/select/dynamic-select.model';
import { environment } from '../../../environments/environment';
export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig<string> = { export const collectionFormEntityTypeSelectionConfig: DynamicSelectModelConfig<string> = {
id: 'entityType', id: 'entityType',
@@ -26,21 +27,26 @@ export const collectionFormModels: DynamicFormControlModel[] = [
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'description', id: 'description',
name: 'dc.description', name: 'dc.description',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'abstract', id: 'abstract',
name: 'dc.description.abstract', name: 'dc.description.abstract',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'rights', id: 'rights',
name: 'dc.rights', name: 'dc.rights',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'tableofcontents', id: 'tableofcontents',
name: 'dc.description.tableofcontents', name: 'dc.description.tableofcontents',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'license', id: 'license',
name: 'dc.rights.license', name: 'dc.rights.license',
spellCheck: environment.form.spellCheck,
}) })
]; ];

View File

@@ -13,6 +13,7 @@ import { CommunityDataService } from '../../core/data/community-data.service';
import { AuthService } from '../../core/auth/auth.service'; import { AuthService } from '../../core/auth/auth.service';
import { RequestService } from '../../core/data/request.service'; import { RequestService } from '../../core/data/request.service';
import { ObjectCacheService } from '../../core/cache/object-cache.service'; import { ObjectCacheService } from '../../core/cache/object-cache.service';
import { environment } from '../../../environments/environment';
/** /**
* Form used for creating and editing communities * Form used for creating and editing communities
@@ -52,18 +53,22 @@ export class CommunityFormComponent extends ComColFormComponent<Community> {
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'description', id: 'description',
name: 'dc.description', name: 'dc.description',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'abstract', id: 'abstract',
name: 'dc.description.abstract', name: 'dc.description.abstract',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'rights', id: 'rights',
name: 'dc.rights', name: 'dc.rights',
spellCheck: environment.form.spellCheck,
}), }),
new DynamicTextAreaModel({ new DynamicTextAreaModel({
id: 'tableofcontents', id: 'tableofcontents',
name: 'dc.description.tableofcontents', name: 'dc.description.tableofcontents',
spellCheck: environment.form.spellCheck,
}), }),
]; ];

View File

@@ -5,6 +5,7 @@ import {
DsDynamicTextAreaModel, DsDynamicTextAreaModel,
DsDynamicTextAreaModelConfig DsDynamicTextAreaModelConfig
} from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model'; } from '../ds-dynamic-form-ui/models/ds-dynamic-textarea.model';
import { environment } from '../../../../../environments/environment';
export class TextareaFieldParser extends FieldParser { export class TextareaFieldParser extends FieldParser {
@@ -20,6 +21,7 @@ export class TextareaFieldParser extends FieldParser {
}; };
textAreaModelConfig.rows = 10; textAreaModelConfig.rows = 10;
textAreaModelConfig.spellCheck = environment.form.spellCheck;
this.setValues(textAreaModelConfig, fieldValue); this.setValues(textAreaModelConfig, fieldValue);
const textAreaModel = new DsDynamicTextAreaModel(textAreaModelConfig, layout); const textAreaModel = new DsDynamicTextAreaModel(textAreaModelConfig, layout);

View File

@@ -93,6 +93,7 @@ export class DefaultAppConfig implements AppConfig {
// Form settings // Form settings
form: FormConfig = { form: FormConfig = {
spellCheck: true,
// NOTE: Map server-side validators to comparative Angular form validators // NOTE: Map server-side validators to comparative Angular form validators
validatorMap: { validatorMap: {
required: 'required', required: 'required',

View File

@@ -5,5 +5,6 @@ export interface ValidatorMap {
} }
export interface FormConfig extends Config { export interface FormConfig extends Config {
spellCheck: boolean;
validatorMap: ValidatorMap; validatorMap: ValidatorMap;
} }

View File

@@ -78,6 +78,7 @@ export const environment: BuildConfig = {
// Form settings // Form settings
form: { form: {
spellCheck: true,
// NOTE: Map server-side validators to comparative Angular form validators // NOTE: Map server-side validators to comparative Angular form validators
validatorMap: { validatorMap: {
required: 'required', required: 'required',