Skip to content
Open
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
38 changes: 20 additions & 18 deletions src/components/Dialogs/AltNamesDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,24 +306,26 @@ class AltNamesDialog extends React.Component {
}}
/>
) : (
<NewAltName
translations={translations}
handleAddAltName={this.handleAddAltName.bind(this)}
handleTypeChange={(event, key, type) => {
this.setState({ type: event.target.value });
}}
onLanguageChange={(event, key, lang) => {
this.setState({ lang: event.target.value });
}}
onValueChange={(event) => {
this.setState({ value: event.target.value });
}}
lang={lang}
type={type}
formatMessage={formatMessage}
value={value}
valid={!!lang && !!type && !!value}
/>
!disabled && (
<NewAltName
translations={translations}
handleAddAltName={this.handleAddAltName.bind(this)}
handleTypeChange={(event, key, type) => {
this.setState({ type: event.target.value });
}}
onLanguageChange={(event, key, lang) => {
this.setState({ lang: event.target.value });
}}
onValueChange={(event) => {
this.setState({ value: event.target.value });
}}
lang={lang}
type={type}
formatMessage={formatMessage}
value={value}
valid={!!lang && !!type && !!value}
/>
)
)}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,13 @@ const AssistanceServiceDetails = ({
id: `${inputName}_${assistanceAvailability}`,
})}
onChange={handleChange}
disabled={!canBeEdited}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option could be to use disabled={disabled} in here, make canBeEdited be about isAssistanceServicePresent only, and then keep the looping logic under .map as it was before. But matter of personal taste, disabling this input for when user is logged in but isAssistanceServicePresent is false is fine too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any strong opinion on this, maybe @a-limyr does? Otherwise, I'm happy with whatever you decide here.

>
{(canBeEdited
? assistanceAvailabilityOptions
: [AssistanceAvailabilityEnum.NONE]
).map((option) => {
return (
<MenuItem
key={`${id}_${inputName}-option-${option}`}
value={option}
>
{formatMessage({ id: `${inputName}_${option}` })}
</MenuItem>
);
})}
{assistanceAvailabilityOptions.map((option) => (
<MenuItem key={`${id}_${inputName}-option-${option}`} value={option}>
{formatMessage({ id: `${inputName}_${option}` })}
</MenuItem>
))}
</Select>
</FormControl>
);
Expand Down
14 changes: 8 additions & 6 deletions src/components/EditStopPage/TagItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Tag from "../MainPage/Tag";

class TagItem extends Component {
render() {
const { tag, handleDelete, intl } = this.props;
const { tag, handleDelete, intl, disabled } = this.props;
const columnStyle = {
flex: 1,
fontSize: "0.8em",
Expand Down Expand Up @@ -48,11 +48,13 @@ class TagItem extends Component {
<div style={{ ...columnStyle, flex: 3, fontSize: "0.7em" }}>
{moment(tag.created).locale("nb").format("DD-MM-YYYY HH:mm")}
</div>
<div style={{ ...columnStyle, flex: 1, padding: 0 }}>
<IconButton onClick={() => handleDelete(tag.name, tag.idReference)}>
<MdDelete style={{ color: "rgb(223, 84, 74)" }} />
</IconButton>
</div>
{!disabled && (
<div style={{ ...columnStyle, flex: 1, padding: 0 }}>
<IconButton onClick={() => handleDelete(tag.name, tag.idReference)}>
<MdDelete style={{ color: "rgb(223, 84, 74)" }} />
</IconButton>
</div>
)}
</div>
);
}
Expand Down
28 changes: 16 additions & 12 deletions src/components/EditStopPage/TagsDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class TagsDialog extends Component {
addTag,
getTags,
findTagByName,
disabled,
} = this.props;
const { formatMessage } = intl;
const { isLoading } = this.state;
Expand Down Expand Up @@ -123,6 +124,7 @@ class TagsDialog extends Component {
handleDelete={this.handleDeleteTag.bind(this)}
tag={tag}
intl={this.props.intl}
disabled={disabled}
/>
<div
style={{
Expand Down Expand Up @@ -150,18 +152,20 @@ class TagsDialog extends Component {
</span>
)}
</div>
<AddTagDialog
idReference={idReference}
addTag={addTag}
getTags={getTags}
handleLoading={(isLoading) => {
this.setState({
isLoading,
});
}}
intl={this.props.intl}
findTagByName={findTagByName}
/>
{!disabled && (
<AddTagDialog
idReference={idReference}
addTag={addTag}
getTags={getTags}
handleLoading={(isLoading) => {
this.setState({
isLoading,
});
}}
intl={this.props.intl}
findTagByName={findTagByName}
/>
)}
</div>
);
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Map/QuayMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ class QuayMarker extends React.Component {
const hideMergingTo = this.getHideMergingTo();
const hideMergingFrom = this.getHideMergingFrom();
const hideCancelMergingFromThis = this.getCancelMergingFromThis();
const canInteract = !disabled && !belongsToNeighbourStop;

return (
<Marker
Expand Down Expand Up @@ -309,8 +310,11 @@ class QuayMarker extends React.Component {
</div>
<div
className="marker-popup-change-coordinates-wrapper"
style={{
cursor: canInteract ? "pointer" : "auto",
}}
onClick={() =>
!belongsToNeighbourStop &&
canInteract &&
handleChangeCoordinates(
{ type: "quay", markerIndex: index },
position,
Expand Down
17 changes: 13 additions & 4 deletions src/components/Map/StopPlaceMarker.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ class StopPlaceMarker extends React.Component {
<div
style={{
display: "block",
cursor: "pointer",
cursor:
!disabled && handleChangeCoordinates ? "pointer" : "auto",
width: "auto",
textAlign: "center",
}}
onClick={() =>
!disabled &&
handleChangeCoordinates &&
handleChangeCoordinates(
{ type: "stop-place", markerIndex: index },
Expand Down Expand Up @@ -207,14 +209,19 @@ class StopPlaceMarker extends React.Component {
label={translations.adjustCentroid}
/>
<PopupButton
hidden={isMultimodalChild || isGroupMember || disabledForSearch}
hidden={
disabled ||
isMultimodalChild ||
isGroupMember ||
disabledForSearch
}
onClick={() => {
handleCreateGroup(id);
}}
label={translations.createGOS}
/>
<PopupButton
hidden={!isMultimodalChild}
hidden={disabled || !isMultimodalChild}
onClick={() =>
isShowingQuays ? handleHideQuays(id) : handleShowQuays(id)
}
Expand All @@ -223,13 +230,14 @@ class StopPlaceMarker extends React.Component {
}
/>
<PopupButton
hidden={!isEditingGroup || !isGroupMember}
hidden={disabled || !isEditingGroup || !isGroupMember}
labelStyle={{ background: "rgb(152,51,47)" }}
onClick={() => this.props.removeFromGroup(id)}
label={translations.removeFromGroup}
/>
<PopupButton
hidden={
disabled ||
isMultimodalChild ||
isMultimodal ||
disabledForSearch ||
Expand All @@ -240,6 +248,7 @@ class StopPlaceMarker extends React.Component {
/>
<PopupButton
hidden={
disabled ||
!allowConnectToAdjacentStop ||
!isMultimodalChild ||
isMultimodal ||
Expand Down
Loading