Skip to content

Commit

Permalink
Bringing develop changes to city-theme branch (#4)
Browse files Browse the repository at this point in the history
* Fix double encoding City-of-Helsinki#524; with caveat axios/axios#2563

* Display all api results in react select components

* Fix event publisher field name for user rights check

* Fix City-of-Helsinki#530

* Do not try to update deleted subevents

* Do not try to edit past subevents

* Refactor editability check; allow deleting and canceling series that contain deleted, canceled or past subevents

* Remove unnecessary inlined sub_events at cancel to prevent API errors

* Add instructions for internet events

* Update snapshots

* Add remote participation keyword to all internet events

* Add notification about online events to cancel confirmation dialog

* Add postpone button and badge

* Mention postponing in cancel extra text

* Add postpone button to editor too

* Show postponed events in search instead of crashing

* Update user rights managers

* Add missing </p>

* Do not remove subevents at cancel after all; deleted items removed by API PR City-of-Helsinki/linkedevents#407

* Fix removed future time validation; fixes City-of-Helsinki#536, City-of-Helsinki#528

* Update snapshots

Co-authored-by: Riku Oja <[email protected]>
Co-authored-by: Aleksi Salonen <[email protected]>
Co-authored-by: Riku Oja <[email protected]>
Co-authored-by: aceViilee <[email protected]>
  • Loading branch information
5 people committed Apr 30, 2020
1 parent 1684c55 commit 3b8fa5c
Show file tree
Hide file tree
Showing 23 changed files with 185 additions and 59 deletions.
9 changes: 7 additions & 2 deletions src/components/EventActionButton/EventActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {confirmAction} from '../../actions/app'
import {getButtonLabel} from '../../utils/helpers'
import {Link} from 'react-router-dom'

const {PUBLICATION_STATUS, USER_TYPE} = constants
const {PUBLICATION_STATUS, EVENT_STATUS, USER_TYPE} = constants

/**
* Returns whether the button is a save button based on given action
Expand Down Expand Up @@ -71,9 +71,10 @@ const EventActionButton = (props) => {
const isRegularUser = get(user, 'userType') === USER_TYPE.REGULAR
const formHasSubEvents = get(editor, ['values', 'sub_events'], []).length > 0
const isDraft = get(event, 'publication_status') === PUBLICATION_STATUS.DRAFT
const isPostponed = get(event, 'event_status') === EVENT_STATUS.POSTPONED
const {editable, explanationId} = checkEventEditability(user, event, action, editor)
const showTermsCheckbox = isRegularUser && isSaveButton(action) && !isDraft
const disabled = !editable || loading || (showTermsCheckbox && !agreedToTerms)
let disabled = !editable || loading || (showTermsCheckbox && !agreedToTerms)

let color = 'default'
const buttonLabel = customButtonLabel || getButtonLabel(action, isRegularUser, isDraft, eventIsPublished, formHasSubEvents)
Expand All @@ -85,6 +86,10 @@ const EventActionButton = (props) => {
color = 'secondary'
}

if (action === 'postpone' && isPostponed) {
disabled = true
}

const button =
<React.Fragment>
{showTermsCheckbox &&
Expand Down
15 changes: 9 additions & 6 deletions src/components/EventGrid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import PropTypes from 'prop-types'
import {FormattedMessage} from 'react-intl'
import get from 'lodash/get'
import forEach from 'lodash/forEach'
import {getBadge} from '../../utils/helpers'

import defaultThumbnail from '../../assets/images/helsinki-coat-of-arms-white.png'

Expand Down Expand Up @@ -68,18 +69,20 @@ const EventItem = (props) => {
backgroundImage: 'url(' + image + ')',
}
const getDay = props.event.start_time
const date = getDay.split('T')
const convertedDate = date[0].split('-').reverse().join('.')
let convertedDate = ''
if (getDay) {
const date = getDay.split('T')
convertedDate = date[0].split('-').reverse().join('.')
}
const isCancelled = props.event.event_status === constants.EVENT_STATUS.CANCELLED
const isPostponed = props.event.event_status === constants.EVENT_STATUS.POSTPONED

return (
<div className="col-xs-12 col-md-6 col-lg-4" key={props.event['id']}>
<Link to={url}>
<div className="event-item">
{
isCancelled &&
<span className="badge badge-danger search-badge"><FormattedMessage id="cancelled"/></span>
}
{isCancelled && getBadge('cancelled')}
{isPostponed && getBadge('postponed')}
<div className="thumbnail" style={thumbnailStyle}/>
<div className="name">
<span className="converted-day">{convertedDate}</span>
Expand Down
2 changes: 2 additions & 0 deletions src/components/EventTable/CellTypes/NameCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const NameCell = props => {
const {event, nestLevel, isSuperEvent, superEventType, hasSubEvents, showSubEvents, toggleSubEvent} = props
const draft = event.publication_status === constants.PUBLICATION_STATUS.DRAFT
const cancelled = event.event_status === constants.EVENT_STATUS.CANCELLED
const postponed = event.event_status === constants.EVENT_STATUS.POSTPONED
const name = getEventName(event)
const indentationStyle = {
paddingLeft: `${nestLevel * 24}px`,
Expand All @@ -28,6 +29,7 @@ const NameCell = props => {
{showSubEvents ? <KeyboardArrowDown /> : <KeyboardArrowRight />}
</span>
}
{postponed && getBadge('postponed')}
{cancelled && getBadge('cancelled')}
{draft && getBadge('draft')}
{isSuperEvent && superEventType === constants.SUPER_EVENT_TYPE_UMBRELLA &&
Expand Down
1 change: 1 addition & 0 deletions src/components/FormFields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ class FormFields extends React.Component {
<SideField>
<div className="tip">
<p><FormattedMessage id="editor-tip-location"/></p>
<p><strong><FormattedMessage id="editor-tip-location-internet"/></strong></p>
<p><FormattedMessage id="editor-tip-location-extra"/></p>
<p><FormattedMessage id="editor-tip-location-not-found"/></p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,20 @@ const HelKeywordSelector = ({intl, editor, setDirtyState, setData}) => {
const {values, keywordSets, validationErrors} = editor
const keywords = get(values, 'keywords', [])
const mainCategoryOptions = mapKeywordSetToForm(keywordSets, 'helsinki:topics')
// Internet location automatically implies "remote participation"
const remoteParticipationKeyword = mainCategoryOptions.find(keyword => keyword['value'].includes('yso:p26626'))
if (remoteParticipationKeyword
&& values['location']
&& values['location']['id'] == 'helsinki:internet'
&& !keywords.find(keyword => keyword['value'].includes('yso:p26626'))) {
keywords.push(remoteParticipationKeyword)
}

return (
<React.Fragment>
<HelLabeledCheckboxGroup
groupLabel={<FormattedMessage id="main-categories"/>}
selectedValues={values['keywords']}
selectedValues={keywords}
name="keywords"
validationErrors={validationErrors['keywords']}
itemClassName="col-md-12 col-lg-6"
Expand Down
7 changes: 6 additions & 1 deletion src/components/HelFormFields/HelSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ const HelSelect = ({
</React.Fragment>
)

const filterOptions = (candidate, input) => {
// no need to filter data returned by the api, text filter might have matched to non-displayed fields
return true
}

return (
<React.Fragment>
<legend ref={labelRef}>
Expand All @@ -160,7 +165,7 @@ const HelSelect = ({
placeholder={intl.formatMessage({id: placeholderId})}
loadingMessage={() => intl.formatMessage({id: 'loading'})}
noOptionsMessage={() => intl.formatMessage({id: 'search-no-results'})}
filterOption={createFilter({ignoreAccents: false})}
filterOption={filterOptions}
formatOptionLabel={formatOption}
styles={HelSelectStyles}
theme={HelSelectTheme}
Expand Down
13 changes: 11 additions & 2 deletions src/components/ImagePicker/__snapshots__/ImagePicker.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ exports[`Image add form ImagePicker component should render correctly with data
"confirm": "Suorita",
"confirm-action-header": "Varmista toiminto",
"confirm-cancel": "Varmista tapahtuman peruminen",
"confirm-cancel-extra": "Muistathan, että perumisen sijaan voit myös järjestää tapahtuman etänä internetissä. Valitse tällöin muokkauslomakkeella tapahtumapaikaksi Internet. Voit myös lykätä tapahtuman tulevaisuuteen.",
"confirm-delete": "Varmista tapahtuman poistaminen",
"confirm-delete-draft": "Varmista luonnoksen poistaminen",
"confirm-image-delete": "Varmista kuvan poistaminen",
"confirm-postpone": "Varmista tapahtuman lykkääminen",
"confirm-postpone-draft": "Varmista luonnostapahtuman lykkääminen",
"confirm-publish": "Varmista tapahtuman julkaiseminen",
"confirm-publish-draft": "Varmista luonnoksen julkaiseminen",
"confirm-update": "Varmista tapahtuman tallentaminen",
Expand All @@ -52,11 +55,13 @@ exports[`Image add form ImagePicker component should render correctly with data
"edit-selected-image": "Muokkaa valittua kuvaa",
"editor-authorization-required": "Jos haluat julkaista tapahtuman, kirjaudu ensin sisään.",
"editor-cancel-extra-warning": "Seuraavat tapahtumat peruutetaan:",
"editor-cancel-warning": "VAROITUS: Tämä toiminto peruuttaa tapahtuman. Voit myös poistaa sellaisen tapahtuman, jonka syötit vahingossa.",
"editor-cancel-warning": "VAROITUS: Tämä toiminto peruuttaa tapahtuman. Voit myös lykätä tapahtuman tulevaisuuteen, tai poistaa sellaisen tapahtuman, jonka syötit vahingossa.",
"editor-delete-draft-extra-warning": "Seuraavat tapahtumat poistetaan:",
"editor-delete-draft-warning": "VAROITUS: Tämä toiminto poistaa tapahtuman lopullisesti. Voit tarvittaessa myös pyytää, että tapahtumaehdotuksen tekijä muokkaa ilmoitustaan.",
"editor-delete-extra-warning": "Seuraavat tapahtumat poistetaan:",
"editor-delete-warning": "VAROITUS: Tämä toiminto poistaa tapahtuman lopullisesti. Voit tarvittaessa myös perua tapahtuman tai lykätä sitä.",
"editor-postpone-extra-warning": "Seuraavat tapahtumat lykätään:",
"editor-postpone-warning": "VAROITUS: Tämä toiminto lykkää tapahtuman tulevaisuuteen. Lykättyäsi voit myöhemmin syöttää tapahtumalle uuden ajankohdan.",
"editor-publish-draft-extra-warning": "Seuraavat tapahtumat julkaistaan:",
"editor-publish-draft-warning": "HUOM. Tämä toiminto julkaisee tapahtuman Internetiin. Tapahtumaehdotuksen alkuperäinen tekijä ei voi enää muokata tapahtumaa.",
"editor-sentinel-alert": "Voit katsella lomaketta, mutta sinulla ei ole oikeuksia julkaista tai muokata tapahtumia. Et ole kirjautunut sisään tai kirjautumisesi on vanhentunut.",
Expand All @@ -66,6 +71,7 @@ exports[`Image add form ImagePicker component should render correctly with data
"editor-tip-keywords": "Liitä tapahtumaan vähintään yksi asiasana, joka kuvaa tapahtuman teemaa. Aloita kirjoittamaan asiasanaa ja valitse lisättävä asiasana alle ilmestyvästä listasta.",
"editor-tip-location": "Kirjoita kenttään tapahtumapaikan nimi tai katuosoite ja valitse oikea paikka listasta.",
"editor-tip-location-extra": "Jos tapahtumapaikka löytyy listasta, sen sijaintia ei tarvitse kuvailla erikseen. Voit kuitenkin antaa lisätietoja tapahtumapaikan löytämiseksi, esimerkiksi kerrosnumeron tai luokkahuoneen nimen.",
"editor-tip-location-internet": "Jos tapahtuma järjestetään vain etänä internetissä, valitse tapahtumapaikaksi Internet. Tapahtuman URL-osoite laitetaan kotisivu-kenttään ja/tai tapahtuma sosiaalisessa mediassa -kenttiin.",
"editor-tip-location-not-found": "Jos tarkkaa tapahtumapaikkaa ei löydy listasta, valitse tapahtumapaikaksi lähin katuosoite ja kirjoita paikan nimi tai muut tarkemmat saapumisohjeet tiiviisti lisätietokenttään.",
"editor-tip-price": "Merkitse onko tapahtuma maksuton. Syötä maksulliselle tapahtumalle hinta muodossa \\"5€\\".",
"editor-tip-price-multi": "Jos tapahtumalla on useita hintoja, klikkaa Lisää uusi hintatieto ja merkitse kunkin hintaryhmän nimi (esim. Lapset) Hintatietojen kuvaus -kenttään.",
Expand Down Expand Up @@ -225,6 +231,8 @@ exports[`Image add form ImagePicker component should render correctly with data
"photographer": "Kuvaaja",
"pick-time-range": "Etsi vain ajalta",
"play-date-label": "Toistopäivät",
"postpone-events": "Lykkää tapahtumaa",
"postponed": "Lykätty",
"publish-events": "Julkaise tapahtuma",
"publish-events-multi": "Julkaise tapahtumat",
"ready": "Valmis",
Expand Down Expand Up @@ -282,10 +290,11 @@ exports[`Image add form ImagePicker component should render correctly with data
"validation-atLeastOneIsTrue": "Valitse vähintään yksi toistopäivä",
"validation-atLeastOneMainCategory": "Valitse vähintään yksi pääkategoria",
"validation-daysWithinInterval": "Yksi tai useampi valituista päivistä ei esiinny toistovälillä",
"validation-defaultEndInTheFuture": "Alkamisajan pitää olla tulevaisuudessa, jos päättymisaikaa ei tunneta",
"validation-error": "Lomakkeessa on virheitä. Tarkasta lomake.",
"validation-error-goto-error": "Siirry virheeseen",
"validation-hasPrice": "Hintatietoja puuttuu",
"validation-inTheFuture": "Tapahtuman pitää olla tulevaisuudessa",
"validation-inTheFuture": "Päättymisajan pitää olla tulevaisuudessa",
"validation-isDate": "Kirjoita päivämäärä muodossa pp.kk.vvvv hh.mm",
"validation-isInt": "Tulon on oltava numero",
"validation-isMoreThanOne": "Toistovälin tulee olla vähintään 1 viikko",
Expand Down
6 changes: 6 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
"confirm-delete": "Delete event",
"confirm-delete-draft": "Delete draft",
"confirm-cancel": "Cancel event",
"confirm-cancel-extra": "Instead of canceling, you may also organize the event online on the internet. In such a case, edit the event and pick the location Internet in the location menu. You may also postpone the event.",
"confirm-publish": "Publish event",
"confirm-publish-draft": "Publish draft",
"confirm-postpone": "Postpone event",
"confirm-postpone-draft": "Postpone draft",
"delete": "Delete",
"confirm": "Confirm",
"draft": "Draft",
"postponed": "Postponed",
"cancelled": "Cancelled",
"series": "Series",
"umbrella": "Umbrella",
Expand Down Expand Up @@ -191,6 +195,7 @@
"validation-requiredAtId": "This field is required",
"validation-requiredString": "This field is required",
"validation-requiredStringForCourses": "This field is required",
"validation-defaultEndInTheFuture": "The start time must be in the future if end time is not specified",
"validation-afterStartTime": "The end time must be later than start time",
"validation-afterStartTimeAndInFuture": "The end time must be in the future and later than the start time",
"validation-afterEnrolmentStartTime": "The end time must be later than start time",
Expand Down Expand Up @@ -277,6 +282,7 @@
"editor-tip-time-multi": "If the event is held more than once, you can add new times to the event. If the event repeats regularly, you can add all times at once by selecting Recurring event.",
"editor-tip-time-delete": "To delete an extra time, select the trash bin next to the time.",
"editor-tip-location": "Start typing the beginning of the name of the venue and then choose the correct place from the emerging list.",
"editor-tip-location-internet": "If the event is strictly online on the internet, pick Internet as the location. The URL of the event should be filled in the event home page field and/or the social media URL fields.",
"editor-tip-location-extra": "If an event location is found in the list, the address and location doesn't need not be described more closely. However, you can add more information to find the event, such as a floor number or other more accurate location.",
"editor-tip-location-not-found": "If you can not find a venue from the list, choose Helsinki as your venue and enter a more detailed place or address in the additional information box.",
"editor-tip-price": "Check if the event is free of charge. If there is a fee enter it like \"5€\".",
Expand Down
14 changes: 12 additions & 2 deletions src/i18n/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"update-events": "Tallenna",
"delete-events": "Poista tapahtuma",
"cancel-events": "Peruuta tapahtuma",
"postpone-events": "Lykkää tapahtumaa",
"publish-events": "Julkaise tapahtuma",
"delete-events-multi": "Poista tapahtumat",
"publish-events-multi": "Julkaise tapahtumat",
Expand All @@ -31,11 +32,15 @@
"confirm-delete": "Varmista tapahtuman poistaminen",
"confirm-delete-draft": "Varmista luonnoksen poistaminen",
"confirm-cancel": "Varmista tapahtuman peruminen",
"confirm-cancel-extra": "Muistathan, että perumisen sijaan voit myös järjestää tapahtuman etänä internetissä. Valitse tällöin muokkauslomakkeella tapahtumapaikaksi Internet. Voit myös lykätä tapahtuman tulevaisuuteen.",
"confirm-publish": "Varmista tapahtuman julkaiseminen",
"confirm-publish-draft": "Varmista luonnoksen julkaiseminen",
"confirm-postpone": "Varmista tapahtuman lykkääminen",
"confirm-postpone-draft": "Varmista luonnostapahtuman lykkääminen",
"delete": "Poista",
"confirm": "Suorita",
"draft": "Luonnos",
"postponed": "Lykätty",
"cancelled": "Peruutettu",
"series": "Sarja",
"umbrella": "Kattotapahtuma",
Expand Down Expand Up @@ -194,7 +199,8 @@
"validation-afterStartTime": "Päättymisajan pitää olla alkamisaikaa myöhemmin",
"validation-afterStartTimeAndInFuture": "Päättymisajan pitää olla tulevaisuudessa ja alkamisaikaa myöhemmin",
"validation-afterEnrolmentStartTime": "Päättymisajan pitää olla alkamisaikaa myöhemmin",
"validation-inTheFuture": "Tapahtuman pitää olla tulevaisuudessa",
"validation-defaultEndInTheFuture": "Alkamisajan pitää olla tulevaisuudessa, jos päättymisaikaa ei tunneta",
"validation-inTheFuture": "Päättymisajan pitää olla tulevaisuudessa",
"validation-stringLimitReached": "Tämä kenttä voi olla korkeintaan {limit} merkkiä pitkä",
"validation-stringLengthCounter": "{counter} merkkiä jäljellä",
"validation-longStringLengthCounter": " merkkiä käytetty",
Expand Down Expand Up @@ -261,9 +267,12 @@
"editor-update-draft-extra-warning": "Tiedot tallennetaan seuraaviin tapahtumiin:",
"editor-update-draft-draft-extra-warning": "Tiedot tallennetaan seuraaviin tapahtumiin:",

"editor-cancel-warning": "VAROITUS: Tämä toiminto peruuttaa tapahtuman. Voit myös poistaa sellaisen tapahtuman, jonka syötit vahingossa.",
"editor-cancel-warning": "VAROITUS: Tämä toiminto peruuttaa tapahtuman. Voit myös lykätä tapahtuman tulevaisuuteen, tai poistaa sellaisen tapahtuman, jonka syötit vahingossa.",
"editor-cancel-extra-warning": "Seuraavat tapahtumat peruutetaan:",

"editor-postpone-warning": "VAROITUS: Tämä toiminto lykkää tapahtuman tulevaisuuteen. Lykättyäsi voit myöhemmin syöttää tapahtumalle uuden ajankohdan.",
"editor-postpone-extra-warning": "Seuraavat tapahtumat lykätään:",

"editor-delete-warning": "VAROITUS: Tämä toiminto poistaa tapahtuman lopullisesti. Voit tarvittaessa myös perua tapahtuman tai lykätä sitä.",
"editor-delete-extra-warning": "Seuraavat tapahtumat poistetaan:",
"editor-delete-draft-warning": "VAROITUS: Tämä toiminto poistaa tapahtuman lopullisesti. Voit tarvittaessa myös pyytää, että tapahtumaehdotuksen tekijä muokkaa ilmoitustaan.",
Expand All @@ -277,6 +286,7 @@
"editor-tip-time-multi": "Jos tapahtuma järjestetään useamman kerran, voit lisätä tapahtumalle uusia ajankohtia. Jos tapahtuma toistuu säännöllisesti, voit lisätä kaikki ajankohdat kerralla valitsemalla Toistuva tapahtuma.",
"editor-tip-time-delete": "Ylimääräisen ajankohdan voit poistaa valitsemalla ajankohdan vieressä olevan roskakorisymbolin.",
"editor-tip-location": "Kirjoita kenttään tapahtumapaikan nimi tai katuosoite ja valitse oikea paikka listasta.",
"editor-tip-location-internet": "Jos tapahtuma järjestetään vain etänä internetissä, valitse tapahtumapaikaksi Internet. Tapahtuman URL-osoite laitetaan kotisivu-kenttään ja/tai tapahtuma sosiaalisessa mediassa -kenttiin.",
"editor-tip-location-extra": "Jos tapahtumapaikka löytyy listasta, sen sijaintia ei tarvitse kuvailla erikseen. Voit kuitenkin antaa lisätietoja tapahtumapaikan löytämiseksi, esimerkiksi kerrosnumeron tai luokkahuoneen nimen.",
"editor-tip-location-not-found": "Jos tarkkaa tapahtumapaikkaa ei löydy listasta, valitse tapahtumapaikaksi lähin katuosoite ja kirjoita paikan nimi tai muut tarkemmat saapumisohjeet tiiviisti lisätietokenttään.",
"editor-tip-price": "Merkitse onko tapahtuma maksuton. Syötä maksulliselle tapahtumalle hinta muodossa \"5€\".",
Expand Down
Loading

0 comments on commit 3b8fa5c

Please sign in to comment.