Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add new location widget #2555

Merged
merged 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/TaskPane/TaskPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
layout: [
{ i: generateWidgetId(), x: 0, y: 0, w: 4, h: 4 },
{ i: generateWidgetId(), x: 4, y: 0, w: 8, h: 5 },
{ i: generateWidgetId(), x: 4, y: 5, w: 8, h: 19 },
{ i: generateWidgetId(), x: 4, y: 5, w: 8, h: 21 },

Check warning on line 58 in src/components/TaskPane/TaskPane.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/TaskPane/TaskPane.jsx#L58

Added line #L58 was not covered by tests
{ i: generateWidgetId(), x: 0, y: 4, w: 4, h: 7 },
{ i: generateWidgetId(), x: 0, y: 11, w: 4, h: 8 },
],
Expand Down
45 changes: 45 additions & 0 deletions src/components/Widgets/LocationWidget/LocationWidget.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Component } from "react";
import { FormattedMessage } from "react-intl";
import { WidgetDataTarget, registerWidgetType } from "../../../services/Widget/Widget";
import QuickWidget from "../../QuickWidget/QuickWidget";
import PlaceDescription from "../../TaskPane/PlaceDescription/PlaceDescription";
import TaskLatLon from "../../TaskPane/TaskLatLon/TaskLatLon";
import messages from "./Messages";

const descriptor = {
widgetKey: "LocationWidget",
label: messages.label,
targets: [WidgetDataTarget.task],
minWidth: 2,
defaultWidth: 4,
minHeight: 2,
defaultHeight: 3,
};

export default class LocationWidget extends Component {
toggleReverseLonLat = (reverseLonLat) => {
this.props.updateUserAppSetting(this.props.user.id, {
reverseLonLat: !reverseLonLat,
});
};

render() {
const reverseLonLat =
this.props.user?.properties?.mr3Frontend?.settings?.reverseLonLat || false;

Check warning on line 28 in src/components/Widgets/LocationWidget/LocationWidget.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Widgets/LocationWidget/LocationWidget.jsx#L27-L28

Added lines #L27 - L28 were not covered by tests

return (
<QuickWidget
{...this.props}
className="task-location-widget"
widgetTitle={<FormattedMessage {...messages.label} />}
noMain

Check warning on line 35 in src/components/Widgets/LocationWidget/LocationWidget.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Widgets/LocationWidget/LocationWidget.jsx#L30-L35

Added lines #L30 - L35 were not covered by tests
>
<PlaceDescription address={this.props.task.place?.address} className="mr-text-md " />

Check warning on line 37 in src/components/Widgets/LocationWidget/LocationWidget.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Widgets/LocationWidget/LocationWidget.jsx#L37

Added line #L37 was not covered by tests

<TaskLatLon task={this.props.task} reverse={reverseLonLat} className="mr-text-xs mr-mt-3" />

Check warning on line 39 in src/components/Widgets/LocationWidget/LocationWidget.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Widgets/LocationWidget/LocationWidget.jsx#L39

Added line #L39 was not covered by tests
</QuickWidget>
);
}

Check warning on line 42 in src/components/Widgets/LocationWidget/LocationWidget.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/Widgets/LocationWidget/LocationWidget.jsx#L42

Added line #L42 was not covered by tests
}

registerWidgetType(LocationWidget, descriptor);
11 changes: 11 additions & 0 deletions src/components/Widgets/LocationWidget/Messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineMessages } from "react-intl";

/**
* Internationalized messages for use with TaskLocationWidget
*/
export default defineMessages({
label: {
id: "Widgets.TaskLocationWidget.label",
defaultMessage: "Location",
},
});
1 change: 1 addition & 0 deletions src/components/Widgets/widget_registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export { default as TaskMoreOptionsWidget } from "./TaskMoreOptionsWidget/TaskMo
export { default as TaskPropertiesWidget } from "./TaskPropertiesWidget/TaskPropertiesWidget";
export { default as KeyboardShortcutsWidget } from "./KeyboardShortcutsWidget/KeyboardShortcutsWidget";
export { default as TaskLocationWidget } from "./TaskLocationWidget/TaskLocationWidget";
export { default as LocationWidget } from "./LocationWidget/LocationWidget";
export { default as TaskStatusWidget } from "./TaskStatusWidget/TaskStatusWidget";
export { default as CompletionProgressWidget } from "./CompletionProgressWidget/CompletionProgressWidget";
export { default as ChallengeShareWidget } from "./ChallengeShareWidget/ChallengeShareWidget";
Expand Down