Skip to content

Commit

Permalink
fix(regulations-admin): Format amending and cancel, styles, signature (
Browse files Browse the repository at this point in the history
…#15344)

* format amending and cancel, styles, signature

* Remove console log

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and snaerseljan committed Jul 2, 2024
1 parent 009b561 commit a72812f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useS3Upload } from '../utils/dataHooks'
const defaultSignatureText = `
<p class="Dags" align="center"><em>{ministry}nu, {dags}.</em></p>
<p class="FHUndirskr" align="center">f.h.r.</p>
<p class="Undirritun" align="center"><strong>NAFN</strong><br/>{minister}.</p>
<p class="Undirritun" align="center"><strong>NAFN</strong></p>
<p class="Undirritun" align="right"><em>NAFN.</em></p>
` as HTMLText

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Based on libs/island-ui/core/src/lib/Input/Input.treat.ts
import { style } from '@vanilla-extract/css'
import { globalStyle, style } from '@vanilla-extract/css'
import { theme, helperStyles } from '@island.is/island-ui/theme'
import * as mixins from './EditorInput.mixins'
import omit from 'lodash/omit'
Expand Down Expand Up @@ -51,3 +51,7 @@ export const hasFocus = style({
[`&${container}`]: mixins.containerFocus,
},
})

globalStyle(`.tox-icon.tox-tbtn__icon-wrap`, {
color: '#217bb7',
})
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ export const formatAmendingRegTitle = (draft: RegDraftForm) => {
)} ${removeRegPrefix(item.regTitle)}`,
)

return PREFIX + [...amendingTitles, ...repealTitles].join(' og ')
return (
PREFIX +
[...amendingTitles, ...repealTitles].join(' og ').replace(/ +(?= )/g, '')
)
}

return PREFIX
Expand All @@ -62,9 +65,11 @@ export const formatAmendingRegBody = (
) => {
const regName = removeRegNamePrefix(name)
if (repeal) {
const text = `<p>Reglugerð nr. ${regName} ${
regTitle ? regTitle.replace(/\.$/, '') + ' ' : ''
}fellur brott.</p>` as HTMLText
const title = regTitle ? regTitle.replace(/^reglugerð\s*/i, '') + ' ' : ''
const text = `<p>Reglugerð nr. ${regName} ${title.replace(
/\.$/,
'',
)}fellur brott.</p>` as HTMLText
const gildistaka =
`<p>Reglugerð þessi er sett með heimild í [].</p><p>Reglugerðin öðlast þegar gildi</p>` as HTMLText
return [text, gildistaka]
Expand Down Expand Up @@ -123,7 +128,6 @@ export const formatAmendingRegBody = (
const textContent = clone.textContent?.trim() ?? ''

articleTitle = textContent
console.log(textContent)
} else {
articleTitle = element.innerText
}
Expand Down Expand Up @@ -244,11 +248,11 @@ export const formatAmendingRegBody = (
if (isArticleTitle) {
// Title was changed
pushHtml =
`<p>Fyrirsögn ${articleTitle} ${regNameDisplay} orðast svo:</p><p>${newText}</p>` as HTMLText
`<p>Fyrirsögn ${articleTitle} ${regNameDisplay} breytist og orðast svo:</p><p>${newText}</p>` as HTMLText
} else if (isParagraph) {
// Paragraph was changed
pushHtml =
`<p>${paragraph}. mgr. ${articleTitle} ${regNameDisplay} orðast svo:</p><p>${newText}</p>` as HTMLText
`<p>${paragraph}. mgr. ${articleTitle} ${regNameDisplay} breytist og orðast svo:</p><p>${newText}</p>` as HTMLText
} else if (isLetterList || isNumberList) {
// List was changed
pushHtml =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,18 @@ export const getDeletionOrAddition = (

// Retrieve the modified text content from the temporary element
const modifiedTextContent = tempElement?.textContent?.trim()
newText = modifiedTextContent ?? ''

// Remove gr number if there is some more text within the title
const modContent = modifiedTextContent ?? ''
const match = modContent.match(/^\d+\.\s*gr\.$/)
if (match) {
// If the string matches the pattern for "{num}. gr.", return it as is
newText = modContent
} else {
// If the string contains more text, extract the text after the pattern
const parts = modContent.split(/^\d+\.\s*gr\.\s*/)
newText = parts[1] ? parts[1] : modContent
}
} else {
newText = newTextElement.textContent || ''
}
Expand Down

0 comments on commit a72812f

Please sign in to comment.