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