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

disable rapid edit mode when in a cooperative task #2186

Merged
merged 1 commit into from
Nov 30, 2023
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
15 changes: 9 additions & 6 deletions src/components/Widgets/TaskMapWidget/RapidEditor/EditSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ export class EditSwitch extends Component {
}

render() {
const editModeOn = this.props.getUserAppSetting(this.props.user, 'isEditMode')
const editModeOn = this.props.editMode
const disableRapid = this.props.disableRapid

return (
<div className="mr-flex mr-justify-center">
<label className="switch-container">
<input type="checkbox" checked={editModeOn} />
<span className="slider round" onClick={() => this.toggleVisible()}></span>
</label>
<span className="mr-ml-2">
{!disableRapid ?
<label className="switch-container mr-mr-2">
<input type="checkbox" checked={editModeOn} />
<span className="slider round" onClick={() => this.toggleVisible()}></span>
</label> : null
}
<span>
{editModeOn ? 'Edit Mode' : 'Classic Mode'}
</span>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/components/Widgets/TaskMapWidget/TaskMapWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FormattedMessage } from 'react-intl'
import EditSwitch from './RapidEditor/EditSwitch'
import RapidEditor from './RapidEditor/RapidEditor';
import WithKeyboardShortcuts from '../../HOCs/WithKeyboardShortcuts/WithKeyboardShortcuts'
import AsCooperativeWork from '../../../interactions/Task/AsCooperativeWork'

const descriptor = {
widgetKey: 'TaskMapWidget',
Expand Down Expand Up @@ -71,7 +72,8 @@ export default class TaskMapWidget extends Component {
}

render() {
const editMode = this.props.getUserAppSetting ? this.props.getUserAppSetting(this.props.user, 'isEditMode') : false;
const disableRapid = AsCooperativeWork(this.props.task).isTagType() || this.props.task.cooperativeWork
const editMode = disableRapid ? false : this.props.getUserAppSetting ? this.props.getUserAppSetting(this.props.user, 'isEditMode') : false

if(!this.props.task.geometries.features){
return (
Expand Down Expand Up @@ -103,11 +105,11 @@ export default class TaskMapWidget extends Component {
this.props.getUserAppSetting
? <>
<div className="mr-flex mr-items-center ">
<div className="mr-text-yellow mr-mr-3">
<div className="mr-text-yellow mr-mr-1 mr-mt-1 mr-mb-2">
<FormattedMessage {...messages.editMode}/>
</div>
<div className="mr-mt-1 mr-mb-2">
<EditSwitch {...this.props}/>
<EditSwitch {...this.props} disableRapid={disableRapid} editMode={editMode} />
</div>
</div>
</>
Expand Down
Loading