generated from eea/volto-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: Remove volto-slate patch normalizeExternalData.js - requires Volto 16.28.1+ * Allow hit Enter in the LayoutSettings block to create a new block * fix(edit): Add a fix for the /edit crash when coming from login screen (#204) * fix(footer): don't crash if contact_extra_actions is not available in portal_actions (#206) * fix(event): Fix event date format in EventDatesInfo - refs #265911 (#208) * fix: use correct date format in EventDatesInfo - refs #265911 * fix(event): add comment on EventDatesInfo customization * Automated release 1.28.2 * fix(event): add permalink in customization to the original volto component * Automated release 1.28.2 --------- Co-authored-by: alin <contact@avoinea.com> Co-authored-by: Tiberiu Ichim <tiberiu.ichim@gmail.com> Co-authored-by: Tiberiu Ichim <tiberiuichim@users.noreply.github.com> Co-authored-by: EEA Jenkins <@users.noreply.github.com>
- Loading branch information
1 parent
f4b199c
commit e12e852
Showing
7 changed files
with
168 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
src/customizations/@plone/volto-slate/editor/extensions/normalizeExternalData.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
src/customizations/volto/components/theme/View/EventDatesInfo.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
/* Original: https://github.com/plone/volto/blob/16.x.x/src/components/theme/View/EventDatesInfo.jsx */ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { List } from 'semantic-ui-react'; | ||
import cx from 'classnames'; | ||
import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable'; | ||
import config from '@plone/volto/registry'; | ||
// import { toBackendLang } from '@plone/volto/helpers'; | ||
// import { useSelector } from 'react-redux'; | ||
|
||
export const datesForDisplay = (start, end, moment) => { | ||
const mStart = moment(start); | ||
const mEnd = moment(end); | ||
if (!mStart.isValid() || !mEnd.isValid()) { | ||
return null; | ||
} | ||
const sameDay = mStart.isSame(mEnd, 'day'); | ||
const sameTime = mStart.isSame(mEnd, 'minute'); | ||
return { | ||
sameDay, | ||
sameTime, | ||
startDate: mStart.format('ll'), | ||
startTime: mStart.format('LT'), | ||
endDate: mEnd.format('ll'), | ||
endTime: mEnd.format('LT'), | ||
}; | ||
}; | ||
|
||
const When_ = ({ start, end, whole_day, open_end, moment: momentlib }) => { | ||
// Customization: | ||
// Fix date format by using dateLocale instead of language from Redux | ||
// const lang = useSelector((state) => state.intl.locale); | ||
const dateLocale = config.settings.dateLocale || 'en-gb'; | ||
|
||
const moment = momentlib.default; | ||
moment.locale(dateLocale); | ||
// end customization | ||
|
||
const datesInfo = datesForDisplay(start, end, moment); | ||
if (!datesInfo) { | ||
return; | ||
} | ||
// TODO I18N INTL | ||
|
||
return ( | ||
<p | ||
className={cx('event-when', { | ||
'same-day': datesInfo.sameDay, | ||
'same-time': datesInfo.sameTime, | ||
'whole-day': whole_day, | ||
'open-end': open_end, | ||
})} | ||
> | ||
{!datesInfo.sameDay ? ( | ||
<> | ||
<span className="start"> | ||
<span className="start-date">{datesInfo.startDate}</span> | ||
{!whole_day && ( | ||
<> | ||
{/* Plone has an optional word based on locale here */} | ||
<span> </span> | ||
<span className="start-time">{datesInfo.startTime}</span> | ||
</> | ||
)} | ||
</span> | ||
{!open_end && ( | ||
<> | ||
to | ||
<span className="end"> | ||
<span className="end-date">{datesInfo.endDate}</span> | ||
{!whole_day && ( | ||
<> | ||
{/* Plone has an optional word based on locale here */} | ||
<span> </span> | ||
<span className="end-time">{datesInfo.endTime}</span> | ||
</> | ||
)} | ||
</span> | ||
</> | ||
)} | ||
</> | ||
) : ( | ||
<> | ||
{whole_day && ( | ||
<span className="start-date">{datesInfo.startDate}</span> | ||
)} | ||
{open_end && !whole_day && ( | ||
<> | ||
<span className="start-date">{datesInfo.startDate}</span> | ||
from | ||
<span className="start-time">{datesInfo.startTime}</span> | ||
</> | ||
)} | ||
{!(whole_day || open_end) && ( | ||
<> | ||
<span className="start-date">{datesInfo.startDate}</span> | ||
from | ||
<span className="start-time">{datesInfo.startTime}</span> | ||
to | ||
<span className="end-time">{datesInfo.endTime}</span> | ||
</> | ||
)} | ||
</> | ||
)} | ||
</p> | ||
); | ||
}; | ||
|
||
export const When = injectLazyLibs(['moment'])(When_); | ||
|
||
When.propTypes = { | ||
start: PropTypes.string.isRequired, | ||
end: PropTypes.string, | ||
whole_day: PropTypes.bool, | ||
open_end: PropTypes.bool, | ||
}; | ||
|
||
export const Recurrence_ = ({ | ||
recurrence, | ||
start, | ||
moment: momentlib, | ||
rrule, | ||
}) => { | ||
const moment = momentlib.default; | ||
const { RRule, rrulestr } = rrule; | ||
if (recurrence.indexOf('DTSTART') < 0) { | ||
var dtstart = RRule.optionsToString({ | ||
dtstart: new Date(start), | ||
}); | ||
recurrence = dtstart + '\n' + recurrence; | ||
} | ||
const rule = rrulestr(recurrence, { unfold: true, forceset: true }); | ||
|
||
return ( | ||
<List | ||
items={rule | ||
.all() | ||
.map((date) => datesForDisplay(date, undefined, moment)) | ||
.map((date) => date.startDate)} | ||
/> | ||
); | ||
}; | ||
export const Recurrence = injectLazyLibs(['moment', 'rrule'])(Recurrence_); | ||
|
||
Recurrence.propTypes = { | ||
recurrence: PropTypes.string.isRequired, | ||
start: PropTypes.string.isRequired, | ||
}; |