mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 19:48:11 +00:00
Poprawka drag&drop
This commit is contained in:
@@ -35,6 +35,19 @@
|
|||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="input_list type">
|
||||||
|
<select
|
||||||
|
id="cargo-list"
|
||||||
|
v-model="store.cargoOptions"
|
||||||
|
>
|
||||||
|
<option :value="null" disabled>Wybierz wagon</option>
|
||||||
|
|
||||||
|
<option v-for="cargo in store.cargoOptions" >
|
||||||
|
{{ cargo }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="input_ready-stock">
|
<div class="input_ready-stock">
|
||||||
<button class="btn" @click="setReadyStockList(true)"><b>REALNE ZESTAWIENIA</b></button>
|
<button class="btn" @click="setReadyStockList(true)"><b>REALNE ZESTAWIENIA</b></button>
|
||||||
<ready-stock-list />
|
<ready-stock-list />
|
||||||
@@ -68,13 +81,8 @@ export default defineComponent({
|
|||||||
setup() {
|
setup() {
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
|
|
||||||
const isReadyStockListOpen = ref(false);
|
|
||||||
|
|
||||||
provide('isReadyStockListOpen', isReadyStockListOpen);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
store,
|
store,
|
||||||
isReadyStockListOpen,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -115,7 +123,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
setReadyStockList(bool = false) {
|
setReadyStockList(bool = false) {
|
||||||
this.isReadyStockListOpen = bool;
|
this.store.isRealStockListCardOpen = bool;
|
||||||
},
|
},
|
||||||
|
|
||||||
onVehicleSelect(type: 'loco' | 'car') {
|
onVehicleSelect(type: 'loco' | 'car') {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
<div class="warning" v-if="warnings.tooManyLocos.value">Ten skład posiada za dużo pojazdów trakcyjnych!</div>
|
<div class="warning" v-if="warnings.tooManyLocos.value">Ten skład posiada za dużo pojazdów trakcyjnych!</div>
|
||||||
</div> -->
|
</div> -->
|
||||||
|
|
||||||
<ul ref="list" data-ignore-outside="1">
|
<ul ref="list" >
|
||||||
<li v-if="store.stockList.length == 0" class="list-empty">
|
<li v-if="store.stockList.length == 0" class="list-empty">
|
||||||
<div class="item-content">Lista pojazdów jest pusta!</div>
|
<div class="item-content">Lista pojazdów jest pusta!</div>
|
||||||
</li>
|
</li>
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
:data-id="i"
|
:data-id="i"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
@focus="onListItemFocus(i)"
|
@focus="onListItemFocus(i)"
|
||||||
:ref="`item-${i}`"
|
ref="itemRefs"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
class="item-content"
|
class="item-content"
|
||||||
@@ -147,8 +147,10 @@ export default defineComponent({
|
|||||||
|
|
||||||
const attr = targetNode.attributes.getNamedItem('data-ignore-outside');
|
const attr = targetNode.attributes.getNamedItem('data-ignore-outside');
|
||||||
|
|
||||||
if (!attr && targetNode.tagName.toLowerCase() != 'select' && targetNode.tagName.toLowerCase() != 'option')
|
if (!attr && !/select|option/i.test(targetNode.tagName)) {
|
||||||
|
console.log(targetNode.tagName);
|
||||||
this.store.chosenStockListIndex = -1;
|
this.store.chosenStockListIndex = -1;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -198,7 +200,7 @@ export default defineComponent({
|
|||||||
onListItemFocus(vehicleID: number) {
|
onListItemFocus(vehicleID: number) {
|
||||||
const vehicle = this.store.stockList[vehicleID];
|
const vehicle = this.store.stockList[vehicleID];
|
||||||
|
|
||||||
this.store.chosenStockListIndex = vehicleID;
|
// this.store.chosenStockListIndex = vehicleID;
|
||||||
|
|
||||||
if (this.store.chosenVehicle?.imageSrc != vehicle.imgSrc) this.store.imageLoading = true;
|
if (this.store.chosenVehicle?.imageSrc != vehicle.imgSrc) this.store.imageLoading = true;
|
||||||
|
|
||||||
@@ -323,17 +325,13 @@ export default defineComponent({
|
|||||||
onDrop(e: DragEvent, vehicleIndex: number) {
|
onDrop(e: DragEvent, vehicleIndex: number) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
let targetEl: Element | null = this.$refs[`item-${vehicleIndex}`] as Element;
|
let targetEl = (this.$refs['itemRefs'] as Element[])[vehicleIndex];
|
||||||
|
|
||||||
if (!targetEl) return;
|
if (!targetEl) return;
|
||||||
|
|
||||||
const dataID = targetEl.attributes.getNamedItem('data-id')?.textContent;
|
const tempVehicle = this.store.stockList[vehicleIndex];
|
||||||
|
|
||||||
if (!dataID) return;
|
this.store.stockList[vehicleIndex] = this.store.stockList[this.draggedVehicleID];
|
||||||
|
|
||||||
const tempVehicle = this.store.stockList[Number(dataID)];
|
|
||||||
|
|
||||||
this.store.stockList[Number(dataID)] = this.store.stockList[this.draggedVehicleID];
|
|
||||||
this.store.stockList[this.draggedVehicleID] = tempVehicle;
|
this.store.stockList[this.draggedVehicleID] = tempVehicle;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="ready-stock-list" v-if="isOpen">
|
<div class="ready-stock-list" v-if="store.isRealStockListCardOpen">
|
||||||
<div class="top-sticky">
|
<div class="top-sticky">
|
||||||
<button class="btn btn--text exit" @click="exit">< POWRÓT</button>
|
<button class="btn btn--text exit" @click="store.isRealStockListCardOpen = false">< POWRÓT</button>
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>
|
<h1>
|
||||||
@@ -65,7 +65,6 @@ export default defineComponent({
|
|||||||
data: () => ({
|
data: () => ({
|
||||||
responseStatus: 'loading',
|
responseStatus: 'loading',
|
||||||
isMobile: 'ontouchstart' in document.documentElement && navigator.userAgent.match(/Mobi/) ? true : false,
|
isMobile: 'ontouchstart' in document.documentElement && navigator.userAgent.match(/Mobi/) ? true : false,
|
||||||
isOpen: false,
|
|
||||||
|
|
||||||
readyStockList: {} as ReadyStockList,
|
readyStockList: {} as ReadyStockList,
|
||||||
searchedReadyStockName: '',
|
searchedReadyStockName: '',
|
||||||
@@ -97,10 +96,6 @@ export default defineComponent({
|
|||||||
return new URL(`./dir/${name}.png`, import.meta.url).href;
|
return new URL(`./dir/${name}.png`, import.meta.url).href;
|
||||||
},
|
},
|
||||||
|
|
||||||
exit() {
|
|
||||||
this.isOpen = false;
|
|
||||||
},
|
|
||||||
|
|
||||||
openPreview(e: Event, type: string, number: string) {
|
openPreview(e: Event, type: string, number: string) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -134,7 +129,7 @@ export default defineComponent({
|
|||||||
this.addVehicle(vehicle);
|
this.addVehicle(vehicle);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.exit();
|
this.store.isRealStockListCardOpen = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
addVehicle(vehicle: Vehicle | null) {
|
addVehicle(vehicle: Vehicle | null) {
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export const useStore = defineStore({
|
|||||||
vehiclePreviewSrc: '',
|
vehiclePreviewSrc: '',
|
||||||
|
|
||||||
isRandomizerCardOpen: false,
|
isRandomizerCardOpen: false,
|
||||||
|
isRealStockListCardOpen: false,
|
||||||
|
|
||||||
|
|
||||||
} as IStore),
|
} as IStore),
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export interface IStore {
|
|||||||
vehiclePreviewSrc: string;
|
vehiclePreviewSrc: string;
|
||||||
|
|
||||||
isRandomizerCardOpen: boolean;
|
isRandomizerCardOpen: boolean;
|
||||||
|
isRealStockListCardOpen: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IVehicleData {
|
export interface IVehicleData {
|
||||||
@@ -75,3 +76,4 @@ export interface IStock {
|
|||||||
imgSrc: string;
|
imgSrc: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user