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

update ministry names in code table, add news blurb, format news blurbs #3750

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions app/src/UI/Overlay/News/NewsPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@
border: 1px solid black;
}
}

.newsListItemContent > li:not(:last-child) {
margin-bottom: 1rem;
}

32 changes: 27 additions & 5 deletions app/src/UI/Overlay/News/NewsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import newsItems from './newsItems';
import './NewsPage.css';
import NewsArticle, { NewsSubject } from 'interfaces/NewsArticle';
Expand All @@ -9,6 +9,7 @@ const NewsPage = (props: any) => {
const BASE_SHOW = 5;
const [loadMore, setLoadMore] = useState<number>(BASE_SHOW);
const handleMore = () => setLoadMore((prev) => prev + BASE_SHOW);

const subjectToIcon = (subject: NewsSubject) => {
switch (subject) {
case NewsSubject.New:
Expand All @@ -32,6 +33,29 @@ const NewsPage = (props: any) => {
default:
}
};

const renderContentWithLinks = (content: string) => {
const urlRegex = /(https?:\/\/[^\s]+)/g;
const parts = content.split(urlRegex);

return parts.map((part, index) => {
if (urlRegex.test(part)) {
return (
<a
key={index}
href={part}
target="_blank"
rel="noopener noreferrer"
style={{ color: '#007bff', textDecoration: 'none' }}
>
{part}
</a>
);
}
return <span key={index}>{part}</span>;
});
};

return (
<div id="newsPageContainer">
<h2 id="newsPageHeader">What's New in InvasivesBC?</h2>
Expand All @@ -46,11 +70,9 @@ const NewsPage = (props: any) => {
Posted:{' '}
<time dateTime={newsItem.date.toLocaleDateString()}>{newsItem.date.toLocaleDateString()}</time>
</p>
<ul>
<ul className="newsListItemContent">
{newsItem.content.map((content: string) => (
<li className="newsListItemContent" key={content}>
{content}
</li>
<li key={content}>{renderContentWithLinks(content)}</li>
))}
</ul>
</div>
Expand Down
13 changes: 7 additions & 6 deletions app/src/UI/Overlay/News/newsItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import NewsArticle, { NewsSubject } from 'interfaces/NewsArticle';
* Array sorts by date to keep things chronological.
*/
const newsItems: NewsArticle[] = [
/*
{
title: '',
date: new Date(),
content: [],
subject: NewsSubject.
title: 'Updated Ministry names',
date: new Date('December 13, 2024'),
content: [
'We have updated the descriptions of certain ministry names in our system to align with recent changes in government nomenclature. While the underlying codes remain unchanged, the descriptions displayed in relevant contexts have been revised to reflect the updated ministry names accurately. This ensures that our system stays current and consistent with official terminology.',
'Ministry names can be found here: https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries'
],
subject: NewsSubject.Update
},
*/
{
title: 'Layer Picker Update',
date: new Date('October 24, 2024'),
Expand Down
196 changes: 196 additions & 0 deletions database/src/migrations/0032_update_ministry_names.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { Knex } from 'knex';

export async function up(knex: Knex) {
await knex.raw(
//language=PostgreSQL
`
-- update jurisdiction code descriptions
update
invasivesbc.code
set
code_description = case
when code_name = 'LWRS' then 'Ministry of Water Land and Resource Stewardship'
when code_name = 'MOE' then 'Ministry of Environment and Parks'
when code_name = 'MOTI' then 'Ministry of Transportation and Transit'
else code_description
end
where
code_header_id = 45
and code_name in ('LWRS', 'MOE', 'MOTI');


-- delete a funding agency, add two funding agencies, update funding agency descriptions
delete from invasivesbc.code where code_header_id = 44 and code_name = 'EMLCI';

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(44, 'MMCM', 'BC Ministry of Mining and Critical Minerals', 1, now(), null, now(), now(), 1, 1);

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(44, 'MECS', 'BC Ministry of Energy and Climate Solutions', 1, now(), null, now(), now(), 1, 1);

update
invasivesbc.code
set
code_description = case
when code_name = 'EDU' then 'BC Ministry of Education and Child Care'
when code_name = 'JERI' then 'BC Ministry of Jobs Economic Development and Innovation'
when code_name = 'LWRS' then 'BC Ministry of Water Land and Resource Stewardship'
when code_name = 'MOE' then 'BC Ministry of Environment and Parks'
when code_name = 'MOTI' then 'BC Ministry of Transportation and Transit'
else code_description
end
where
code_header_id = 44
and code_name in ('EDU', 'JERI', 'LWRS', 'MOE', 'MOTI');


-- delete an employer, add two employers, update employer descriptions
delete from invasivesbc.code where code_header_id = 79 and code_name = 'EMLCI';

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(79, 'MMCM', 'BC Ministry of Mining and Critical Minerals', 1, now(), null, now(), now(), 1, 1);

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(79, 'MECS', 'BC Ministry of Energy and Climate Solutions', 1, now(), null, now(), now(), 1, 1);

update
invasivesbc.code
set
code_description = case
when code_name = 'AEST' then 'BC Ministry of Post-Secondary Education and Future Skills'
when code_name = 'EDU' then 'BC Ministry of Education and Child Care'
when code_name = 'JERI' then 'BC Ministry of Jobs Economic Development and Innovation'
when code_name = 'LWRS' then 'BC Ministry of Water Land and Resource Stewardship'
when code_name = 'MOE' then 'BC Ministry of Environment and Parks'
when code_name = 'MOTI' then 'BC Ministry of Transportation and Transit'
when code_name = 'MUNI' then 'BC Ministry of Housing and Municipal Affairs'
when code_name = 'PSSG' then 'BC Ministry of Public Safety and Solicitor General'
else code_description
end
where
code_header_id = 79
and code_name in ('AEST', 'EDU', 'JERI', 'LWRS', 'MOE', 'MOTI', 'MUNI', 'PSSG');


-- re-sort jurisdictions, funding agencies, and employers
update
invasivesbc.code as c
set
code_sort_order = subquery.row_number
from
(
select
code_id,
row_number() over (partition by code_header_id
order by
code_header_id,
code_description) as row_number
from
invasivesbc.code
where
code_header_id in (44, 45, 79)
) as subquery
where
c.code_id = subquery.code_id
and code_header_id in (44, 45, 79);
`
);
}

export async function down(knex: Knex) {
//language=PostgreSQL
await knex.raw(
`
-- update jurisdiction code descriptions
update
invasivesbc.code
set
code_description = case
when code_name = 'LWRS' then 'Ministry of Land Water Resource Stewardship'
when code_name = 'MOE' then 'Ministry of Environment & Climate Change Strategy'
when code_name = 'MOTI' then 'Ministry of Transportation and Infrastructure'
else code_description
end
where
code_header_id = 45
and code_name in ('LWRS', 'MOE', 'MOTI');


-- delete a funding agency, add two funding agencies, update funding agency descriptions
delete from invasivesbc.code where code_header_id = 44 and code_name in ('MMCM', 'MECS');

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(44, 'EMLCI', 'BC Ministry of Energy Mines and Low Carbon Innovation', 1, now(), null, now(), now(), 1, 1);

update
invasivesbc.code
set
code_description = case
when code_name = 'EDU' then 'BC Ministry of Education'
when code_name = 'JERI' then 'BC Ministry of Jobs Economic Recovery and Innovation'
when code_name = 'LWRS' then 'BC Ministry of Land Water Resource Stewardship'
when code_name = 'MOE' then 'BC Ministry of Environment & Climate Change Strategy'
when code_name = 'MOTI' then 'BC Ministry of Transportation & Infrastructure'
else code_description
end
where
code_header_id = 44
and code_name in ('EDU', 'JERI', 'LWRS', 'MOE', 'MOTI');


-- delete an employer, add two employers, update employer descriptions
delete from invasivesbc.code where code_header_id = 79 and code_name in ('MMCM', 'MECS');

INSERT INTO invasivesbc.code
(code_header_id, code_name, code_description, code_sort_order, valid_from, valid_to, created_at, updated_at, created_by_user_id, updated_by_user_id)
VALUES(79, 'EMLCI', 'BC Ministry of Energy Mines and Low Carbon Innovation', 1, now(), null, now(), now(), 1, 1);

update
invasivesbc.code
set
code_description = case
when code_name = 'AEST' then 'BC Ministry of Advanced Education and Skills Training'
when code_name = 'EDU' then 'BC Ministry of Education'
when code_name = 'JERI' then 'BC Ministry of Jobs Economic Recovery and Innovation'
when code_name = 'LWRS' then 'BC Ministry of Land Water and Resource Stewardship'
when code_name = 'MOE' then 'BC Ministry of Environment & Climate Change Strategy'
when code_name = 'MOTI' then 'BC Ministry of Transportation & Infrastructure'
when code_name = 'MUNI' then 'BC Ministry of Municipal Affairs'
when code_name = 'PSSG' then 'BC Ministry of Public Safety & Solicitor General & Emergency B.C.'
else code_description
end
where
code_header_id = 79
and code_name in ('AEST', 'EDU', 'JERI', 'LWRS', 'MOE', 'MOTI', 'MUNI', 'PSSG');


-- re-sort jurisdictions, funding agencies, and employers
update
invasivesbc.code as c
set
code_sort_order = subquery.row_number
from
(
select
code_id,
row_number() over (partition by code_header_id
order by
code_header_id,
code_description) as row_number
from
invasivesbc.code
where
code_header_id in (44, 45, 79)
) as subquery
where
c.code_id = subquery.code_id
and code_header_id in (44, 45, 79);

`
);
}
Loading