-
Notifications
You must be signed in to change notification settings - Fork 5
Added links for different events #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6765c12
c227812
1f0dbf9
ffc43a4
c9eb496
8cb26a7
d1fcda9
123f138
452c04a
1a70815
0794a3d
baf954c
9699f27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| <template> | ||
| <p>Select an Event to see details</p> | ||
| </template> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <template> | ||
| <button type="button" class="btn btn-primary" @click="copyLink">Copy Link to Event</button> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import { PopupType } from '@/models'; | ||
| import { usePopupStore } from '@/stores/popup'; | ||
| import { defineComponent } from 'vue'; | ||
|
|
||
| export default defineComponent({ | ||
| props: { | ||
| eventId: Number | ||
| }, | ||
| methods: { | ||
| copyLink() { | ||
| const popupStore = usePopupStore(); | ||
| const baseUrl = window.location.host; | ||
|
|
||
| const urlToCopy = baseUrl + '/event/' + this.eventId; | ||
|
|
||
| try { | ||
| navigator.clipboard.writeText(urlToCopy); | ||
|
|
||
| popupStore.addPopup(PopupType.Success, 'Copied url for event to clipboard!'); | ||
| } catch (_err) { | ||
| popupStore.addPopup(PopupType.Danger, `Failed to copy url ${urlToCopy} to clipboard`); | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,10 +8,17 @@ function sortByStartDate(a: Event, b: Event) { | |
| export const useEventStore = defineStore('events', { | ||
| state: () => ({ | ||
| events: [] as Event[], | ||
| selectedEvent: null as Event | null | ||
| id: null as number | null | ||
| }), | ||
| getters: { | ||
| selectedEventCars: (state) => state.selectedEvent?.cars | ||
| selectedEvent(state) { | ||
| return state.events.find((event) => { | ||
| return event.id == state.id; | ||
| }); | ||
| }, | ||
|
Comment on lines
+14
to
+18
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One could argue it's more efficient to store events as a dict of ID to event, but it doesn't really matter
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rn the store stores the events in an array sorted by date to make it easier to display them in order I honestly don't know which way is better |
||
| selectedEventCars(): Car[] | undefined { | ||
| return this.selectedEvent?.cars; | ||
| } | ||
| }, | ||
| actions: { | ||
| addEvent(event: Event) { | ||
|
|
@@ -20,29 +27,25 @@ export const useEventStore = defineStore('events', { | |
| setEvents(events: Event[]) { | ||
| this.events = events; | ||
| }, | ||
| setEventId(id: number) { | ||
| this.id = id; | ||
| }, | ||
| sortEvents(past: Boolean) { | ||
| this.events.sort(sortByStartDate); | ||
|
|
||
| if (past) { | ||
| this.events.reverse(); | ||
| this.events.reverse(); | ||
| } | ||
| }, | ||
| removeEvent(event: Event | null) { | ||
| if (event == null) { | ||
| removeEvent(id: number | null) { | ||
| if (id == null) { | ||
| return; | ||
| } | ||
| const index = this.events.indexOf(event); | ||
| const index = this.events.findIndex((event) => event.id == id); | ||
| if (index > -1) { | ||
| this.events.splice(index, 1); | ||
| } | ||
| }, | ||
| selectEvent(event: Event) { | ||
| if (this.selectedEvent == event) { | ||
| return; | ||
| } | ||
| this.selectedEvent = event; | ||
| this.selectedEvent.cars = []; | ||
| }, | ||
| addCar(car: Car) { | ||
| this.selectedEvent?.cars?.push(car); | ||
| }, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: IMO the share button would be cleaner as a little link icon next to the title. But I don't use this app nearly as much as you, so do what you feel is best :)