@defra/forms-model 3.0.689 → 3.0.691

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,6 +64,12 @@ export const keyConfig = {
64
64
  displayName: 'Short description',
65
65
  getLabel: (pageNum, questionNum) => `Welsh short description - Page ${pageNum}, question ${questionNum}`
66
66
  },
67
+ [TranslationRowTypes.ErrorDescription]: {
68
+ jsonPrefix: 'components',
69
+ jsonSuffix: 'errorDescription',
70
+ displayName: 'Error description',
71
+ getLabel: (pageNum, questionNum) => `Welsh error description - Page ${pageNum}, question ${questionNum}`
72
+ },
67
73
  [TranslationRowTypes.InstructionText]: {
68
74
  jsonPrefix: 'components',
69
75
  jsonSuffix: 'instructionText',
@@ -1 +1 @@
1
- {"version":3,"file":"translations-config.js","names":["ComponentType","TranslationRowTypes","PageHeading","PageGuidance","RepeatTitle","QuestionText","QuestionHint","ShortDescription","ErrorDescription","ListItemText","ListItemHint","InstructionText","DeclarationBody","PaymentDescription","TEXTAREA_3_ROWS","TEXTAREA_5_ROWS","TEXTAREA_12_ROWS_WITH_MARKDOWN","LIST_ITEM_HINT","LIST_ITEM_WITH_HINT_FOLLOWING","keyConfig","jsonPrefix","jsonSuffix","displayName","getLabel","pageNum","questionNum","itemNum","IGNORE_FIELDS","Details","Html","InsetText","HiddenField","lookupTranslation","key","translations","drillDown","keyType","entity","resolveData","options","instructionText","hint","text","content","description","func","entityWithDynamicProperties"],"sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\n\n/**\n * @typedef {object} TranslationRow\n * @property {string} name - the key name\n * @property {string} [type] - type of text\n * @property {string | undefined} englishContent - English text\n * @property {string | undefined} welshContent - Welsh text\n * @property {number} [pageNum] - page number\n * @property {number} [questionNum] - question number\n * @property {number} [itemNum] - list item number\n * @property {string} [label] - label for field\n */\n\n/**\n * @typedef {{ text: string, href?: string }} ErrorDetailsItem\n * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails\n */\n\n/**\n * @template {object} [Schema=object]\n * @typedef {object} ValidationFailure\n * @property {ErrorDetails} formErrors - Formatted errors for error summary\n * @property {Schema} formValues - Form POST payload from Hapi request\n */\n\nexport const TranslationRowTypes = {\n PageHeading: 'PageHeading',\n PageGuidance: 'PageGuidance',\n RepeatTitle: 'RepeatTitle',\n QuestionText: 'QuestionText',\n QuestionHint: 'QuestionHint',\n ShortDescription: 'ShortDescription',\n ErrorDescription: 'ErrorDescription',\n ListItemText: 'ListItemText',\n ListItemHint: 'ListItemHint',\n InstructionText: 'InstructionText',\n DeclarationBody: 'DeclarationBody',\n PaymentDescription: 'PaymentDescription'\n}\n\nexport const TEXTAREA_3_ROWS = 'textarea3'\nexport const TEXTAREA_5_ROWS = 'textarea5'\nexport const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown'\nexport const LIST_ITEM_HINT = 'listitemhint'\nexport const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing'\n\n/** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */\nexport const keyConfig = {\n [TranslationRowTypes.QuestionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'title',\n displayName: 'Question text',\n getLabel: (pageNum, questionNum) =>\n `Welsh question text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.QuestionHint]: {\n jsonPrefix: 'components',\n jsonSuffix: 'hint',\n displayName: 'Hint',\n getLabel: (pageNum, questionNum) =>\n `Welsh hint - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ShortDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'shortDescription',\n displayName: 'Short description',\n getLabel: (pageNum, questionNum) =>\n `Welsh short description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.InstructionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'instructionText',\n displayName: 'Instruction text',\n getLabel: (pageNum, questionNum) =>\n `Welsh instruction text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.DeclarationBody]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Declaration body',\n getLabel: (pageNum, questionNum) =>\n `Welsh declaration body - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PaymentDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'paymentDescription',\n displayName: 'Payment description',\n getLabel: (pageNum, questionNum) =>\n `Welsh payment description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemText]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'text',\n displayName: 'Option',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemHint]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'hint',\n displayName: 'Option hint',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PageGuidance]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Guidance text',\n getLabel: (pageNum) => `Welsh guidance text (markdown) - page ${pageNum}`\n },\n [TranslationRowTypes.PageHeading]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'title',\n displayName: 'Page heading',\n getLabel: (pageNum) => `Welsh page heading - page ${pageNum}`\n },\n [TranslationRowTypes.RepeatTitle]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'repeatTitle',\n displayName: 'Repeat name',\n getLabel: (pageNum) => `Welsh repeat name - page ${pageNum}`\n }\n}\n\nexport const IGNORE_FIELDS = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.HiddenField\n]\n\n/**\n * Lookup a translation from a list of translation records.\n * @param {string} key - The translation key to look up.\n * @param {Record<string, string> | undefined} translations - The translation values to search.\n */\nexport function lookupTranslation(key, translations) {\n if (!translations) {\n return ''\n }\n return translations[key] ?? ''\n}\n\n/**\n * Resolve the underlying content for a translation row from an entity.\n * Involves using the appropriate child properties if necessary.\n * @param {string} keyType - The translation row type being resolved.\n * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.\n * @param {string} jsonSuffix - The property name to read from the entity.\n */\nexport function drillDown(keyType, entity, jsonSuffix) {\n /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */\n const resolveData = {\n [TranslationRowTypes.InstructionText]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.instructionText : '',\n [TranslationRowTypes.ListItemHint]: () =>\n // @ts-expect-error - dynamic property lookup\n 'hint' in entity ? entity.hint.text : '',\n [TranslationRowTypes.DeclarationBody]: () =>\n 'content' in entity ? entity.content : '',\n [TranslationRowTypes.PaymentDescription]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.description : ''\n }\n const func = resolveData[keyType]\n if (func) {\n return func(entity)\n } else {\n const entityWithDynamicProperties = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (entity)\n )\n if (typeof entity === 'object') {\n return jsonSuffix in entityWithDynamicProperties\n ? /** @type {string} */ (entityWithDynamicProperties[jsonSuffix])\n : ''\n }\n }\n return entity\n}\n\n/**\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { Item, Page } from '~/src/form/form-definition/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,kBAAkB;EACpCC,gBAAgB,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O,CAAC;EACjC,IAAIS,IAAI,EAAE;IACR,OAAOA,IAAI,CAACR,MAAM,CAAC;EACrB,CAAC,MAAM;IACL,MAAMS,2BAA2B,GAAG;IAClC,sBAAwBT,MACzB;IACD,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MAC9B,OAAOhB,UAAU,IAAIyB,2BAA2B,IAC5C,qBAAuBA,2BAA2B,CAACzB,UAAU,CAAC,IAC9D,EAAE;IACR;EACF;EACA,OAAOgB,MAAM;AACf;;AAEA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"translations-config.js","names":["ComponentType","TranslationRowTypes","PageHeading","PageGuidance","RepeatTitle","QuestionText","QuestionHint","ShortDescription","ErrorDescription","ListItemText","ListItemHint","InstructionText","DeclarationBody","PaymentDescription","TEXTAREA_3_ROWS","TEXTAREA_5_ROWS","TEXTAREA_12_ROWS_WITH_MARKDOWN","LIST_ITEM_HINT","LIST_ITEM_WITH_HINT_FOLLOWING","keyConfig","jsonPrefix","jsonSuffix","displayName","getLabel","pageNum","questionNum","itemNum","IGNORE_FIELDS","Details","Html","InsetText","HiddenField","lookupTranslation","key","translations","drillDown","keyType","entity","resolveData","options","instructionText","hint","text","content","description","func","entityWithDynamicProperties"],"sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\n\n/**\n * @typedef {object} TranslationRow\n * @property {string} name - the key name\n * @property {string} [type] - type of text\n * @property {string | undefined} englishContent - English text\n * @property {string | undefined} welshContent - Welsh text\n * @property {number} [pageNum] - page number\n * @property {number} [questionNum] - question number\n * @property {number} [itemNum] - list item number\n * @property {string} [label] - label for field\n */\n\n/**\n * @typedef {{ text: string, href?: string }} ErrorDetailsItem\n * @typedef {Record<string, ErrorDetailsItem>} ErrorDetails\n */\n\n/**\n * @template {object} [Schema=object]\n * @typedef {object} ValidationFailure\n * @property {ErrorDetails} formErrors - Formatted errors for error summary\n * @property {Schema} formValues - Form POST payload from Hapi request\n */\n\nexport const TranslationRowTypes = {\n PageHeading: 'PageHeading',\n PageGuidance: 'PageGuidance',\n RepeatTitle: 'RepeatTitle',\n QuestionText: 'QuestionText',\n QuestionHint: 'QuestionHint',\n ShortDescription: 'ShortDescription',\n ErrorDescription: 'ErrorDescription',\n ListItemText: 'ListItemText',\n ListItemHint: 'ListItemHint',\n InstructionText: 'InstructionText',\n DeclarationBody: 'DeclarationBody',\n PaymentDescription: 'PaymentDescription'\n}\n\nexport const TEXTAREA_3_ROWS = 'textarea3'\nexport const TEXTAREA_5_ROWS = 'textarea5'\nexport const TEXTAREA_12_ROWS_WITH_MARKDOWN = 'textarea12markdown'\nexport const LIST_ITEM_HINT = 'listitemhint'\nexport const LIST_ITEM_WITH_HINT_FOLLOWING = 'listoptionwithhintfollowing'\n\n/** @type {Record<string, { jsonPrefix: string, jsonSuffix: string, displayName: string, getLabel: (pageNum: number, questionNum?: number, itemNum?: number) => string }>} */\nexport const keyConfig = {\n [TranslationRowTypes.QuestionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'title',\n displayName: 'Question text',\n getLabel: (pageNum, questionNum) =>\n `Welsh question text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.QuestionHint]: {\n jsonPrefix: 'components',\n jsonSuffix: 'hint',\n displayName: 'Hint',\n getLabel: (pageNum, questionNum) =>\n `Welsh hint - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ShortDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'shortDescription',\n displayName: 'Short description',\n getLabel: (pageNum, questionNum) =>\n `Welsh short description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ErrorDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'errorDescription',\n displayName: 'Error description',\n getLabel: (pageNum, questionNum) =>\n `Welsh error description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.InstructionText]: {\n jsonPrefix: 'components',\n jsonSuffix: 'instructionText',\n displayName: 'Instruction text',\n getLabel: (pageNum, questionNum) =>\n `Welsh instruction text - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.DeclarationBody]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Declaration body',\n getLabel: (pageNum, questionNum) =>\n `Welsh declaration body - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PaymentDescription]: {\n jsonPrefix: 'components',\n jsonSuffix: 'paymentDescription',\n displayName: 'Payment description',\n getLabel: (pageNum, questionNum) =>\n `Welsh payment description - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemText]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'text',\n displayName: 'Option',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.ListItemHint]: {\n jsonPrefix: 'listItems',\n jsonSuffix: 'hint',\n displayName: 'Option hint',\n getLabel: (pageNum, questionNum, itemNum) =>\n `Welsh hint for option ${itemNum} - Page ${pageNum}, question ${questionNum}`\n },\n [TranslationRowTypes.PageGuidance]: {\n jsonPrefix: 'components',\n jsonSuffix: 'content',\n displayName: 'Guidance text',\n getLabel: (pageNum) => `Welsh guidance text (markdown) - page ${pageNum}`\n },\n [TranslationRowTypes.PageHeading]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'title',\n displayName: 'Page heading',\n getLabel: (pageNum) => `Welsh page heading - page ${pageNum}`\n },\n [TranslationRowTypes.RepeatTitle]: {\n jsonPrefix: 'pages',\n jsonSuffix: 'repeatTitle',\n displayName: 'Repeat name',\n getLabel: (pageNum) => `Welsh repeat name - page ${pageNum}`\n }\n}\n\nexport const IGNORE_FIELDS = [\n ComponentType.Details,\n ComponentType.Html,\n ComponentType.InsetText,\n ComponentType.HiddenField\n]\n\n/**\n * Lookup a translation from a list of translation records.\n * @param {string} key - The translation key to look up.\n * @param {Record<string, string> | undefined} translations - The translation values to search.\n */\nexport function lookupTranslation(key, translations) {\n if (!translations) {\n return ''\n }\n return translations[key] ?? ''\n}\n\n/**\n * Resolve the underlying content for a translation row from an entity.\n * Involves using the appropriate child properties if necessary.\n * @param {string} keyType - The translation row type being resolved.\n * @param {ComponentDef | Page | Item} entity - The entity that may contain the content to translate.\n * @param {string} jsonSuffix - The property name to read from the entity.\n */\nexport function drillDown(keyType, entity, jsonSuffix) {\n /** @type {Partial<Record<string, (entity: ComponentDef | Page | Item) => string>>} */\n const resolveData = {\n [TranslationRowTypes.InstructionText]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.instructionText : '',\n [TranslationRowTypes.ListItemHint]: () =>\n // @ts-expect-error - dynamic property lookup\n 'hint' in entity ? entity.hint.text : '',\n [TranslationRowTypes.DeclarationBody]: () =>\n 'content' in entity ? entity.content : '',\n [TranslationRowTypes.PaymentDescription]: () =>\n // @ts-expect-error - dynamic property lookup\n 'options' in entity ? entity.options?.description : ''\n }\n const func = resolveData[keyType]\n if (func) {\n return func(entity)\n } else {\n const entityWithDynamicProperties = /** @type {Record<string, unknown>} */ (\n /** @type {unknown} */ (entity)\n )\n if (typeof entity === 'object') {\n return jsonSuffix in entityWithDynamicProperties\n ? /** @type {string} */ (entityWithDynamicProperties[jsonSuffix])\n : ''\n }\n }\n return entity\n}\n\n/**\n * @import { ComponentDef } from '~/src/components/types.js'\n * @import { Item, Page } from '~/src/form/form-definition/types.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,mBAAmB,GAAG;EACjCC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,WAAW,EAAE,aAAa;EAC1BC,YAAY,EAAE,cAAc;EAC5BC,YAAY,EAAE,cAAc;EAC5BC,gBAAgB,EAAE,kBAAkB;EACpCC,gBA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AIyB,MAAM,GAAGA,MAAM,CAACM,OAAO,GAAG,EAAE;IAC3C,CAAC1C,mBAAmB,CAACY,kBAAkB,GAAG;IACxC;IACA,SAAS,IAAIwB,MAAM,GAAGA,MAAM,CAACE,OAAO,EAAEK,WAAW,GAAG;EACxD,CAAC;EACD,MAAMC,IAAI,GAAGP,WAAW,CAACF,OAAO,CAAC;EACjC,IAAIS,IAAI,EAAE;IACR,OAAOA,IAAI,CAACR,MAAM,CAAC;EACrB,CAAC,MAAM;IACL,MAAMS,2BAA2B,GAAG;IAClC,sBAAwBT,MACzB;IACD,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MAC9B,OAAOhB,UAAU,IAAIyB,2BAA2B,IAC5C,qBAAuBA,2BAA2B,CAACzB,UAAU,CAAC,IAC9D,EAAE;IACR;EACF;EACA,OAAOgB,MAAM;AACf;;AAEA;AACA;AACA;AACA","ignoreList":[]}
@@ -100,7 +100,7 @@ function buildPage(page, pageNum, translations, validation) {
100
100
  * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
101
101
  * @returns {TranslationRow[]} The translation rows generated for the component.
102
102
  */
103
- function buildComponent(definition, component, pageNum, questionNum, translations, validation) {
103
+ export function buildComponent(definition, component, pageNum, questionNum, translations, validation) {
104
104
  if (IGNORE_FIELDS.includes(component.type)) {
105
105
  return [];
106
106
  }
@@ -120,15 +120,15 @@ function buildComponent(definition, component, pageNum, questionNum, translation
120
120
  }
121
121
  if (component.type !== ComponentType.PaymentField) {
122
122
  rows.push(createRow(component, TranslationRowTypes.ShortDescription, options));
123
+ if (typed.errorDescription) {
124
+ rows.push(createRow(component, TranslationRowTypes.ErrorDescription, options));
125
+ }
123
126
  } else {
124
127
  rows.push(createRow(component, TranslationRowTypes.PaymentDescription, options));
125
128
  }
126
129
  if (component.type === ComponentType.DeclarationField) {
127
130
  rows.push(createRow(component, TranslationRowTypes.DeclarationBody, options));
128
131
  }
129
- if (component.type === ComponentType.PaymentField) {
130
- rows.push(createRow(component, TranslationRowTypes.PaymentDescription, options));
131
- }
132
132
  if (typed.options.instructionText && isTypeWithInstructions(component.type)) {
133
133
  rows.push(createRow(component, TranslationRowTypes.InstructionText, options));
134
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"translations.js","names":["ComponentType","isListType","isTypeWithInstructions","IGNORE_FIELDS","TranslationRowTypes","drillDown","keyConfig","lookupTranslation","buildOverviewSection","getListFromComponent","getPageNum","getQuestionNum","ControllerType","hasComponents","createRow","entity","keyType","pageNum","questionNum","itemNum","translations","validation","keyProperties","innerEnglishContent","jsonSuffix","keyName","jsonPrefix","id","name","type","englishContent","welshContent","formValues","label","getLabel","allowedControllerTypesSet","Set","Page","Repeat","Start","FileUpload","Terminal","buildPage","page","controller","has","translationRows","title","PageHeading","push","guidance","components","Markdown","undefined","PageGuidance","content","RepeatTitle","repeat","options","buildComponent","definition","component","includes","rows","typed","PaymentField","QuestionText","hint","QuestionHint","ShortDescription","PaymentDescription","DeclarationField","DeclarationBody","instructionText","InstructionText","addSelectionOptions","YesNoField","list","items","length","item","listOptions","ListItemText","ListItemHint","buildTranslationDataRows","metadata","translationsJSON","cy","overviewRows","formRows","pages","pageId","questionId"],"sources":["../../../../../src/form/form-editor/translations/translations.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { isListType, isTypeWithInstructions } from '~/src/components/helpers.js'\nimport {\n IGNORE_FIELDS,\n TranslationRowTypes,\n drillDown,\n keyConfig,\n lookupTranslation\n} from '~/src/form/form-editor/translations/translations-config.js'\nimport { buildOverviewSection } from '~/src/form/form-editor/translations/translations-overview.js'\nimport { getListFromComponent } from '~/src/form/utils/list.js'\nimport { getPageNum, getQuestionNum } from '~/src/form/utils/numbering.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * Create a translation row for a single entity field.\n * @param {ComponentDef | Page | Item} entity - The source entity that contains the English content.\n * @param {string} keyType - The translation row type to build.\n * @param {{ pageNum: number, questionNum?: number, itemNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n * @returns {TranslationRow} The populated translation row for the entity field.\n */\nfunction createRow(\n entity,\n keyType,\n { pageNum, questionNum, itemNum, translations, validation }\n) {\n const keyProperties = keyConfig[keyType]\n\n const innerEnglishContent = drillDown(\n keyType,\n entity,\n keyProperties.jsonSuffix\n )\n\n const keyName = `${keyProperties.jsonPrefix}.${entity.id}.${keyProperties.jsonSuffix}`\n\n return {\n name: keyName,\n type: keyType,\n pageNum,\n questionNum,\n itemNum,\n englishContent: innerEnglishContent,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum, questionNum, itemNum)\n }\n}\n\nconst allowedControllerTypesSet = new Set([\n ControllerType.Page,\n ControllerType.Repeat,\n ControllerType.Start,\n ControllerType.FileUpload,\n ControllerType.Terminal\n])\n\n/**\n * Build the translation rows for a single page.\n * @param {Page} page - The page definition to inspect for translatable content.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the page.\n */\nfunction buildPage(page, pageNum, translations, validation) {\n if (page.controller && !allowedControllerTypesSet.has(page.controller)) {\n return []\n }\n\n const translationRows = []\n if (page.title) {\n const keyProperties = keyConfig[TranslationRowTypes.PageHeading]\n\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageHeading,\n pageNum,\n englishContent: page.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n const guidance =\n hasComponents(page) && page.components[0].type === ComponentType.Markdown\n ? page.components[0]\n : undefined\n if (guidance) {\n const keyProperties = keyConfig[TranslationRowTypes.PageGuidance]\n const keyName = `${keyProperties.jsonPrefix}.${guidance.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageGuidance,\n pageNum,\n englishContent: guidance.content,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n if (page.controller === ControllerType.Repeat) {\n const keyProperties = keyConfig[TranslationRowTypes.RepeatTitle]\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.RepeatTitle,\n pageNum,\n englishContent: page.repeat.options.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n return translationRows\n}\n\n/**\n * Build the translation rows for a single component.\n * @param {FormDefinition} definition - The overall form definition used to resolve list-based content.\n * @param {ComponentDef} component - The component to inspect for translatable fields.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {number} questionNum - The question number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the component.\n */\nfunction buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translations,\n validation\n) {\n if (IGNORE_FIELDS.includes(component.type)) {\n return []\n }\n\n const rows = []\n\n const options = { pageNum, questionNum, translations, validation }\n\n const typed = /** @type {InputFieldsComponentsDef} */ (component)\n if (typed.title && component.type !== ComponentType.PaymentField) {\n rows.push(createRow(component, TranslationRowTypes.QuestionText, options))\n }\n if (typed.hint) {\n rows.push(createRow(component, TranslationRowTypes.QuestionHint, options))\n }\n\n if (component.type !== ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.ShortDescription, options)\n )\n } else {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (component.type === ComponentType.DeclarationField) {\n rows.push(\n createRow(component, TranslationRowTypes.DeclarationBody, options)\n )\n }\n\n if (component.type === ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (typed.options.instructionText && isTypeWithInstructions(component.type)) {\n rows.push(\n createRow(component, TranslationRowTypes.InstructionText, options)\n )\n }\n\n if (isListType(component.type)) {\n addSelectionOptions(rows, component, definition, options)\n }\n return rows\n}\n\n/**\n * Add translation rows for the select item options of a list-based component.\n * @param {any[]} rows - The accumulator for translation rows.\n * @param {ComponentDef} component - The list-based component to inspect.\n * @param {FormDefinition} definition - The form definition that contains the option list data.\n * @param {{ pageNum: number, questionNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n */\nfunction addSelectionOptions(rows, component, definition, options) {\n // Temporary workaround - ignore for Yes/No and use defaults in the plugin,\n // until we create a solution that allows users to override the Yes/No options\n if (component.type === ComponentType.YesNoField) {\n return\n }\n\n const list = getListFromComponent(component, definition)\n if (list?.items.length) {\n let itemNum = 0\n for (const item of list.items) {\n itemNum++\n const listOptions = {\n ...options,\n itemNum\n }\n if (item.hint) {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions),\n createRow(item, TranslationRowTypes.ListItemHint, listOptions)\n )\n } else {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions)\n )\n }\n }\n }\n}\n\n/**\n * Build the overview and form translation rows for a form definition.\n * @param {FormMetadata} metadata - The form metadata used to build the overview section.\n * @param {FormDefinition} definition - The form definition containing pages and components.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {{ overviewRows: TranslationRow[], formRows: TranslationRow[] }} The generated overview and form translation rows.\n */\nexport function buildTranslationDataRows(metadata, definition, validation) {\n const translationsJSON = /** @type {Record<string, string>} */ (\n // @ts-expect-error - dynamic language definition\n definition.metadata?.translations?.cy\n )\n\n const overviewRows = buildOverviewSection(\n metadata,\n definition,\n translationsJSON,\n validation\n )\n\n const formRows = []\n for (const page of definition.pages) {\n const pageId = /** @type {string} */ (page.id)\n const pageNum = getPageNum(definition, pageId)\n const components = hasComponents(page) ? page.components : []\n if (components.length === 0) {\n continue\n }\n\n formRows.push(...buildPage(page, pageNum, translationsJSON, validation))\n\n for (const component of components) {\n if (component.type === ComponentType.Markdown) {\n continue\n }\n const questionId = /** @type {string} */ (component.id)\n const questionNum = getQuestionNum(definition, pageId, questionId)\n\n formRows.push(\n ...buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translationsJSON,\n validation\n )\n )\n }\n }\n\n return {\n overviewRows,\n formRows\n }\n}\n\n/**\n * @import { ComponentDef, InputFieldsComponentsDef } from '~/src/components/types.js'\n * @import { FormMetadata } from '~/src/form/form-metadata/types.js'\n * @import { FormDefinition, Item, Page } from '~/src/form/form-definition/types.js'\n * @import { TranslationRow, ValidationFailure } from '~/src/form/form-editor/translations/translations-config.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,UAAU,EAAEC,sBAAsB;AAC3C,SACEC,aAAa,EACbC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,iBAAiB;AAEnB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,UAAU,EAAEC,cAAc;AACnC,SAASC,cAAc;AACvB,SAASC,aAAa;;AAEtB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAASA,CAChBC,MAAM,EACNC,OAAO,EACP;EAAEC,OAAO;EAAEC,WAAW;EAAEC,OAAO;EAAEC,YAAY;EAAEC;AAAW,CAAC,EAC3D;EACA,MAAMC,aAAa,GAAGhB,SAAS,CAACU,OAAO,CAAC;EAExC,MAAMO,mBAAmB,GAAGlB,SAAS,CACnCW,OAAO,EACPD,MAAM,EACNO,aAAa,CAACE,UAChB,CAAC;EAED,MAAMC,OAAO,GAAG,GAAGH,aAAa,CAACI,UAAU,IAAIX,MAAM,CAACY,EAAE,IAAIL,aAAa,CAACE,UAAU,EA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AAC,GAAGP,SAAS,CAACC,IAAI,EAAE1B,OAAO,EAAEqE,gBAAgB,EAAEjE,UAAU,CAAC,CAAC;IAExE,KAAK,MAAMwC,SAAS,IAAIV,UAAU,EAAE;MAClC,IAAIU,SAAS,CAAChC,IAAI,KAAK7B,aAAa,CAACoD,QAAQ,EAAE;QAC7C;MACF;MACA,MAAMwC,UAAU,GAAG,qBAAuB/B,SAAS,CAAClC,EAAG;MACvD,MAAMT,WAAW,GAAGP,cAAc,CAACiD,UAAU,EAAE+B,MAAM,EAAEC,UAAU,CAAC;MAElEH,QAAQ,CAACxC,IAAI,CACX,GAAGU,cAAc,CACfC,UAAU,EACVC,SAAS,EACT5C,OAAO,EACPC,WAAW,EACXoE,gBAAgB,EAChBjE,UACF,CACF,CAAC;IACH;EACF;EAEA,OAAO;IACLmE,YAAY;IACZC;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"file":"translations.js","names":["ComponentType","isListType","isTypeWithInstructions","IGNORE_FIELDS","TranslationRowTypes","drillDown","keyConfig","lookupTranslation","buildOverviewSection","getListFromComponent","getPageNum","getQuestionNum","ControllerType","hasComponents","createRow","entity","keyType","pageNum","questionNum","itemNum","translations","validation","keyProperties","innerEnglishContent","jsonSuffix","keyName","jsonPrefix","id","name","type","englishContent","welshContent","formValues","label","getLabel","allowedControllerTypesSet","Set","Page","Repeat","Start","FileUpload","Terminal","buildPage","page","controller","has","translationRows","title","PageHeading","push","guidance","components","Markdown","undefined","PageGuidance","content","RepeatTitle","repeat","options","buildComponent","definition","component","includes","rows","typed","PaymentField","QuestionText","hint","QuestionHint","ShortDescription","errorDescription","ErrorDescription","PaymentDescription","DeclarationField","DeclarationBody","instructionText","InstructionText","addSelectionOptions","YesNoField","list","items","length","item","listOptions","ListItemText","ListItemHint","buildTranslationDataRows","metadata","translationsJSON","cy","overviewRows","formRows","pages","pageId","questionId"],"sources":["../../../../../src/form/form-editor/translations/translations.js"],"sourcesContent":["import { ComponentType } from '~/src/components/enums.js'\nimport { isListType, isTypeWithInstructions } from '~/src/components/helpers.js'\nimport {\n IGNORE_FIELDS,\n TranslationRowTypes,\n drillDown,\n keyConfig,\n lookupTranslation\n} from '~/src/form/form-editor/translations/translations-config.js'\nimport { buildOverviewSection } from '~/src/form/form-editor/translations/translations-overview.js'\nimport { getListFromComponent } from '~/src/form/utils/list.js'\nimport { getPageNum, getQuestionNum } from '~/src/form/utils/numbering.js'\nimport { ControllerType } from '~/src/pages/enums.js'\nimport { hasComponents } from '~/src/pages/helpers.js'\n\n/**\n * Create a translation row for a single entity field.\n * @param {ComponentDef | Page | Item} entity - The source entity that contains the English content.\n * @param {string} keyType - The translation row type to build.\n * @param {{ pageNum: number, questionNum?: number, itemNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n * @returns {TranslationRow} The populated translation row for the entity field.\n */\nfunction createRow(\n entity,\n keyType,\n { pageNum, questionNum, itemNum, translations, validation }\n) {\n const keyProperties = keyConfig[keyType]\n\n const innerEnglishContent = drillDown(\n keyType,\n entity,\n keyProperties.jsonSuffix\n )\n\n const keyName = `${keyProperties.jsonPrefix}.${entity.id}.${keyProperties.jsonSuffix}`\n\n return {\n name: keyName,\n type: keyType,\n pageNum,\n questionNum,\n itemNum,\n englishContent: innerEnglishContent,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum, questionNum, itemNum)\n }\n}\n\nconst allowedControllerTypesSet = new Set([\n ControllerType.Page,\n ControllerType.Repeat,\n ControllerType.Start,\n ControllerType.FileUpload,\n ControllerType.Terminal\n])\n\n/**\n * Build the translation rows for a single page.\n * @param {Page} page - The page definition to inspect for translatable content.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the page.\n */\nfunction buildPage(page, pageNum, translations, validation) {\n if (page.controller && !allowedControllerTypesSet.has(page.controller)) {\n return []\n }\n\n const translationRows = []\n if (page.title) {\n const keyProperties = keyConfig[TranslationRowTypes.PageHeading]\n\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageHeading,\n pageNum,\n englishContent: page.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n const guidance =\n hasComponents(page) && page.components[0].type === ComponentType.Markdown\n ? page.components[0]\n : undefined\n if (guidance) {\n const keyProperties = keyConfig[TranslationRowTypes.PageGuidance]\n const keyName = `${keyProperties.jsonPrefix}.${guidance.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.PageGuidance,\n pageNum,\n englishContent: guidance.content,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n if (page.controller === ControllerType.Repeat) {\n const keyProperties = keyConfig[TranslationRowTypes.RepeatTitle]\n const keyName = `${keyProperties.jsonPrefix}.${page.id}.${keyProperties.jsonSuffix}`\n\n translationRows.push({\n name: keyName,\n type: TranslationRowTypes.RepeatTitle,\n pageNum,\n englishContent: page.repeat.options.title,\n welshContent:\n validation?.formValues[keyName] ??\n lookupTranslation(keyName, translations),\n label: keyProperties.getLabel(pageNum)\n })\n }\n\n return translationRows\n}\n\n/**\n * Build the translation rows for a single component.\n * @param {FormDefinition} definition - The overall form definition used to resolve list-based content.\n * @param {ComponentDef} component - The component to inspect for translatable fields.\n * @param {number} pageNum - The page number used in the generated labels.\n * @param {number} questionNum - The question number used in the generated labels.\n * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {TranslationRow[]} The translation rows generated for the component.\n */\nexport function buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translations,\n validation\n) {\n if (IGNORE_FIELDS.includes(component.type)) {\n return []\n }\n\n const rows = []\n\n const options = { pageNum, questionNum, translations, validation }\n\n const typed = /** @type {InputFieldsComponentsDef} */ (component)\n if (typed.title && component.type !== ComponentType.PaymentField) {\n rows.push(createRow(component, TranslationRowTypes.QuestionText, options))\n }\n if (typed.hint) {\n rows.push(createRow(component, TranslationRowTypes.QuestionHint, options))\n }\n\n if (component.type !== ComponentType.PaymentField) {\n rows.push(\n createRow(component, TranslationRowTypes.ShortDescription, options)\n )\n if (typed.errorDescription) {\n rows.push(\n createRow(component, TranslationRowTypes.ErrorDescription, options)\n )\n }\n } else {\n rows.push(\n createRow(component, TranslationRowTypes.PaymentDescription, options)\n )\n }\n\n if (component.type === ComponentType.DeclarationField) {\n rows.push(\n createRow(component, TranslationRowTypes.DeclarationBody, options)\n )\n }\n\n if (typed.options.instructionText && isTypeWithInstructions(component.type)) {\n rows.push(\n createRow(component, TranslationRowTypes.InstructionText, options)\n )\n }\n\n if (isListType(component.type)) {\n addSelectionOptions(rows, component, definition, options)\n }\n return rows\n}\n\n/**\n * Add translation rows for the select item options of a list-based component.\n * @param {any[]} rows - The accumulator for translation rows.\n * @param {ComponentDef} component - The list-based component to inspect.\n * @param {FormDefinition} definition - The form definition that contains the option list data.\n * @param {{ pageNum: number, questionNum?: number, translations: Record<string, string>, validation?: ValidationFailure<any> }} options - The row context including numbering and translation values.\n */\nfunction addSelectionOptions(rows, component, definition, options) {\n // Temporary workaround - ignore for Yes/No and use defaults in the plugin,\n // until we create a solution that allows users to override the Yes/No options\n if (component.type === ComponentType.YesNoField) {\n return\n }\n\n const list = getListFromComponent(component, definition)\n if (list?.items.length) {\n let itemNum = 0\n for (const item of list.items) {\n itemNum++\n const listOptions = {\n ...options,\n itemNum\n }\n if (item.hint) {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions),\n createRow(item, TranslationRowTypes.ListItemHint, listOptions)\n )\n } else {\n rows.push(\n createRow(item, TranslationRowTypes.ListItemText, listOptions)\n )\n }\n }\n }\n}\n\n/**\n * Build the overview and form translation rows for a form definition.\n * @param {FormMetadata} metadata - The form metadata used to build the overview section.\n * @param {FormDefinition} definition - The form definition containing pages and components.\n * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.\n * @returns {{ overviewRows: TranslationRow[], formRows: TranslationRow[] }} The generated overview and form translation rows.\n */\nexport function buildTranslationDataRows(metadata, definition, validation) {\n const translationsJSON = /** @type {Record<string, string>} */ (\n // @ts-expect-error - dynamic language definition\n definition.metadata?.translations?.cy\n )\n\n const overviewRows = buildOverviewSection(\n metadata,\n definition,\n translationsJSON,\n validation\n )\n\n const formRows = []\n for (const page of definition.pages) {\n const pageId = /** @type {string} */ (page.id)\n const pageNum = getPageNum(definition, pageId)\n const components = hasComponents(page) ? page.components : []\n if (components.length === 0) {\n continue\n }\n\n formRows.push(...buildPage(page, pageNum, translationsJSON, validation))\n\n for (const component of components) {\n if (component.type === ComponentType.Markdown) {\n continue\n }\n const questionId = /** @type {string} */ (component.id)\n const questionNum = getQuestionNum(definition, pageId, questionId)\n\n formRows.push(\n ...buildComponent(\n definition,\n component,\n pageNum,\n questionNum,\n translationsJSON,\n validation\n )\n )\n }\n }\n\n return {\n overviewRows,\n formRows\n }\n}\n\n/**\n * @import { ComponentDef, InputFieldsComponentsDef } from '~/src/components/types.js'\n * @import { FormMetadata } from '~/src/form/form-metadata/types.js'\n * @import { FormDefinition, Item, Page } from '~/src/form/form-definition/types.js'\n * @import { TranslationRow, ValidationFailure } from '~/src/form/form-editor/translations/translations-config.js'\n */\n"],"mappings":"AAAA,SAASA,aAAa;AACtB,SAASC,UAAU,EAAEC,sBAAsB;AAC3C,SACEC,aAAa,EACbC,mBAAmB,EACnBC,SAAS,EACTC,SAAS,EACTC,iBAAiB;AAEnB,SAASC,oBAAoB;AAC7B,SAASC,oBAAoB;AAC7B,SAASC,UAAU,EAAEC,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AChBnE,UACF,CAAC;EAED,MAAMsE,QAAQ,GAAG,EAAE;EACnB,KAAK,MAAMhD,IAAI,IAAIiB,UAAU,CAACgC,KAAK,EAAE;IACnC,MAAMC,MAAM,GAAG,qBAAuBlD,IAAI,CAAChB,EAAG;IAC9C,MAAMV,OAAO,GAAGP,UAAU,CAACkD,UAAU,EAAEiC,MAAM,CAAC;IAC9C,MAAM1C,UAAU,GAAGtC,aAAa,CAAC8B,IAAI,CAAC,GAAGA,IAAI,CAACQ,UAAU,GAAG,EAAE;IAC7D,IAAIA,UAAU,CAAC8B,MAAM,KAAK,CAAC,EAAE;MAC3B;IACF;IAEAU,QAAQ,CAAC1C,IAAI,CAAC,GAAGP,SAAS,CAACC,IAAI,EAAE1B,OAAO,EAAEuE,gBAAgB,EAAEnE,UAAU,CAAC,CAAC;IAExE,KAAK,MAAMwC,SAAS,IAAIV,UAAU,EAAE;MAClC,IAAIU,SAAS,CAAChC,IAAI,KAAK7B,aAAa,CAACoD,QAAQ,EAAE;QAC7C;MACF;MACA,MAAM0C,UAAU,GAAG,qBAAuBjC,SAAS,CAAClC,EAAG;MACvD,MAAMT,WAAW,GAAGP,cAAc,CAACiD,UAAU,EAAEiC,MAAM,EAAEC,UAAU,CAAC;MAElEH,QAAQ,CAAC1C,IAAI,CACX,GAAGU,cAAc,CACfC,UAAU,EACVC,SAAS,EACT5C,OAAO,EACPC,WAAW,EACXsE,gBAAgB,EAChBnE,UACF,CACF,CAAC;IACH;EACF;EAEA,OAAO;IACLqE,YAAY;IACZC;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
@@ -21,12 +21,13 @@ export let Scopes = /*#__PURE__*/function (Scopes) {
21
21
  Scopes["FormsInspect"] = "forms-inspect";
22
22
  Scopes["FormsReport"] = "forms-report";
23
23
  Scopes["RegenerateMetrics"] = "regenerate-metrics";
24
+ Scopes["SubmissionRead"] = "submission-read";
24
25
  return Scopes;
25
26
  }({});
26
27
  export const RoleScopes = {
27
28
  [Roles.Superadmin]: Object.values(Scopes),
28
- [Roles.Admin]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.UserCreate, Scopes.UserDelete, Scopes.UserEdit, Scopes.FormsFeedback, Scopes.FormsFeedbackAllForms, Scopes.FormsReport],
29
- [Roles.FormPublisher]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.FormsFeedback],
29
+ [Roles.Admin]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.UserCreate, Scopes.UserDelete, Scopes.UserEdit, Scopes.FormsFeedback, Scopes.FormsFeedbackAllForms, Scopes.FormsReport, Scopes.SubmissionRead],
30
+ [Roles.FormPublisher]: [Scopes.FormDelete, Scopes.FormEdit, Scopes.FormRead, Scopes.FormPublish, Scopes.FormsFeedback, Scopes.SubmissionRead],
30
31
  [Roles.FormCreator]: [Scopes.FormRead, Scopes.FormEdit, Scopes.FormDelete, Scopes.FormsFeedback]
31
32
  };
32
33
  export const RoleNames = {
@@ -1 +1 @@
1
- {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormsFeedbackAllForms","FormsReport","FormPublisher","FormCreator","RoleNames","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsFeedbackAllForms = 'forms-feedback-all-forms',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit',\n DeadLetterQueues = 'dead-letter-queues',\n FormsInspect = 'forms-inspect',\n FormsReport = 'forms-report',\n RegenerateMetrics = 'regenerate-metrics'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback,\n Scopes.FormsFeedbackAllForms,\n Scopes.FormsReport\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.FormsFeedback\n ],\n [Roles.FormCreator]: [\n Scopes.FormRead,\n Scopes.FormEdit,\n Scopes.FormDelete,\n Scopes.FormsFeedback\n ]\n}\n\nexport const RoleNames = {\n [Roles.Superadmin]: 'Superadmin',\n [Roles.Admin]: 'Admin',\n [Roles.FormPublisher]: 'Form publisher',\n [Roles.FormCreator]: 'Form creator'\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<Scopes>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAkBlB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CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
1
+ {"version":3,"file":"roles.js","names":["Roles","Scopes","RoleScopes","Superadmin","Object","values","Admin","FormDelete","FormEdit","FormRead","FormPublish","UserCreate","UserDelete","UserEdit","FormsFeedback","FormsFeedbackAllForms","FormsReport","SubmissionRead","FormPublisher","FormCreator","RoleNames","mapScopesToRoles","roles","scopeSet","Set","forEach","role","scopes","scope","add","Array","from"],"sources":["../../../src/manage/roles.ts"],"sourcesContent":["export enum Roles {\n Superadmin = 'superadmin',\n Admin = 'admin',\n FormPublisher = 'form-publisher',\n FormCreator = 'form-creator'\n}\n\nexport enum Scopes {\n FormDelete = 'form-delete',\n FormEdit = 'form-edit',\n FormRead = 'form-read',\n FormPublish = 'form-publish',\n UserCreate = 'user-create',\n UserDelete = 'user-delete',\n UserEdit = 'user-edit',\n FormsFeedback = 'forms-feedback',\n FormsFeedbackAllForms = 'forms-feedback-all-forms',\n FormsBackup = 'forms-backup',\n ResetSaveAndExit = 'reset-save-and-exit',\n DeadLetterQueues = 'dead-letter-queues',\n FormsInspect = 'forms-inspect',\n FormsReport = 'forms-report',\n RegenerateMetrics = 'regenerate-metrics',\n SubmissionRead = 'submission-read'\n}\n\nexport const RoleScopes = {\n [Roles.Superadmin]: Object.values(Scopes),\n [Roles.Admin]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.UserCreate,\n Scopes.UserDelete,\n Scopes.UserEdit,\n Scopes.FormsFeedback,\n Scopes.FormsFeedbackAllForms,\n Scopes.FormsReport,\n Scopes.SubmissionRead\n ],\n [Roles.FormPublisher]: [\n Scopes.FormDelete,\n Scopes.FormEdit,\n Scopes.FormRead,\n Scopes.FormPublish,\n Scopes.FormsFeedback,\n Scopes.SubmissionRead\n ],\n [Roles.FormCreator]: [\n Scopes.FormRead,\n Scopes.FormEdit,\n Scopes.FormDelete,\n Scopes.FormsFeedback\n ]\n}\n\nexport const RoleNames = {\n [Roles.Superadmin]: 'Superadmin',\n [Roles.Admin]: 'Admin',\n [Roles.FormPublisher]: 'Form publisher',\n [Roles.FormCreator]: 'Form creator'\n}\n\n/**\n * Return a unique list of scopes based on the array of roles passed in\n */\nexport function mapScopesToRoles(roles: Roles[]) {\n const scopeSet = new Set<Scopes>()\n roles.forEach((role) => {\n const scopes = RoleScopes[role]\n scopes.forEach((scope) => {\n scopeSet.add(scope)\n })\n })\n return Array.from(scopeSet)\n}\n"],"mappings":"AAAA,WAAYA,KAAK,0BAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAALA,KAAK;EAAA,OAALA,KAAK;AAAA;AAOjB,WAAYC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA;AAmBlB,OAAO,MAAMC,UAAU,GAAG;EACxB,CAACF,KAAK,CAACG,UAAU,GAAGC,MAAM,CAACC,MAAM,CAACJ,MAAM,CAAC;EACzC,CAACD,KAAK,CAACM,KAAK,GAAG,CACbL,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACU,UAAU,EACjBV,MAAM,CAACW,UAAU,EACjBX,MAAM,CAACY,QAAQ,EACfZ,MAAM,CAACa,aAAa,EACpBb,MAAM,CAACc,qBAAqB,EAC5Bd,MAAM,CAACe,WAAW,EAClBf,MAAM,CAACgB,cAAc,CACtB;EACD,CAACjB,KAAK,CAACkB,aAAa,GAAG,CACrBjB,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACS,WAAW,EAClBT,MAAM,CAACa,aAAa,EACpBb,MAAM,CAACgB,cAAc,CACtB;EACD,CAACjB,KAAK,CAACmB,WAAW,GAAG,CACnBlB,MAAM,CAACQ,QAAQ,EACfR,MAAM,CAACO,QAAQ,EACfP,MAAM,CAACM,UAAU,EACjBN,MAAM,CAACa,aAAa;AAExB,CAAC;AAED,OAAO,MAAMM,SAAS,GAAG;EACvB,CAACpB,KAAK,CAACG,UAAU,GAAG,YAAY;EAChC,CAACH,KAAK,CAACM,KAAK,GAAG,OAAO;EACtB,CAACN,KAAK,CAACkB,aAAa,GAAG,gBAAgB;EACvC,CAAClB,KAAK,CAACmB,WAAW,GAAG;AACvB,CAAC;;AAED;AACA;AACA;AACA,OAAO,SAASE,gBAAgBA,CAACC,KAAc,EAAE;EAC/C,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAClCF,KAAK,CAACG,OAAO,CAAEC,IAAI,IAAK;IACtB,MAAMC,MAAM,GAAGzB,UAAU,CAACwB,IAAI,CAAC;IAC/BC,MAAM,CAACF,OAAO,CAAEG,KAAK,IAAK;MACxBL,QAAQ,CAACM,GAAG,CAACD,KAAK,CAAC;IACrB,CAAC,CAAC;EACJ,CAAC,CAAC;EACF,OAAOE,KAAK,CAACC,IAAI,CAACR,QAAQ,CAAC;AAC7B","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"translations-config.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"names":[],"mappings":"AAoIA;;;;GAIG;AACH,uCAHW,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,UAO5C;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,UACN,YAAY,GAAG,IAAI,GAAG,IAAI,cAC1B,MAAM,UA+BhB;;;;;;;;;;;;;;;AA3ID,8BAA+B,WAAW,CAAA;AAC1C,8BAA+B,WAAW,CAAA;AAC1C,6CAA8C,oBAAoB,CAAA;AAClE,6BAA8B,cAAc,CAAA;AAC5C,4CAA6C,6BAA6B,CAAA;AAE1E,6KAA6K;AAC7K,wBADW,MAAM,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAAC,CA4ExK;AAED,4CAKC;;;;;UA9Ha,MAAM;;;;;;;;oBAEN,MAAM,GAAG,SAAS;;;;kBAClB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;+BAQnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;2BAC/B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;8BAItB,MAAM;;;;gBAEf,YAAY;;;;gBACZ,MAAM;;kCAgKa,2BAA2B;0BAC7B,qCAAqC;0BAArC,qCAAqC;8BAxLtC,2BAA2B"}
1
+ {"version":3,"file":"translations-config.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations-config.js"],"names":[],"mappings":"AA2IA;;;;GAIG;AACH,uCAHW,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,UAO5C;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,UACN,YAAY,GAAG,IAAI,GAAG,IAAI,cAC1B,MAAM,UA+BhB;;;;;;;;;;;;;;;AAlJD,8BAA+B,WAAW,CAAA;AAC1C,8BAA+B,WAAW,CAAA;AAC1C,6CAA8C,oBAAoB,CAAA;AAClE,6BAA8B,cAAc,CAAA;AAC5C,4CAA6C,6BAA6B,CAAA;AAE1E,6KAA6K;AAC7K,wBADW,MAAM,CAAC,MAAM,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,MAAM,CAAA;CAAE,CAAC,CAmFxK;AAED,4CAKC;;;;;UArIa,MAAM;;;;;;;;oBAEN,MAAM,GAAG,SAAS;;;;kBAClB,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;;;+BAQnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE;2BAC/B,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;8BAItB,MAAM;;;;gBAEf,YAAY;;;;gBACZ,MAAM;;kCAuKa,2BAA2B;0BAC7B,qCAAqC;0BAArC,qCAAqC;8BA/LtC,2BAA2B"}
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Build the translation rows for a single component.
3
+ * @param {FormDefinition} definition - The overall form definition used to resolve list-based content.
4
+ * @param {ComponentDef} component - The component to inspect for translatable fields.
5
+ * @param {number} pageNum - The page number used in the generated labels.
6
+ * @param {number} questionNum - The question number used in the generated labels.
7
+ * @param {Record<string, string>} translations - Existing Welsh translations keyed by translation name.
8
+ * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
9
+ * @returns {TranslationRow[]} The translation rows generated for the component.
10
+ */
11
+ export function buildComponent(definition: FormDefinition, component: ComponentDef, pageNum: number, questionNum: number, translations: Record<string, string>, validation?: ValidationFailure<any>): TranslationRow[];
1
12
  /**
2
13
  * Build the overview and form translation rows for a form definition.
3
14
  * @param {FormMetadata} metadata - The form metadata used to build the overview section.
@@ -9,8 +20,9 @@ export function buildTranslationDataRows(metadata: FormMetadata, definition: For
9
20
  overviewRows: TranslationRow[];
10
21
  formRows: TranslationRow[];
11
22
  };
12
- import type { FormMetadata } from '../../../form/form-metadata/types.js';
13
23
  import type { FormDefinition } from '../../../form/form-definition/types.js';
24
+ import type { ComponentDef } from '../../../components/types.js';
14
25
  import type { ValidationFailure } from '../../../form/form-editor/translations/translations-config.js';
15
26
  import type { TranslationRow } from '../../../form/form-editor/translations/translations-config.js';
27
+ import type { FormMetadata } from '../../../form/form-metadata/types.js';
16
28
  //# sourceMappingURL=translations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations.js"],"names":[],"mappings":"AA0OA;;;;;;GAMG;AACH,mDALW,YAAY,cACZ,cAAc,eACd,kBAAkB,GAAG,CAAC,GACpB;IAAE,YAAY,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAkD1E;kCAIgC,mCAAmC;oCACrB,qCAAqC;uCAC9B,4DAA4D;oCAA5D,4DAA4D"}
1
+ {"version":3,"file":"translations.d.ts","sourceRoot":"","sources":["../../../../../src/form/form-editor/translations/translations.js"],"names":[],"mappings":"AAiIA;;;;;;;;;GASG;AACH,2CARW,cAAc,aACd,YAAY,WACZ,MAAM,eACN,MAAM,gBACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,eACtB,kBAAkB,GAAG,CAAC,GACpB,cAAc,EAAE,CAyD5B;AAuCD;;;;;;GAMG;AACH,mDALW,YAAY,cACZ,cAAc,eACd,kBAAkB,GAAG,CAAC,GACpB;IAAE,YAAY,EAAE,cAAc,EAAE,CAAC;IAAC,QAAQ,EAAE,cAAc,EAAE,CAAA;CAAE,CAkD1E;oCAK8C,qCAAqC;kCAFzB,2BAA2B;uCAGhC,4DAA4D;oCAA5D,4DAA4D;kCAFjF,mCAAmC"}
@@ -19,7 +19,8 @@ export declare enum Scopes {
19
19
  DeadLetterQueues = "dead-letter-queues",
20
20
  FormsInspect = "forms-inspect",
21
21
  FormsReport = "forms-report",
22
- RegenerateMetrics = "regenerate-metrics"
22
+ RegenerateMetrics = "regenerate-metrics",
23
+ SubmissionRead = "submission-read"
23
24
  }
24
25
  export declare const RoleScopes: {
25
26
  superadmin: Scopes[];
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,qBAAqB,6BAA6B;IAClD,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;IACxC,gBAAgB,uBAAuB;IACvC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,iBAAiB,uBAAuB;CACzC;AAED,eAAO,MAAM,UAAU;;;;;CA2BtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
1
+ {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../../src/manage/roles.ts"],"names":[],"mappings":"AAAA,oBAAY,KAAK;IACf,UAAU,eAAe;IACzB,KAAK,UAAU;IACf,aAAa,mBAAmB;IAChC,WAAW,iBAAiB;CAC7B;AAED,oBAAY,MAAM;IAChB,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,QAAQ,cAAc;IACtB,WAAW,iBAAiB;IAC5B,UAAU,gBAAgB;IAC1B,UAAU,gBAAgB;IAC1B,QAAQ,cAAc;IACtB,aAAa,mBAAmB;IAChC,qBAAqB,6BAA6B;IAClD,WAAW,iBAAiB;IAC5B,gBAAgB,wBAAwB;IACxC,gBAAgB,uBAAuB;IACvC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,iBAAiB,uBAAuB;IACxC,cAAc,oBAAoB;CACnC;AAED,eAAO,MAAM,UAAU;;;;;CA6BtB,CAAA;AAED,eAAO,MAAM,SAAS;;;;;CAKrB,CAAA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,EAAE,YAS9C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/forms-model",
3
- "version": "3.0.689",
3
+ "version": "3.0.691",
4
4
  "description": "A hapi plugin providing the model for Defra forms",
5
5
  "homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
6
6
  "types": "dist/types/index.d.ts",
@@ -68,6 +68,13 @@ export const keyConfig = {
68
68
  getLabel: (pageNum, questionNum) =>
69
69
  `Welsh short description - Page ${pageNum}, question ${questionNum}`
70
70
  },
71
+ [TranslationRowTypes.ErrorDescription]: {
72
+ jsonPrefix: 'components',
73
+ jsonSuffix: 'errorDescription',
74
+ displayName: 'Error description',
75
+ getLabel: (pageNum, questionNum) =>
76
+ `Welsh error description - Page ${pageNum}, question ${questionNum}`
77
+ },
71
78
  [TranslationRowTypes.InstructionText]: {
72
79
  jsonPrefix: 'components',
73
80
  jsonSuffix: 'instructionText',
@@ -137,7 +137,7 @@ function buildPage(page, pageNum, translations, validation) {
137
137
  * @param {ValidationFailure<any>} [validation] - Optional validation context for posted form values.
138
138
  * @returns {TranslationRow[]} The translation rows generated for the component.
139
139
  */
140
- function buildComponent(
140
+ export function buildComponent(
141
141
  definition,
142
142
  component,
143
143
  pageNum,
@@ -165,6 +165,11 @@ function buildComponent(
165
165
  rows.push(
166
166
  createRow(component, TranslationRowTypes.ShortDescription, options)
167
167
  )
168
+ if (typed.errorDescription) {
169
+ rows.push(
170
+ createRow(component, TranslationRowTypes.ErrorDescription, options)
171
+ )
172
+ }
168
173
  } else {
169
174
  rows.push(
170
175
  createRow(component, TranslationRowTypes.PaymentDescription, options)
@@ -177,12 +182,6 @@ function buildComponent(
177
182
  )
178
183
  }
179
184
 
180
- if (component.type === ComponentType.PaymentField) {
181
- rows.push(
182
- createRow(component, TranslationRowTypes.PaymentDescription, options)
183
- )
184
- }
185
-
186
185
  if (typed.options.instructionText && isTypeWithInstructions(component.type)) {
187
186
  rows.push(
188
187
  createRow(component, TranslationRowTypes.InstructionText, options)
@@ -20,7 +20,8 @@ export enum Scopes {
20
20
  DeadLetterQueues = 'dead-letter-queues',
21
21
  FormsInspect = 'forms-inspect',
22
22
  FormsReport = 'forms-report',
23
- RegenerateMetrics = 'regenerate-metrics'
23
+ RegenerateMetrics = 'regenerate-metrics',
24
+ SubmissionRead = 'submission-read'
24
25
  }
25
26
 
26
27
  export const RoleScopes = {
@@ -35,14 +36,16 @@ export const RoleScopes = {
35
36
  Scopes.UserEdit,
36
37
  Scopes.FormsFeedback,
37
38
  Scopes.FormsFeedbackAllForms,
38
- Scopes.FormsReport
39
+ Scopes.FormsReport,
40
+ Scopes.SubmissionRead
39
41
  ],
40
42
  [Roles.FormPublisher]: [
41
43
  Scopes.FormDelete,
42
44
  Scopes.FormEdit,
43
45
  Scopes.FormRead,
44
46
  Scopes.FormPublish,
45
- Scopes.FormsFeedback
47
+ Scopes.FormsFeedback,
48
+ Scopes.SubmissionRead
46
49
  ],
47
50
  [Roles.FormCreator]: [
48
51
  Scopes.FormRead,