Skip to content

Commit

Permalink
Merge pull request #52 from Jacob-Daniel/add-fullDay-duration
Browse files Browse the repository at this point in the history
Added fullDay default duration for events
  • Loading branch information
LuisRodriguezLD authored Oct 14, 2024
2 parents 930bb5b + 6372c32 commit 16a41cb
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
6 changes: 6 additions & 0 deletions admin/src/pages/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,12 @@ function Settings() {
defaultMessage: '2 Hours',
})}
</Option>
<Option value={1440}>
{formatMessage({
id: getTrad('view.settings.section.general.default-duration.fullday'),
defaultMessage: 'Full Day',
})}
</Option>
</Select>
</GridItem>
</Grid>
Expand Down
1 change: 1 addition & 0 deletions admin/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"view.settings.section.general.default-duration.1h": "1 Stunde",
"view.settings.section.general.default-duration.1.5h": "1,5 Stunden",
"view.settings.section.general.default-duration.2h": "2 Stunden",
"view.settings.section.general.default-duration.fullDay": "Ganztägig",
"view.settings.section.general.start.label": "Start-Feld auswählen",
"view.settings.section.general.end.label": "Ende-Feld auswählen",
"view.settings.section.general.end.none": "Kein Ende-Feld",
Expand Down
1 change: 1 addition & 0 deletions admin/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"view.settings.section.general.default-duration.1h": "1 Hour",
"view.settings.section.general.default-duration.1.5h": "1.5 Hours",
"view.settings.section.general.default-duration.2h": "2 Hours",
"view.settings.section.general.default-duration.fullDay": "Full Day",
"view.settings.section.general.start.label": "Choose your start field",
"view.settings.section.general.end.label": "Choose your end field",
"view.settings.section.general.end.none": "No end field",
Expand Down
1 change: 1 addition & 0 deletions admin/src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"view.settings.section.general.default-duration.1h": "1 hora",
"view.settings.section.general.default-duration.1.5h": "1,5 horas",
"view.settings.section.general.default-duration.2h": "2 horas",
"view.settings.section.general.default-duration.fullDay": "Todo el día",
"view.settings.section.general.start.label": "Elija su campo de comienzo",
"view.settings.section.general.end.label": "Elija su campo de finalización",
"view.settings.section.general.end.none": "Sin campo de finalización",
Expand Down
30 changes: 21 additions & 9 deletions server/services/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,28 @@ module.exports = () => ({
if (config.drafts) return true;
return x.publishedAt;
});

return dataFiltered.map((x) => ({
id: x.id,
title: config.titleField ? x[config.titleField] : config.startField,
startDate: x[config.startField],
endDate: config.endField
return dataFiltered.map((x) => {
let startDate = x[config.startField];
let endDate = config.endField
? x[config.endField]
: moment(x[config.startField]).add(config.defaultDuration, 'minutes'),
color: config.colorField ? x[config.colorField] : null,
}));
: moment(x[config.startField]).add(config.defaultDuration, 'minutes').format();

const allDay = config.defaultDuration === 1440;

if (allDay) {
startDate = moment(startDate).startOf('day').format();
endDate = moment(endDate).endOf('day').format();
}

return {
id: x.id,
title: config.titleField ? x[config.titleField] : x[config.startField],
startDate: startDate,
endDate: endDate,
color: config.colorField ? x[config.colorField] : null,
allDay: allDay,
};
});
},
async getCollections() {
const types = strapi.contentTypes;
Expand Down

0 comments on commit 16a41cb

Please sign in to comment.