mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore(journal): added synching detailed timetable data with basic
This commit is contained in:
@@ -138,7 +138,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, defineComponent, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { RouteLocationRaw } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
@@ -167,15 +167,6 @@ const currentHistoryIndex = ref(0);
|
||||
|
||||
const timetableDetails = ref<API.TimetableHistory.Data | null>(null);
|
||||
|
||||
watch(
|
||||
computed(() => props.showExtraInfo),
|
||||
(state) => {
|
||||
if (state == true) {
|
||||
fetchTimetableDetails();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const stockHistory = computed(() => {
|
||||
return (
|
||||
timetableDetails.value?.stockHistory
|
||||
@@ -231,8 +222,12 @@ async function fetchTimetableDetails() {
|
||||
}
|
||||
}
|
||||
|
||||
function toggleExtraInfo() {
|
||||
emits('toggleExtraInfo', props.timetableId);
|
||||
async function toggleExtraInfo() {
|
||||
if (props.showExtraInfo == false) {
|
||||
await fetchTimetableDetails();
|
||||
}
|
||||
|
||||
emits('toggleExtraInfo', timetableDetails.value);
|
||||
}
|
||||
|
||||
function copyStockToClipboard() {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
<hr />
|
||||
|
||||
<div @click="toggleExtraInfo" style="cursor: pointer">
|
||||
<div style="cursor: pointer">
|
||||
<!-- Status -->
|
||||
<EntryStatus :timetable="timetableEntry" />
|
||||
</div>
|
||||
@@ -60,8 +60,8 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggleExtraInfo() {
|
||||
this.$emit('toggleShowExtraInfo');
|
||||
toggleExtraInfo(data: API.TimetableHistory.Data | null) {
|
||||
this.$emit('toggleShowExtraInfo', data);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
v-for="(timetableEntry, i) in timetableHistory"
|
||||
:key="timetableEntry.id"
|
||||
:timetableEntry="timetableEntry"
|
||||
:onToggleShowExtraInfo="() => toggleExtraInfo(timetableEntry.id)"
|
||||
:onToggleShowExtraInfo="toggleExtraInfo"
|
||||
:showExtraInfo="extraInfoIndexes.includes(timetableEntry.id)"
|
||||
/>
|
||||
</transition-group>
|
||||
@@ -59,6 +59,8 @@ export default defineComponent({
|
||||
JournalTimetableEntry
|
||||
},
|
||||
|
||||
emits: ['toggleExtraInfo'],
|
||||
|
||||
props: {
|
||||
timetableHistory: {
|
||||
type: Array as PropType<API.TimetableHistory.ResponseShort>,
|
||||
@@ -75,32 +77,23 @@ export default defineComponent({
|
||||
},
|
||||
dataStatus: {
|
||||
type: Number as PropType<Status.Data>
|
||||
},
|
||||
extraInfoIndexes: {
|
||||
type: Object as PropType<number[]>,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
Status,
|
||||
store: useMainStore(),
|
||||
extraInfoIndexes: [] as number[]
|
||||
store: useMainStore()
|
||||
};
|
||||
},
|
||||
|
||||
watch: {
|
||||
'$route.query': {
|
||||
deep: true,
|
||||
handler() {
|
||||
this.extraInfoIndexes.length = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
toggleExtraInfo(id: number) {
|
||||
const existingIdx = this.extraInfoIndexes.indexOf(id);
|
||||
|
||||
if (existingIdx != -1) this.extraInfoIndexes.splice(existingIdx, 1);
|
||||
else this.extraInfoIndexes.push(id);
|
||||
toggleExtraInfo(data: API.TimetableHistory.Data | null) {
|
||||
this.$emit('toggleExtraInfo', data);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -111,7 +104,7 @@ export default defineComponent({
|
||||
@use '../../../styles/journal-section';
|
||||
@use '../../../styles/responsive';
|
||||
|
||||
@include responsive.smallScreen{
|
||||
@include responsive.smallScreen {
|
||||
.journal_item-info {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user