Merge branch '5-add-delete-or-modify-rooms' into 'dev'
Resolve "Add, Delete, or Modify rooms" Closes #5 See merge request sa4-2020/the-sanmarinoes/frontend!31
BIN
smart-hut/public/img/room_404_meme/1.jpeg
Normal file
After Width: | Height: | Size: 7.9 KiB |
BIN
smart-hut/public/img/room_404_meme/10.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
smart-hut/public/img/room_404_meme/11.jpeg
Normal file
After Width: | Height: | Size: 12 KiB |
BIN
smart-hut/public/img/room_404_meme/12.gif
Normal file
After Width: | Height: | Size: 94 KiB |
BIN
smart-hut/public/img/room_404_meme/13.gif
Normal file
After Width: | Height: | Size: 644 KiB |
BIN
smart-hut/public/img/room_404_meme/14.gif
Normal file
After Width: | Height: | Size: 320 KiB |
BIN
smart-hut/public/img/room_404_meme/2.jpeg
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
smart-hut/public/img/room_404_meme/3.png
Normal file
After Width: | Height: | Size: 244 KiB |
BIN
smart-hut/public/img/room_404_meme/4.jpeg
Normal file
After Width: | Height: | Size: 9.6 KiB |
BIN
smart-hut/public/img/room_404_meme/5.jpeg
Normal file
After Width: | Height: | Size: 6.3 KiB |
BIN
smart-hut/public/img/room_404_meme/6.jpg
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
smart-hut/public/img/room_404_meme/7.jpg
Normal file
After Width: | Height: | Size: 48 KiB |
BIN
smart-hut/public/img/room_404_meme/8.jpg
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
smart-hut/public/img/room_404_meme/9.jpeg
Normal file
After Width: | Height: | Size: 37 KiB |
|
@ -7,7 +7,8 @@ export default class ModalWindow extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedIcon: 'home',
|
id : "",
|
||||||
|
selectedIcon: "",
|
||||||
name: "",
|
name: "",
|
||||||
img: "",
|
img: "",
|
||||||
openModal: false
|
openModal: false
|
||||||
|
@ -23,14 +24,26 @@ export default class ModalWindow extends Component {
|
||||||
"name" : this.state.name,
|
"name" : this.state.name,
|
||||||
"images" : this.state.img
|
"images" : this.state.img
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this.props, data);
|
|
||||||
this.props.addRoom(data);
|
this.props.addRoom(data);
|
||||||
this.closeModal();
|
this.closeModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
modifyRoomModal = (e) => {
|
||||||
|
let data = {
|
||||||
|
"icon" : this.state.selectedIcon,
|
||||||
|
"name" : this.state.name,
|
||||||
|
"images" : this.state.img
|
||||||
|
}
|
||||||
|
this.props.updateRoom(data);
|
||||||
|
this.closeModal();
|
||||||
|
}
|
||||||
|
|
||||||
deleteRoom = (e) => {
|
deleteRoom = (e) => {
|
||||||
console.log(e);
|
let data = {
|
||||||
|
"id" : this.state.id
|
||||||
|
}
|
||||||
|
this.props.deleteRoom(data);
|
||||||
|
this.closeModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
changeSomething = (event) => {
|
changeSomething = (event) => {
|
||||||
|
@ -49,7 +62,6 @@ export default class ModalWindow extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateIcon(e) {
|
updateIcon(e) {
|
||||||
console.log(e);
|
|
||||||
this.setState({selectedIcon : e})
|
this.setState({selectedIcon : e})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,10 +76,16 @@ export default class ModalWindow extends Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
{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>
|
||||||
|
:
|
||||||
|
<Icon name="pencil" size="small" onClick={this.openModal}/>
|
||||||
|
}
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
onClose={this.closeModal}
|
onClose={this.closeModal}
|
||||||
open={this.state.openModal}>
|
open={this.state.openModal}>
|
||||||
|
@ -76,16 +94,19 @@ export default class ModalWindow extends Component {
|
||||||
<Form>
|
<Form>
|
||||||
<p>Insert the name of the room:</p>
|
<p>Insert the name of the room:</p>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<Input label='Room name' placeholder='Room Name' name="name" type='text' onChange={this.changeSomething}/>
|
<Input label='Room name' placeholder='Room Name' name="name" type='text' onChange={this.changeSomething}
|
||||||
|
value={this.props.type == "new" ? null : this.props.idRoom.name }/>
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
<p>Insert an image of the room:</p>
|
<p>Insert an image of the room:</p>
|
||||||
<Form.Field>
|
<Form.Field>
|
||||||
<Input label='Room image' type='file' name="img" onChange={this.changeSomething}/>
|
<Input label='Room image' type='file' name="img" onChange={this.changeSomething}
|
||||||
|
value={this.props.type == "new" ? null : this.props.idRoom.images }/>
|
||||||
</Form.Field>
|
</Form.Field>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
<div style={spaceDiv}>
|
<div style={spaceDiv}>
|
||||||
<p>Select an icon:</p>
|
<p>Select an icon:</p>
|
||||||
|
{this.props.selectedIcon == "new" ? "home" : this.props.idRoom.icon }
|
||||||
<SelectIcons updateIcon={this.updateIcon} currentIcon={this.state.selectedIcon}/>
|
<SelectIcons updateIcon={this.updateIcon} currentIcon={this.state.selectedIcon}/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -100,9 +121,12 @@ export default class ModalWindow extends Component {
|
||||||
<Button color='red' onClick={this.closeModal}>
|
<Button color='red' onClick={this.closeModal}>
|
||||||
<Icon name='remove' /> {this.props.type == "new" ? "Cancel" : "Discard changes" }
|
<Icon name='remove' /> {this.props.type == "new" ? "Cancel" : "Discard changes" }
|
||||||
</Button>
|
</Button>
|
||||||
<Button color='green' onClick={this.addRoomModal}>
|
|
||||||
|
|
||||||
|
<Button color='green' onClick={this.props.type == "new" ? this.addRoomModal : this.modifyRoomModal}>
|
||||||
<Icon name='checkmark' /> {this.props.type == "new" ? "Add room" : "Save changes"}
|
<Icon name='checkmark' /> {this.props.type == "new" ? "Add room" : "Save changes"}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
</Modal.Actions>
|
</Modal.Actions>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,17 +8,14 @@ class Navbar extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
activeItem: 'Home',
|
activeItem: 'Home',
|
||||||
edited: ""
|
edited: "",
|
||||||
|
editMode : false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showForm = (event) => {
|
editModeController = (e) => {
|
||||||
console.log(event);
|
this.setState((prevState) => ({ editMode: !prevState.editMode }));
|
||||||
if (event === "new"){
|
};
|
||||||
console.log("funziona");
|
|
||||||
return (<ModalWindow type="new"/>)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
handleClick = (e, { i }) => {
|
handleClick = (e, { i }) => {
|
||||||
this.setState({ activeItem: e.name,
|
this.setState({ activeItem: e.name,
|
||||||
|
@ -50,7 +47,7 @@ class Navbar extends Component {
|
||||||
<Icon name="home" size="small"/>
|
<Icon name="home" size="small"/>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column>
|
<Grid.Column>
|
||||||
Home
|
HOME
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -69,20 +66,21 @@ class Navbar extends Component {
|
||||||
>
|
>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Row>
|
<Grid.Row>
|
||||||
<Grid.Column width={1}>
|
<Grid.Column>
|
||||||
<Icon name={e.icon} size="small"/>
|
<Icon name={e.icon} size="small"/>
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column width={12}>
|
<Grid.Column width={8}>
|
||||||
{e.name}
|
{e.name}
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
<Grid.Column width={1}>
|
<Grid.Column floated="right">
|
||||||
<Icon name="pencil" size="small"/>
|
{this.state.edit ?
|
||||||
|
<ModalWindow type="modify" idRoom={e} modifyRoom={this.props.updateRoom} deleteRoom={this.props.deleteRoom}/>
|
||||||
|
: null
|
||||||
|
}
|
||||||
</Grid.Column>
|
</Grid.Column>
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
</ Menu.Item>
|
</ Menu.Item>
|
||||||
|
|
||||||
)
|
)
|
||||||
}) : null
|
}) : null
|
||||||
}
|
}
|
||||||
|
@ -91,11 +89,10 @@ class Navbar extends Component {
|
||||||
name='newM'
|
name='newM'
|
||||||
active={activeItem === 'Plus'}
|
active={activeItem === 'Plus'}
|
||||||
>
|
>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Row centered onClick={this.showForm} name='new'>
|
<Grid.Row centered name='new'>
|
||||||
|
|
||||||
<ModalWindow type="new" addRoom={this.props.addRoom}/>
|
<ModalWindow type="new" addRoom={this.props.addRoom}/>
|
||||||
|
|
||||||
</Grid.Row>
|
</Grid.Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|