mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-04 03:58:11 +00:00
feat: turning around rolling stock
This commit is contained in:
@@ -67,6 +67,16 @@
|
||||
>
|
||||
<Shuffle :stroke-width="2.5" />
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn btn--image"
|
||||
:data-disabled="stockIsEmpty"
|
||||
:disabled="stockIsEmpty"
|
||||
@click="turnAroundCars"
|
||||
:data-button-tooltip="$t('stocklist.action-switch')"
|
||||
>
|
||||
<Repeat :stroke-width="2.5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="actions-bottom" :data-disabled="store.chosenStockListIndex == -1">
|
||||
@@ -201,6 +211,22 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
|
||||
turnAroundCars() {
|
||||
if (this.store.stockList.length <= 1) return;
|
||||
|
||||
const isFirstTractionUnit = isTractionUnit(this.store.stockList[0].vehicleRef);
|
||||
|
||||
const sliceToSwap = isFirstTractionUnit
|
||||
? this.store.stockList.slice(1)
|
||||
: this.store.stockList.slice();
|
||||
|
||||
sliceToSwap.reverse();
|
||||
|
||||
if (isFirstTractionUnit) sliceToSwap.unshift(this.store.stockList[0]);
|
||||
|
||||
this.store.stockList = sliceToSwap;
|
||||
},
|
||||
|
||||
downloadStock() {
|
||||
if (this.store.stockList.length == 0) return alert(this.$t('stocklist.alert-empty'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user