Skip to content

Commit f01fb6d

Browse files
author
Yannick
authored
Merge pull request #68 from webgem-xyz/v3.1
✏️ Changing Tempature in measurements to Temperature ✏️ Changed Ph to pH in measurements ✏️ Editable now uses 30 days instead of random number. 🐛 Fixed remove item in add measurement to remove the proper added field. 🐛 Input fields now also allow . and , ✨ Now warning when signing out. ✨ In edit added input type date ✨ In editMedia added input type date. ✨ Added remove button in editmedia ✨ Edit now saves changes. 🎨 Removed unused comments 💚 Updates to eslint config
2 parents fa3fae5 + e7a47fb commit f01fb6d

File tree

12 files changed

+174
-36
lines changed

12 files changed

+174
-36
lines changed

.eslintrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
"max-len": 0,
4545
"import/extensions": 0,
4646
"no-underscore-dangle": 0,
47+
"no-restricted-globals": 1,
4748
"no-return-assign": 0,
49+
"no-alert": 0,
4850
"consistent-return": 0,
4951
"react/display-name": 1,
5052
"react/no-unknown-property": 0,

readme.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,16 @@ createAccount | function | Function that handles creating the user account and s
240240
## DatePicker Component
241241
### Usage
242242
The DatePicker Component consists of the following
243-
* Label
243+
* Label
244244
* Input (date)
245245
* You choose the date
246246

247247
### Location
248-
The DatePicker Component is located at
248+
The DatePicker Component is located at
249249
```
250250
src/components/datePicker/
251251
```
252-
### Attributes
252+
### Attributes
253253
The DatePicker Component accepts the following attributes
254254

255255
Attribute | Type | Usage
@@ -362,7 +362,7 @@ HandleFilter | function | function that handles the filtering.
362362

363363
## Footer Component
364364
### Usage
365-
The Footer Component consists of the following
365+
The Footer Component consists of the following
366366
* Overview (icon)
367367
* When clicked on Overview it will send them to [Overview Component](#overview-component).
368368
* Request (icon)
@@ -373,7 +373,7 @@ The Footer Component consists of the following
373373
* When clicked on Notifications it will send them to [Notifications Component](#notifications-component).
374374

375375
### Location
376-
The Footer Component is located at
376+
The Footer Component is located at
377377
```
378378
src/components/footer/
379379
```
@@ -393,15 +393,15 @@ The FormItem Component consists of the following
393393
* Value
394394
* Acidity
395395
* Salinity
396-
* Tempature
396+
* Temperature
397397
* Label (value)
398398
* Input (number)
399399
* Remove Button
400400
* Value
401401
* Remove item
402402

403403
### Location
404-
The FormItem is located at
404+
The FormItem is located at
405405
```
406406
src/components/formItem/
407407
```
@@ -612,7 +612,7 @@ The Measurement component consists of the following
612612
* Date
613613
* Acidity (pH)
614614
* Salinity (PSU)
615-
* Tempature
615+
* Temperature
616616
* A button to delete the measurements
617617

618618
### Location

src/components/formItem/index.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,39 @@ import RemoveButton from '../../components/removeButton/';
55
import style from './style';
66

77
export default class FormItem extends Component {
8+
constructor() {
9+
super();
10+
11+
this.handleChange = this.handleChange.bind(this);
12+
this.removeField = this.removeField.bind(this);
13+
}
14+
15+
handleChange(e, kind) {
16+
this.props.handleState(kind, e.target.value);
17+
}
18+
19+
removeField(kind) {
20+
this.props.handleState(kind, null);
21+
}
22+
823
render() {
924
return (
1025
<div key={this.props.item} class={style.customFormfieldWrap}>
1126
<label>Measurement type</label>
12-
<select required class={style.select} value={this.props.item}>
13-
<option value="acidity">Acidity (Ph)</option>
27+
<select required class={style.select} value={this.props.item} disabled>
28+
<option value="acidity">Acidity (pH)</option>
1429
<option value="salinity">Salinity (PSU)</option>
15-
<option value="tempature">Tempature</option>
30+
<option value="Temperature">Temperature</option>
1631
</select>
1732
<label>Value</label>
18-
<input type="number" value={this.props.value} class={style.addedInputField} />
19-
<RemoveButton value="remove item" removeField={this.removeField} />
33+
<input
34+
onChange={e => this.handleChange(e, this.props.item)}
35+
type="number"
36+
step="0.00001"
37+
value={this.props.value}
38+
class={style.addedInputField}
39+
/>
40+
<RemoveButton value="remove item" i={this.props.item} removeField={this.removeField} />
2041
</div>
2142
);
2243
}
@@ -25,4 +46,5 @@ export default class FormItem extends Component {
2546
FormItem.propTypes = {
2647
item: PropTypes.string.isRequired,
2748
value: PropTypes.string.isRequired,
49+
handleState: PropTypes.func.isRequired,
2850
};

src/components/inputGroup/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default class InputGroup extends Component {
2222
<input
2323
onChange={e => this.handleChange(e, this.props.kind)}
2424
type={this.props.type}
25+
step="0.00001"
2526
placeholder={this.props.placeholder}
2627
value={this.props.value}
2728
id={this.props.kind}

src/components/item/index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ function defineImgAlt(details) {
2424
}
2525
}
2626

27-
function getNumber(mx) {
28-
return Math.floor(Math.random() * Math.floor(mx)) + 1;
29-
}
30-
3127
export default class Item extends Component {
3228
render() {
3329
const details = this.props.details;
@@ -41,7 +37,7 @@ export default class Item extends Component {
4137
class={style.icon}
4238
/>
4339
<p class={style.date}>{details.date}</p>
44-
<p class={style.edit}>{getNumber(24)} days</p>
40+
<p class={style.edit}>30 days</p>
4541
<p class={style.uploadStatText}>Received</p>
4642
<i className={`material-icons ${style.uploadStat}`}>done</i>
4743
</div>

src/components/removeButton/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default class RemoveButton extends Component {
99
type="button"
1010
value={this.props.value}
1111
class={style.remove}
12-
onClick={e => this.props.removeField(e, this.props.i)}
12+
onClick={() => this.props.removeField(this.props.i)}
1313
/>
1414
);
1515
}

src/routes/account/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ import Header from '../../components/header/index';
88
import style from './style';
99

1010
export default class Account extends Component {
11+
constructor(props) {
12+
super(props);
13+
14+
this.logoutConfirm = this.logoutConfirm.bind(this);
15+
}
16+
17+
logoutConfirm(e) {
18+
e.preventDefault();
19+
const r = confirm(
20+
`Are you sure you want to sign out? \nYou need a proper internet connection to sign in again.`
21+
);
22+
if (r === true) {
23+
this.props.logout(e);
24+
}
25+
}
1126
render() {
1227
return (
1328
<div class={style.account}>
@@ -26,7 +41,7 @@ export default class Account extends Component {
2641
<p>
2742
<span>Birth date:</span> 20-04-1990
2843
</p>
29-
<button onClick={e => this.props.logout(e)} class={style.logout}>
44+
<button onClick={e => this.logoutConfirm(e)} class={style.logout}>
3045
SIGN OUT
3146
</button>
3247
</div>

src/routes/add/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,14 @@ export default class Add extends Component {
147147
<label>Measurement type</label>
148148
<select required onChange={e => this.handleSelectChange(e, i)} class={style.select}>
149149
<option label=" " disabled selected />
150-
<option value="acidity">Acidity (Ph)</option>
150+
<option value="acidity">Acidity (pH)</option>
151151
<option value="salinity">Salinity (PSU)</option>
152-
<option value="tempature">Tempature</option>
152+
<option value="Temperature">Temperature</option>
153153
</select>
154154
<label>Value</label>
155155
<input
156156
type="number"
157+
step="0.0000001"
157158
value={this.state.value[i] || ''}
158159
onChange={e => this.handleChange(e, i)}
159160
class={style.addedInputField}

src/routes/edit/index.js

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export default class Edit extends Component {
2020

2121
this.handleSave = this.handleSave.bind(this);
2222
this.handleResetLoc = this.handleResetLoc.bind(this);
23+
this.handleState = this.handleState.bind(this);
24+
this.handleChange = this.handleChange.bind(this);
2325
this.handleEditSave = this.handleEditSave.bind(this);
2426

2527
this.state = {
@@ -29,9 +31,13 @@ export default class Edit extends Component {
2931
}
3032

3133
componentWillMount(nextProps) {
32-
this.ref = base.bindToState(`/${this.props.uid}/mes/${this.props.measurementId}`, {
34+
this.ref = base.fetch(`/${this.props.uid}/mes/${this.props.measurementId}`, {
3335
context: this,
34-
state: 'measurement',
36+
then(data) {
37+
this.setState({
38+
measurement: data,
39+
});
40+
},
3541
});
3642
}
3743

@@ -52,14 +58,32 @@ export default class Edit extends Component {
5258
});
5359
}
5460

61+
handleState(kind, value) {
62+
const measurement = { ...this.state.measurement };
63+
measurement[kind] = value;
64+
this.setState({
65+
measurement,
66+
});
67+
}
68+
69+
handleChange(e, kind) {
70+
this.handleState(kind, e.target.value);
71+
}
72+
5573
handleSave() {
5674
this.setState({
5775
open: false,
5876
});
5977
}
6078

6179
handleEditSave() {
62-
route(`/mes/${this.props.measurementId}`);
80+
const measurementId = this.props.measurementId;
81+
base.update(`/${this.props.uid}/mes/${this.props.measurementId}`, {
82+
data: this.state.measurement,
83+
then() {
84+
route(`/mes/${measurementId}`);
85+
},
86+
});
6387
}
6488

6589
render() {
@@ -75,9 +99,9 @@ export default class Edit extends Component {
7599
label="Date"
76100
handleState={this.handleState}
77101
fullWidth
102+
type="date"
78103
placeholder=""
79104
/>
80-
<i className="material-icons">date_range</i>
81105
</div>
82106
<section class={style.locationEdit}>
83107
<label>Location</label>
@@ -101,9 +125,19 @@ export default class Edit extends Component {
101125
<LinkRequestButton />
102126
</section>
103127
<section class={style.data}>
104-
{measurement.acidity && <FormItem item="acidity" value={measurement.acidity} />}
105-
{measurement.salinity && <FormItem item="acidity" value={measurement.salinity} />}
106-
{measurement.tempature && <FormItem item="acidity" value={measurement.tempature} />}
128+
{measurement.acidity && (
129+
<FormItem item="acidity" handleState={this.handleState} value={measurement.acidity} />
130+
)}
131+
{measurement.salinity && (
132+
<FormItem item="salinity" handleState={this.handleState} value={measurement.salinity} />
133+
)}
134+
{measurement.Temperature && (
135+
<FormItem
136+
item="Temperature"
137+
handleState={this.handleState}
138+
value={measurement.Temperature}
139+
/>
140+
)}
107141
<input
108142
type="button"
109143
onClick={this.handleEditSave}

0 commit comments

Comments
 (0)