Client: add notes to activities - fix 10

+ minor fix on weather
This commit is contained in:
Sam 2018-06-13 18:52:39 +02:00
parent 47fc2ab830
commit 066a05c57f
7 changed files with 59 additions and 8 deletions

View File

@ -1,4 +1,4 @@
"""empty message
"""Add 'notes' column to 'Activity' table
Revision ID: 096dd0b43beb
Revises: 71093ac9ca44

View File

@ -0,0 +1,15 @@
import React from 'react'
export default function ActivityNotes(props) {
const { notes } = props
return (
<div className="card">
<div className="card-body">
Notes
<div className="activity-notes">
{notes ? notes : 'No notes'}
</div>
</div>
</div>
)
}

View File

@ -43,10 +43,10 @@ export default function ActivityWeather(props) {
/>
</td>
<td>
{activity.weather_start.temperature}°C
{Number(activity.weather_start.temperature).toFixed(1)}°C
</td>
<td>
{activity.weather_end.temperature}°C
{Number(activity.weather_end.temperature).toFixed(1)}°C
</td>
</tr>
<tr>
@ -58,10 +58,10 @@ export default function ActivityWeather(props) {
/>
</td>
<td>
{activity.weather_start.humidity * 100}%
{Number(activity.weather_start.humidity * 100).toFixed(1)}%
</td>
<td>
{activity.weather_end.humidity * 100}%
{Number(activity.weather_end.humidity * 100).toFixed(1)}%
</td>
</tr>
<tr>
@ -73,10 +73,10 @@ export default function ActivityWeather(props) {
/>
</td>
<td>
{activity.weather_start.wind}m/s
{Number(activity.weather_start.wind).toFixed(1)}m/s
</td>
<td>
{activity.weather_end.wind}m/s
{Number(activity.weather_end.wind).toFixed(1)}m/s
</td>
</tr>
</tbody>

View File

@ -6,6 +6,7 @@ import ActivityCardHeader from './ActivityCardHeader'
import ActivityCharts from './ActivityCharts'
import ActivityDetails from './ActivityDetails'
import ActivityMap from './ActivityMap'
import ActivityNotes from './ActivityNotes'
import CustomModal from './../../Others/CustomModal'
import { getOrUpdateData } from '../../../actions'
import { deleteActivity } from '../../../actions/activities'
@ -106,6 +107,7 @@ class ActivityDisplay extends React.Component {
</div>
</div>
)}
<ActivityNotes notes={activity.notes} />
</div>
)}
</div>

View File

@ -64,6 +64,18 @@ function FormWithGpx (props) {
</label>
</div>
)}
<div className="form-group">
<label>
Notes:
<textarea
name="notes"
defaultValue={activity ? activity.notes : ''}
disabled={loading}
className="form-control input-lg"
maxLength="500"
/>
</label>
</div>
{loading ? (
<div className="loader" />
) : (
@ -100,13 +112,16 @@ export default connect(
const form = new FormData()
form.append('file', e.target.form.gpxFile.files[0])
form.append(
'data', `{"sport_id": ${e.target.form.sport.value}}`
'data',
`{"sport_id": ${e.target.form.sport.value
}, "notes": "${e.target.form.notes.value}"}`
)
dispatch(addActivity(form))
},
onEditActivity: (e, activity) => {
dispatch(editActivity({
id: activity.id,
notes: e.target.form.notes.value,
sport_id: +e.target.form.sport.value,
title: e.target.form.title.value,
}))

View File

@ -103,6 +103,17 @@ function FormWithoutGpx (props) {
/>
</label>
</div>
<div className="form-group">
<label>
Notes:
<textarea
name="notes"
defaultValue={activity ? activity.notes : ''}
className="form-control input-lg"
maxLength="500"
/>
</label>
</div>
<input
type="submit"
className="btn btn-primary btn-lg btn-block"
@ -133,6 +144,7 @@ export default connect(
activity_date: activityDate,
distance: +e.target.form.distance.value,
duration,
notes: e.target.form.notes.value,
sport_id: +e.target.form.sport_id.value,
title: e.target.form.title.value,
}

View File

@ -72,6 +72,13 @@ label {
padding: 0;
}
.activity-notes {
font-size: 0.9em;
font-style: italic;
margin-top: 10px;
padding: 5px;
}
.activity-page {
margin-top: 20px;
}