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

feat(regulations-admin): ministry basic + bugfixes #16042

Merged
merged 6 commits into from
Sep 18, 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 @@ -76,6 +76,7 @@ export class RegulationDocumentsController {
comments: draftRegulation.comments,
name: draftRegulation.name,
publishedDate: draftRegulation.idealPublishDate,
ministry: draftRegulation.ministry,
}

const documentResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import {
Button,
AlertMessage,
AlertBanner,
Select,
} from '@island.is/island-ui/core'
import { EditorInput } from './EditorInput'
import { editorMsgs as msg, errorMsgs } from '../lib/messages'
import { editorMsgs as msg, errorMsgs, m } from '../lib/messages'
import { useLocale } from '@island.is/localization'
import { Appendixes } from './Appendixes'
import { MagicTextarea } from './MagicTextarea'
Expand All @@ -32,7 +33,7 @@ const updateText =

export const EditBasics = () => {
const t = useLocale().formatMessage
const { draft, actions } = useDraftingState()
const { draft, actions, ministries } = useDraftingState()
const [editorKey, setEditorKey] = useState('initial')
const [titleError, setTitleError] = useState<string | undefined>(undefined)
const [hasUpdated, setHasUpdated] = useState<boolean>(false)
Expand Down Expand Up @@ -162,13 +163,15 @@ export const EditBasics = () => {
label={t(msg.text)}
startExpanded={startTextExpanded}
>
<Box marginBottom={3}>
<AlertBanner
description={t(msg.diffPrecisionWarning)}
variant="info"
dismissable
/>
</Box>
{draft.type.value === RegulationDraftTypes.amending ? (
<Box marginBottom={3}>
<AlertBanner
description={t(msg.diffPrecisionWarning)}
variant="info"
dismissable
/>
</Box>
) : undefined}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
<Box marginBottom={3}>
<EditorInput
key={editorKey} // Force re-render of TinyMCE
Expand Down Expand Up @@ -224,7 +227,7 @@ export const EditBasics = () => {
<Divider />
{' '}
</Box>
{draft.signedDocumentUrl.value && (
{draft.signedDocumentUrl.value ? (
<Box marginBottom={[4, 4, 6]}>
<EditorInput
label={t(msg.signatureText)}
Expand All @@ -234,6 +237,38 @@ export const EditBasics = () => {
readOnly
/>
</Box>
) : (
ministries.length > 0 &&
!draft.signatureText.value && (
<Select
size="sm"
label={t(m.regulationAdminMinistries)}
name="setMinistry"
isSearchable
value={
draft.ministry.value
? {
value: draft.ministry.value,
label: draft.ministry.value,
}
: undefined
}
placeholder={t(msg.selectMinistry)}
options={[
{
label: t(msg.selectMinistry),
value: '',
},
...ministries.map((ministry) => ({
value: ministry.name,
label: ministry.name,
})),
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
].filter((item) => item.label)}
required={false}
onChange={(option) => actions.setMinistry(option?.value)}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
backgroundColor="white"
/>
)
)}
</AccordionItem>
</Accordion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export const EditSignature = () => {
draftId={draft.id}
value={
draft.signatureText.value ||
getDefaultSignatureText(formatDateFns)
getDefaultSignatureText(formatDateFns, draft.ministry.value)
}
onChange={(text) => updateState('signatureText', text)}
required={!!draft.signatureText.required}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ export const EditCancellation = (props: EditCancellationProp) => {
<ImpactModalTitle
impact={activeCancellation}
name={activeCancellation.name}
title={activeCancellation.regTitle}
title={
activeCancellation.name === 'self'
? 'stofnreglugerð'
: activeCancellation.regTitle
}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
type={'cancel'}
minDate={minDate}
tag={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,11 @@ export const EditChange = (props: EditChangeProp) => {
>
<ImpactModalTitle
type="edit"
title={activeChange.regTitle}
title={
activeChange.name === 'self'
? 'stofnreglugerð'
: activeChange.regTitle
}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
name={activeChange.name}
impact={activeChange}
minDate={readOnly ? activeChange.date.value : minDate}
Expand Down
4 changes: 4 additions & 0 deletions libs/portals/admin/regulations-admin/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ export const editorMsgs = defineMessages({
defaultMessage:
'Vakin er athygli á því að kerfið útbýr tillögu að breytingareglugerð sem starfsmaður þarf að rýna gaumgæfilega áður en haldið er áfram. Ekki er öruggt að inngangsliðir og efnisákvæði færist réttilega inn í breytingareglugerðina.',
},
selectMinistry: {
id: 'ap.regulations-admin:select-ministry',
defaultMessage: 'Veldu ráðuneyti',
},
})

export const impactMsgs = defineMessages({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export const actionHandlers: {
}
},

SET_MINISTRY: (state, { value }) => {
updateFieldValue(state.draft.ministry, value || undefined)
},

SET_IMPACT: (state, { impactId }) => {
if (impactId) {
Object.entries(state.draft.impacts).forEach(([key, impacts]) => {
Expand Down
4 changes: 4 additions & 0 deletions libs/portals/admin/regulations-admin/src/state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,10 @@ export type Action =
action?: 'add' | 'delete'
value: LawChapterSlug
}
| {
type: 'SET_MINISTRY'
value?: PlainText
}
thordurhhh marked this conversation as resolved.
Show resolved Hide resolved
| ({
type: 'UPDATE_PROP'
} & FieldNameValuePair)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ReactNode,
} from 'react'
import { useMutation, gql } from '@apollo/client'
import { LawChapterSlug, toISODate } from '@island.is/regulations'
import { LawChapterSlug, PlainText, toISODate } from '@island.is/regulations'
import { useNavigate } from 'react-router-dom'
import { RegulationDraftTypes, Step, StepNames } from '../types'
import { useLocale } from '@island.is/localization'
Expand Down Expand Up @@ -252,6 +252,10 @@ const useMakeDraftingState = (inputs: StateInputs) => {
dispatch({ type: 'APPENDIX_ADD' })
},

setMinistry: (value?: PlainText) => {
dispatch({ type: 'SET_MINISTRY', value })
},

updateLawChapterProp: (
action: 'add' | 'delete',
value: LawChapterSlug,
Expand Down
1 change: 1 addition & 0 deletions libs/regulations/src/lib/types-admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ export type RegulationPdfInput = {
comments: HTMLText
name?: RegName
publishedDate?: ISODate
ministry?: string
}

/** API response from regulation API */
Expand Down
Loading