Skip to content

Commit

Permalink
clone tour
Browse files Browse the repository at this point in the history
  • Loading branch information
dimmik committed Oct 14, 2019
1 parent ec39e0d commit be509c3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
19 changes: 18 additions & 1 deletion TourCalcWebApp/App/containers/appstate.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,24 @@ export default class AppState {
})
.then(res => res.text())
.then((res) => res, (error) => { alert('Error add tour') })
}
}
static addTourJson(comp, tour, accessCode, tname) {
if (tname != null) {
tour.name = tname
}
let b = JSON.stringify(tour, null, 2)
//alert('b: ' + b)
return fetch('/api/tour/add/' + accessCode, {
method: 'post',
headers: new Headers({
"Authorization": 'Bearer ' + this.token,
"Content-Type": "application/json"
}),
body: b
})
.then(res => res.text())
.then((res) => res, (error) => { alert('Error add tour') })
}
static changeTourName(comp, tourid, tname) {
let b = JSON.stringify({ name: tname }, null, 2)
//alert('b: ' + b)
Expand Down
24 changes: 24 additions & 0 deletions TourCalcWebApp/App/containers/tour-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export default class TourList extends React.Component {
: <span />
)
}</TableCell>
<TableCell>#
</TableCell>
</TableRow>
</TableHead>
<TableBody>
Expand All @@ -77,6 +79,28 @@ export default class TourList extends React.Component {
<TableCell>
<Button variant='outlined' onClick={() => { document.getElementById('TourJsonTextArea').value = JSON.stringify(t, null, 2); }}>JSON</Button>
</TableCell>
<TableCell>
<Button color='secondary' variant='outlined' onClick={
() => {
//alert('id: ' + t.id + 'tourAccessCode' + ' val: ' + document.getElementById(t.id + 'tourAccessCode').value);
if (document.getElementById(t.id + 'tourAccessCode').value != '') {
AppState.addTourJson(this, t
, document.getElementById(t.id + 'tourAccessCode').value
, document.getElementById(t.id + 'tourName').value
)
.then(() => { AppState.loadTours(this) })
} else {
alert('Please enter access code')
}
}
}>Clone</Button>

{this.props.authData.type === 'Master' ?
<span>Access code:<input type="text" size="4" id={t.id + "tourAccessCode"} /></span>
: <span><input type="hidden" id={t.id + "tourAccessCode"} value='none'/></span>
}
&nbsp;New tour name: <input type="text" size="16" id={t.id + "tourName"} defaultValue={'Clone ' + t.name} />
</TableCell>
</TableRow>
)
})
Expand Down

0 comments on commit be509c3

Please sign in to comment.