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

Feature/orebro tsm 2 #1281

Merged
merged 20 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
12 changes: 9 additions & 3 deletions new-admin/src/views/tools/MenuEditor/menuEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,8 @@ class ToolOptions extends Component {
this.addNewItem();
};

getHeader = (canSave) => {
//getHeader = (canSave) => {
getHeader = () => {
const { classes } = this.props;
return (
<Grid
Expand All @@ -349,8 +350,14 @@ class ToolOptions extends Component {
<Grid xs={3} item>
<Typography variant="h5">Inställningar</Typography>
</Grid>
<Grid xs={4} item>
<Typography variant="h5">Dokument</Typography>
</Grid>
<Grid xs={2} item>
<Typography variant="h5">Kartlänk</Typography>
</Grid>
<Grid xs={2} item>
<Typography variant="h5">Koppling</Typography>
<Typography variant="h5">Extern länk</Typography>
</Grid>

<Grid ref={this.buttonHeaderRef} xs={4} item>
Expand All @@ -364,7 +371,6 @@ class ToolOptions extends Component {
<ColorButtonBlue
variant="contained"
className="btn"
disabled={!canSave}
onClick={this.onSaveMenuEditsClick}
startIcon={<SaveIcon />}
>
Expand Down
83 changes: 10 additions & 73 deletions new-admin/src/views/tools/MenuEditor/menuconnectionselector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import React from "react";
import Grid from "@material-ui/core/Grid";
import ArrowRightIcon from "@material-ui/icons/ArrowRight";
import DescriptionIcon from "@material-ui/icons/Description";
import RoomIcon from "@material-ui/icons/Room";
import LanguageIcon from "@material-ui/icons/Language";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
Expand Down Expand Up @@ -39,15 +37,15 @@ const getTextField = (value, onChangeFunction, variant) => {

const MENU_CONNECTION_TYPES = {
documentConnection: "Koppla dokument",
mapLink: "Koppla karta och lager",
link: "Koppla webblänk",
// mapLink: "Koppla karta och lager",
// link: "Koppla webblänk",
none: "Inget valt",
};

const MAPLINK_TEXT = "Kartlänk";
const WEBLINK_TEXT = "Webblänk";
const NONE_TEXT = "Inget valt";
const MAP_TEXT = "Karta";
//const MAP_TEXT = "Karta";

const styles = (theme) => ({
menuItem: {
Expand All @@ -61,8 +59,6 @@ const styles = (theme) => ({
class MenuConnectionSelector extends React.Component {
state = {
open: false,
mapLinkValue: this.props.menuItem.maplink,
linkValue: this.props.menuItem.link,
documentValue: this.props.menuItem.document,
activeMenu: "",
};
Expand All @@ -79,15 +75,6 @@ class MenuConnectionSelector extends React.Component {
if (menuItem.document !== "") {
return MENU_CONNECTION_TYPES.documentConnection;
}

if (menuItem.link) {
return MENU_CONNECTION_TYPES.link;
}

if (menuItem.maplink) {
return MENU_CONNECTION_TYPES.mapLink;
}

return MENU_CONNECTION_TYPES.none;
};

Expand All @@ -102,11 +89,7 @@ class MenuConnectionSelector extends React.Component {
};

getMenuConnectionTypeIcon = (type) => {
return type === MENU_CONNECTION_TYPES.link ? (
<LanguageIcon></LanguageIcon>
) : type === MENU_CONNECTION_TYPES.mapLink ? (
<RoomIcon></RoomIcon>
) : type === MENU_CONNECTION_TYPES.documentConnection ? (
return type === MENU_CONNECTION_TYPES.documentConnection ? (
<DescriptionIcon></DescriptionIcon>
) : type === MENU_CONNECTION_TYPES.none ? (
<BlockIcon></BlockIcon>
Expand Down Expand Up @@ -174,8 +157,6 @@ class MenuConnectionSelector extends React.Component {
reset = () => {
const { menuItem } = this.props;
this.setState({
mapLinkValue: menuItem.maplink,
linkValue: menuItem.link,
documentValue: menuItem.document,
connectionsMenuAnchorEl: null,
});
Expand All @@ -186,32 +167,17 @@ class MenuConnectionSelector extends React.Component {
const { activeMenu } = this.state;
let value = this.state.activeMenu;
let newMenuItem = {
maplink: "",
link: "",
document: "",
};

if (activeMenu === MENU_CONNECTION_TYPES.documentConnection) {
if (!this.state.documentValue) {
value = MENU_CONNECTION_TYPES.none;
}
newMenuItem = { ...newMenuItem, document: this.state.documentValue };
}

if (activeMenu === MENU_CONNECTION_TYPES.link) {
if (!this.state.linkValue) {
value = MENU_CONNECTION_TYPES.none;
}
newMenuItem = { ...newMenuItem, link: this.state.linkValue };
}
newMenuItem = { ...newMenuItem, document: this.state.documentValue };

if (activeMenu === MENU_CONNECTION_TYPES.mapLink) {
if (!this.state.mapLinkValue) {
value = MENU_CONNECTION_TYPES.none;
}
newMenuItem = { ...newMenuItem, maplink: this.state.mapLinkValue };
if (activeMenu === MENU_CONNECTION_TYPES.none) {

newMenuItem = { ...newMenuItem, document: "" };

}

updateMenuItem(treeNodeId, newMenuItem);

this.setState({
Expand Down Expand Up @@ -282,14 +248,6 @@ class MenuConnectionSelector extends React.Component {
if (activeMenu === MENU_CONNECTION_TYPES.documentConnection) {
return this.renderDocumentList();
}

if (activeMenu === MENU_CONNECTION_TYPES.link) {
return this.renderLink();
}

if (activeMenu === MENU_CONNECTION_TYPES.mapLink) {
return this.renderMapLink();
}
};

handleChange = (target, value) => {
Expand Down Expand Up @@ -350,21 +308,6 @@ class MenuConnectionSelector extends React.Component {
this.getMenuConnectionTypeIcon(MENU_CONNECTION_TYPES.none)
);
}

if (this.state.value === MENU_CONNECTION_TYPES.link) {
return this.getRenderedSelectionText(
WEBLINK_TEXT,
this.getMenuConnectionTypeIcon(MENU_CONNECTION_TYPES.link)
);
}

if (this.state.value === MENU_CONNECTION_TYPES.mapLink) {
return this.getRenderedSelectionText(
MAP_TEXT,
this.getMenuConnectionTypeIcon(MENU_CONNECTION_TYPES.mapLink)
);
}

return this.getRenderedSelectionText(NONE_TEXT);
};

Expand All @@ -382,18 +325,12 @@ class MenuConnectionSelector extends React.Component {

render = () => {
const { value, open } = this.state;
const { valid } = this.props;

if (value) {
return (
<>
<FormControl>
<Grid alignItems="center" container>
{!valid && (
<Grid xs={2} item>
{this.renderWarning()}
</Grid>
)}
<Grid xs={10} item>
<Select
MenuProps={{
Expand Down
Loading