Merge branch 'fix-mobile' into 'dev'

fixed mobile

See merge request sa4-2020/the-sanmarinoes/frontend!77
This commit is contained in:
Claudio Maggioni 2020-03-26 10:31:02 +01:00
commit 49ba4283bf
2 changed files with 76 additions and 33 deletions

View file

@ -103,10 +103,17 @@ export default class ModalWindow extends Component {
margin: "10px 0px", margin: "10px 0px",
}; };
return ( return (
<div>
{!this.props.nicolaStop ? (
<div> <div>
<Responsive minWidth={768}> <Responsive minWidth={768}>
{this.props.type === "new" ? ( {this.props.type === "new" ? (
<Button icon labelPosition="left" inverted onClick={this.openModal}> <Button
icon
labelPosition="left"
inverted
onClick={this.openModal}
>
<Icon name="plus" size="small" /> <Icon name="plus" size="small" />
ADD ROOM ADD ROOM
</Button> </Button>
@ -116,17 +123,29 @@ export default class ModalWindow extends Component {
</Responsive> </Responsive>
<Responsive maxWidth={768}> <Responsive maxWidth={768}>
{this.props.type === "new" ? ( {this.props.type === "new" ? (
<Button icon fluid labelPosition="left" onClick={this.openModal}> <Button
icon
fluid
labelPosition="left"
onClick={this.openModal}
>
<Icon name="plus" size="small" /> <Icon name="plus" size="small" />
ADD ROOM ADD ROOM
</Button> </Button>
) : ( ) : (
<Button icon fluid labelPosition="left" onClick={this.openModal}> <Button
icon
fluid
labelPosition="left"
onClick={this.openModal}
>
<Icon name="pencil" size="small" /> <Icon name="pencil" size="small" />
EDIT ROOM EDIT ROOM
</Button> </Button>
)} )}
</Responsive> </Responsive>
</div>
) : null}
<Modal onClose={this.closeModal} open={this.state.openModal}> <Modal onClose={this.closeModal} open={this.state.openModal}>
<Header> <Header>

View file

@ -1,5 +1,12 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Menu, Grid, Icon, Responsive, Dropdown } from "semantic-ui-react"; import {
Menu,
Button,
Grid,
Icon,
Responsive,
Dropdown,
} from "semantic-ui-react";
import { editButtonStyle } from "../components/dashboard/devices/styleComponents"; import { editButtonStyle } from "../components/dashboard/devices/styleComponents";
import ModalWindow from "../components/modalform"; import ModalWindow from "../components/modalform";
@ -13,6 +20,11 @@ class Navbar extends Component {
editMode: false, editMode: false,
room: "", room: "",
}; };
this.roomRefs = {};
this.props.rooms.forEach((e) => {
this.roomRefs[e.id] = React.createRef();
});
} }
componentDidMount() { componentDidMount() {
@ -137,6 +149,8 @@ class Navbar extends Component {
{this.props.rooms {this.props.rooms
? this.props.rooms.map((e, i) => { ? this.props.rooms.map((e, i) => {
if (!this.roomRefs[e.id])
this.roomRefs[e.id] = React.createRef();
return ( return (
<Dropdown.Item <Dropdown.Item
id={e.id} id={e.id}
@ -153,6 +167,14 @@ class Navbar extends Component {
<Grid.Column>{e.name}</Grid.Column> <Grid.Column>{e.name}</Grid.Column>
</Grid.Row> </Grid.Row>
</Grid> </Grid>
<ModalWindow
ref={this.roomRefs[e.id]}
type="modify"
nicolaStop={true}
idRoom={e}
updateRoom={this.props.updateRoom}
deleteRoom={this.props.deleteRoom}
/>
</Dropdown.Item> </Dropdown.Item>
); );
}) })
@ -167,15 +189,17 @@ class Navbar extends Component {
</Grid.Column> </Grid.Column>
{this.state.activeItem !== -1 ? ( {this.state.activeItem !== -1 ? (
<Grid.Column width={8}> <Grid.Column width={8}>
<ModalWindow <Button
type="modify" icon
idRoom={() => { fluid
console.log("MALUSA", this.activeRoom); labelPosition="left"
return this.activeRoom; onClick={() =>
}} this.roomRefs[this.state.activeItem].current.openModal()
updateRoom={this.props.updateRoom} }
deleteRoom={this.props.deleteRoom} >
/> <Icon name="pencil" size="small" />
EDIT ROOM
</Button>
</Grid.Column> </Grid.Column>
) : null} ) : null}
</Grid.Row> </Grid.Row>