Skip to content

Commit 3363483

Browse files
authored
Merge pull request #51 from bonham/bonham/issue48
protect from clicking 'all'
2 parents 4186a8c + 4601c54 commit 3363483

File tree

5 files changed

+57
-15
lines changed

5 files changed

+57
-15
lines changed

client/src/components/FilteredTrackList.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
label="Spinning"
1111
/>
1212
</span>
13-
<span v-else>Loaded</span>
13+
<span v-else>{{ headline }}</span>
1414
</div>
1515
<b-card
1616
ref="testref"
@@ -38,6 +38,7 @@
3838
<script>
3939
import { mapState, mapMutations } from 'vuex'
4040
import { BListGroup, BListGroupItem, BCard, BSpinner } from 'bootstrap-vue'
41+
import { TrackCollection } from '@/lib/Track.js'
4142
4243
export default {
4344
name: 'FilteredTrackList',
@@ -57,6 +58,14 @@ export default {
5758
const l = this.loadedTracks
5859
l.sort((a, b) => (a.secondsSinceEpoch() - b.secondsSinceEpoch()))
5960
return l
61+
},
62+
sumDistance () {
63+
const tc = new TrackCollection(this.loadedTracks)
64+
return tc.distance()
65+
},
66+
headline () {
67+
const dist = Math.round(this.sumDistance / 1000)
68+
return `${this.loadedTracks.length} Tracks, ${dist} km`
6069
}
6170
},
6271
created () {

client/src/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Vue from 'vue'
22

33
// import { BootstrapVue } from 'bootstrap-vue'
4-
import { LayoutPlugin, NavbarPlugin, ButtonPlugin, LinkPlugin } from 'bootstrap-vue'
4+
import { LayoutPlugin, NavbarPlugin, ButtonPlugin, LinkPlugin, ModalPlugin } from 'bootstrap-vue'
55
import 'bootstrap/dist/css/bootstrap.css'
66
import 'bootstrap-vue/dist/bootstrap-vue.css'
77

@@ -13,6 +13,7 @@ Vue.use(LayoutPlugin)
1313
Vue.use(NavbarPlugin)
1414
Vue.use(ButtonPlugin)
1515
Vue.use(LinkPlugin)
16+
Vue.use(ModalPlugin)
1617

1718
new Vue({
1819
router,

client/src/views/SelectTracksPage.vue

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
{{ year === 0 ? "No date" : year }}
3232
</b-button>
3333
<b-button
34+
v-if="showAllButton"
3435
class="m-2"
3536
@click="loadAllTracks()"
3637
>
@@ -105,7 +106,8 @@ export default {
105106
currentOrientation: 'landscape',
106107
resizeObserver: null,
107108
years: [],
108-
buttonsLoading: false
109+
buttonsLoading: false,
110+
showAllButton: false
109111
}
110112
},
111113
computed: {

client/src/views/TrackMultiEditPage.vue

+19-4
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,21 @@
1414
</div>
1515

1616
<b-button
17+
v-b-modal.my-modal
1718
class="mb-3"
18-
@click="cleanAll"
1919
>
2020
Clean all
2121
</b-button>
22+
<!-- The modal -->
23+
<b-modal
24+
id="my-modal"
25+
ok-title="Proceed"
26+
ok-variant="danger"
27+
cancel-title="Abort"
28+
@ok="cleanAll"
29+
>
30+
This can take very long and may have unpredicted results. Better try line by line first.
31+
</b-modal>
2232
<b-table
2333
id="tracktable"
2434
striped
@@ -32,7 +42,7 @@
3242
<div
3343
v-if="data.item.loading"
3444
>
35-
<b-skeleton />
45+
<span class="cell-updating">Updating ..</span>
3646
</div>
3747
<div v-else>
3848
<editable-text
@@ -64,7 +74,8 @@
6474
import {
6575
BTable, BButton,
6676
BIconArrowLeft, BIconTrash,
67-
BSkeleton, BContainer, BSpinner
77+
BContainer, BSpinner,
78+
BModal
6879
} from 'bootstrap-vue'
6980
import { getAllTracks, updateTrack, updateTrackById, deleteTrack } from '@/lib/trackServices.js'
7081
import TrackManagerNavBar from '@/components/TrackManagerNavBar.vue'
@@ -117,9 +128,9 @@ export default {
117128
BButton,
118129
BIconArrowLeft,
119130
BIconTrash,
120-
BSkeleton,
121131
BContainer,
122132
BSpinner,
133+
BModal,
123134
TrackManagerNavBar,
124135
EditableText
125136
},
@@ -223,5 +234,9 @@ export default {
223234
.flip-list-leave-to {
224235
opacity: 0;
225236
}
237+
.cell-updating {
238+
opacity: 0.5;
239+
font-style: italic;
240+
}
226241
227242
</style>

client/tests/unit/TrackMultiEditPage.spec.js

+23-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, fireEvent, waitForElementToBeRemoved } from '@testing-library/v
33
import TrackMultiEditPage from '@/views/TrackMultiEditPage.vue'
44
import ResizeObserver from './__mocks__/ResizeObserver'
55
import { responseMockFunction } from './mockResponse'
6+
import { ModalPlugin, BModal } from 'bootstrap-vue'
67

78
fetchMock.enableMocks()
89

@@ -17,14 +18,22 @@ describe('MultiEditPage', () => {
1718
fetch.mockResponse(responseMockFunction)
1819

1920
const rresult = render(
20-
TrackMultiEditPage, {
21-
props: { sid: 'abcd1234' }
22-
})
21+
TrackMultiEditPage,
22+
{
23+
props: { sid: 'abcd1234' },
24+
components: {
25+
BModal
26+
}
27+
},
28+
vue => vue.use(ModalPlugin)
29+
)
2330
await rresult.findByText('Saupferchweg')
24-
const button = await rresult.findByText('Clean all')
31+
const button1 = await rresult.findByText('Clean all')
2532
expect(fetch.mock.calls.length).toEqual(1)
2633
expect(fetch.mock.calls[0][0]).toEqual('/api/tracks/getall/sid/abcd1234')
27-
await fireEvent.click(button)
34+
await fireEvent.click(button1)
35+
const button2 = await rresult.findByText('Proceed')
36+
await fireEvent.click(button2)
2837
await rresult.findByText('Muellerweg')
2938
expect(fetch.mock.calls.length).toEqual(2)
3039
const secondCallRequest = fetch.mock.calls[1][0]
@@ -38,9 +47,15 @@ describe('MultiEditPage', () => {
3847
fetch.mockResponse(responseMockFunction)
3948

4049
const rresult = render(
41-
TrackMultiEditPage, {
42-
props: { sid: 'abcd1234' }
43-
})
50+
TrackMultiEditPage,
51+
{
52+
props: { sid: 'abcd1234' },
53+
components: {
54+
BModal
55+
}
56+
},
57+
vue => vue.use(ModalPlugin)
58+
)
4459
await rresult.findByText('Saupferchweg')
4560
const deleteButton = await rresult.findByLabelText('trash')
4661
expect(fetch.mock.calls.length).toEqual(1)

0 commit comments

Comments
 (0)