Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(regulations-admin): Format amending and cancel, styles, signature #15344

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading