Skip to content

Commit

Permalink
#3024: Add all day indicators to calendars, maps etc
Browse files Browse the repository at this point in the history
  • Loading branch information
cemalettin-work committed Oct 12, 2020
1 parent 673b781 commit 5af227c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
4 changes: 1 addition & 3 deletions client/src/components/ReportSummary.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,7 @@ const ReportSummaryRow = ({ report }) => {
<Col md={12}>
{report.engagementDate && (
<Label bsStyle="default" className="engagement-date">
{moment(report.engagementDate).format(
Report.getEngagementDateFormat()
)}
{Report.getFormattedEngagementDate(report)}
</Label>
)}
</Col>
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/aggregations/ReportsMapWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import Leaflet from "components/Leaflet"
import _escape from "lodash/escape"
import _isEmpty from "lodash/isEmpty"
import { Location } from "models"
import { Location, Report } from "models"
import PropTypes from "prop-types"
import React, { useMemo } from "react"

Expand All @@ -25,7 +25,9 @@ const ReportsMapWidget = ({
values.forEach(report => {
if (Location.hasCoordinates(report.location)) {
let label = _escape(report.intent || "<undefined>") // escape HTML in intent!
label += `<br/>@ <b>${_escape(report.location.name)}</b>` // escape HTML in locationName!
label += `<br/>@ <b>${_escape(
report.location.name
)} ${Report.getAllDayIndicator(report)}</b>` // escape HTML in locationName!
markerArray.push({
id: report.uuid,
lat: report.location.lat,
Expand Down
4 changes: 3 additions & 1 deletion client/src/components/aggregations/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ export function reportsToEvents(reports) {
(r.location && r.location.name) ||
""
return {
title: who + "@" + where,
title: `${who} @ ${where} - ${
Report.isEngagementAllDay(r) ? "(all day)" : ""
}`,
start: moment(r.engagementDate).format("YYYY-MM-DD HH:mm"),
end: moment(r.engagementDate)
.add(r.duration, "minutes")
Expand Down
10 changes: 9 additions & 1 deletion client/src/models/Report.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,14 @@ export default class Report extends Model {
return attendees.find(el => el.role === role && el.primary)
}

static isEngagementAllDay(report) {
return !report.duration
}

static getAllDayIndicator(report) {
return Report.isEngagementAllDay(report) ? "(all day)" : ""
}

static getEngagementDateFormat() {
return Settings.engagementsIncludeTimeAndDuration
? Settings.dateFormats.forms.displayLong.withTime
Expand Down Expand Up @@ -535,7 +543,7 @@ export default class Report extends Model {
}

const start = moment(report.engagementDate)
if (!report.duration) {
if (Report.isEngagementAllDay(report)) {
return Settings.engagementsIncludeTimeAndDuration
? start.format(Settings.dateFormats.forms.displayLong.date) +
" (all day)"
Expand Down
5 changes: 1 addition & 4 deletions client/src/pages/reports/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,7 @@ const ReportShow = ({ setSearchQuery, pageDispatchers }) => {
component={FieldHelper.ReadonlyField}
humanValue={
<>
{report.engagementDate &&
moment(report.engagementDate).format(
Report.getEngagementDateFormat()
)}
{Report.getFormattedEngagementDate(report)}
<PlanningConflictForReport report={report} largeIcon />
</>
}
Expand Down

0 comments on commit 5af227c

Please sign in to comment.