@ministryofjustice/fb-nunjucks-helpers
Advanced tools
Comparing version 0.0.6 to 0.0.7
@@ -19,2 +19,10 @@ const Markdown = require('markdown-it')() | ||
} | ||
if (data[prop]) { | ||
if (data._id) { | ||
data[prop].attributes = { | ||
'data-block-id': data._id, | ||
'data-block-property': prop | ||
} | ||
} | ||
} | ||
return data | ||
@@ -33,29 +41,45 @@ } | ||
const setItemsLabel = data => { | ||
data = setLabel(data) | ||
data.legend = data.legend || data.label | ||
data = checkPropObject(data, 'legend') | ||
data.fieldset = data.fieldset || {} | ||
if (data.legend) { | ||
data.fieldset = Object.assign({}, data.fieldset, { | ||
legend: data.legend | ||
}) | ||
} | ||
if (data.hint) { | ||
data.fieldset = Object.assign({}, data.fieldset, { | ||
hint: data.hint | ||
}) | ||
} | ||
try { | ||
data = setLabel(data) | ||
data.legend = data.legend || data.label | ||
data = checkPropObject(data, 'legend') | ||
data.fieldset = data.fieldset || {} | ||
if (data.legend) { | ||
data.fieldset = Object.assign({}, data.fieldset, { | ||
legend: data.legend | ||
}, { | ||
attributes: data.legend.attributes | ||
}) | ||
delete data.legend.attributes | ||
} | ||
if (data.hint) { | ||
data.fieldset = Object.assign({}, data.fieldset, { | ||
hint: data.hint | ||
}) | ||
} | ||
if (data.error) { | ||
data.fieldset.errorMessage = { | ||
html: data.error | ||
if (data.error) { | ||
data.fieldset.errorMessage = { | ||
html: data.error | ||
} | ||
} | ||
data = Object.assign(data, data.fieldset) | ||
data.items = data.items || [] | ||
data.items = data.items.map(item => { | ||
const updatedItem = Object.assign({}, item, { | ||
text: item.text ? item.text : item.label | ||
}) | ||
if (data._type !== 'date') { | ||
updatedItem.label = { | ||
attributes: { | ||
'data-block-id': item._id, | ||
'data-block-property': 'label' | ||
} | ||
} | ||
} | ||
return updatedItem | ||
}) | ||
} catch (e) { | ||
// console.log(e) | ||
} | ||
data = Object.assign(data, data.fieldset) | ||
data.items = data.items || [] | ||
data.items = data.items.map(item => { | ||
return Object.assign({}, item, { | ||
text: item.text ? item.text : item.label | ||
}) | ||
}) | ||
return data | ||
@@ -62,0 +86,0 @@ } |
{ | ||
"name": "@ministryofjustice/fb-nunjucks-helpers", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "Form Builder Nunjucks helpers", | ||
@@ -5,0 +5,0 @@ "main": "lib/fb-nunjucks-helpers.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26124
603