diff --git a/src/components/App.js b/src/components/App.js index abb6bf17d..4a2fb9c65 100644 --- a/src/components/App.js +++ b/src/components/App.js @@ -34,16 +34,20 @@ class App extends Component { componentDidMount(){ //Matomo analytic - let _paq = window._paq = window._paq || []; - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - let u="//matomo.hel.fi/"; - _paq.push(['setTrackerUrl', u+'matomo.php']); - _paq.push(['setSiteId', '74']); - let d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); - })(); + const currentEnv = process.env.REACT_APP_ENVIRONMENT + + if(currentEnv === 'production'){ + let _paq = window._paq = window._paq || []; + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + let u="//matomo.hel.fi/"; + _paq.push(['setTrackerUrl', u+'matomo.php']); + _paq.push(['setSiteId', '74']); + let d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); + })(); + } } componentDidUpdate(prevProps) { diff --git a/src/components/ProjectTimeline/helpers/createDeadlines.js b/src/components/ProjectTimeline/helpers/createDeadlines.js index 1ddcb8e17..182a506b5 100644 --- a/src/components/ProjectTimeline/helpers/createDeadlines.js +++ b/src/components/ProjectTimeline/helpers/createDeadlines.js @@ -152,11 +152,13 @@ function fillGaps(inputMonths, deadlines) { let deadlinePropAbbreviation = null let monthDateIndex = null const has = Object.prototype.hasOwnProperty + let has_endpoint_in_range = false; for (let i = 0; i < monthDates.length; i++) { for (const prop in monthDates[i]) { if (has.call(monthDates[i], prop)) { if (Object.keys(monthDates[i]).length < 4) { if (Array.isArray(monthDates[i][prop].deadline_type)) { + has_endpoint_in_range = true; if (monthDates[i][prop].deadline_type[0] === 'phase_start' || monthDates[i][prop].deadline_type[0] === 'past_start_point') { deadlineAbbreviation = monthDates[i][prop].abbreviation color_code = monthDates[i][prop].color_code @@ -212,6 +214,34 @@ function fillGaps(inputMonths, deadlines) { } } } + + // Special case: no phase start/endpoints are in visible range + if (!has_endpoint_in_range) { + let [min_year, min_month] = monthDates[0].date.split('-'); + min_month = min_month.length == 1 ? "0" + min_month : min_month; + let min_day = (((monthDates[0].week-1) * 7) +1).toString(); + min_day = min_day.length == 1 ? "0" + min_day : min_day; + const min_date = Date.parse([min_year, min_month, min_day].join('-')); + + let phase_color, abbr; + for (const dl of deadlines) { + if (dl.deadline?.deadline_types?.includes('phase_start')) { + phase_color = dl.deadline?.phase_color_code; + abbr = dl.deadline?.abbreviation + } + if (dl.date && Date.parse(dl.date) > min_date){ + break; + } + } + for (let i = 0; i < monthDates.length; i++) { + monthDates[i].midpoint = { + abbreviation: abbr, + deadline_type: ['mid_point'], + color_code: phase_color + } + } + } + return createMilestones(monthDates, deadlines) } /** diff --git a/src/components/input/Input.scss b/src/components/input/Input.scss index caa17ff5d..bd3de62c3 100644 --- a/src/components/input/Input.scss +++ b/src/components/input/Input.scss @@ -718,7 +718,7 @@ background-color: $color-fog-light; padding-bottom: 27.5px; .field{ - .text-input,.selection,.ad-combobox{ + .text-input:not(.rolling-info-container .text-input),.selection,.ad-combobox{ max-width: 256px; } } diff --git a/src/components/input/Link.js b/src/components/input/Link.js index f2dd19cd8..aae183f06 100644 --- a/src/components/input/Link.js +++ b/src/components/input/Link.js @@ -7,7 +7,19 @@ import { useTranslation } from 'react-i18next'; import RollingInfo from '../input/RollingInfo' const Link = props => { - const openLink = () => window.open(currentValue) + const openLink = () => { + try { + window.open(currentValue); + } + catch (e) { + if (currentValue.includes("pw://")){ + const encoded_URN = "pw://" + currentValue.split("pw://")[1].replace(":", "%3A"); + window.open(encoded_URN); + } else { + throw e; + } + } + } const {t} = useTranslation() diff --git a/src/components/projectCard/index.js b/src/components/projectCard/index.js index a6c90a3d1..086225169 100644 --- a/src/components/projectCard/index.js +++ b/src/components/projectCard/index.js @@ -129,17 +129,12 @@ function ProjectCardPage({ ) projectCardFields && projectCardFields.forEach(field => { - let value = projectUtils.findValueFromObject(projectData, field.name) + let value; + const returnValues = []; + projectUtils.findValuesFromObject(projectData, field.name, returnValues); - const returnValues = [] - projectUtils.findValuesFromObject(projectData, field.name, returnValues) - - if (returnValues.length > 1) { - let currentValues = [] - returnValues.forEach(current => { - currentValues.push(current) - }) - value = currentValues + if (returnValues.length > 0) { + value = returnValues.length === 1 ? returnValues[0] : returnValues; } let newField = {