mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 05:28:13 +00:00
chore: added new ID format; restored options of incrementing ID o save/copy
This commit is contained in:
@@ -92,6 +92,7 @@ import { LucideCopy, LucidePencil, LucideRotateCcw, LucideSave } from 'lucide-vu
|
|||||||
import { useStore } from '../../store/store';
|
import { useStore } from '../../store/store';
|
||||||
import { IOrderHeader, IOrderFooter, IStorageOrderData } from '../../types/orderTypes';
|
import { IOrderHeader, IOrderFooter, IStorageOrderData } from '../../types/orderTypes';
|
||||||
import StorageManager from '../../managers/storageManager';
|
import StorageManager from '../../managers/storageManager';
|
||||||
|
import { getOrderFullId } from '../../utils/orderUtils';
|
||||||
|
|
||||||
type TActionMonitType = 'warning' | 'info' | 'success';
|
type TActionMonitType = 'warning' | 'info' | 'success';
|
||||||
|
|
||||||
@@ -255,9 +256,15 @@ function hasHeaderFieldsComplete() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
function incrementOrderNo() {
|
function incrementOrderNo() {
|
||||||
// store.orderData. = (Number(order.header.orderNo) + 1).toString();
|
const idData = store.orderData.footer.Z.split('-');
|
||||||
|
|
||||||
|
if (idData.length == 4) {
|
||||||
|
const sceneryHash = idData[2];
|
||||||
|
let orderNumber = Number(idData[1]) || 0;
|
||||||
|
|
||||||
|
store.orderData.footer.Z = getOrderFullId(++orderNumber, sceneryHash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyMessage() {
|
function copyMessage() {
|
||||||
@@ -270,7 +277,7 @@ function copyMessage() {
|
|||||||
|
|
||||||
navigator.clipboard.writeText(orderMessagePreview.value);
|
navigator.clipboard.writeText(orderMessagePreview.value);
|
||||||
|
|
||||||
if (incrementOnCopy) incrementOrderNo();
|
if (incrementOnCopy.value) incrementOrderNo();
|
||||||
|
|
||||||
showActionMonit(t('order-message.success-copy-html'), 'success');
|
showActionMonit(t('order-message.success-copy-html'), 'success');
|
||||||
}
|
}
|
||||||
@@ -319,7 +326,7 @@ function saveOrder() {
|
|||||||
store.chosenLocalOrderId = nextOrderId;
|
store.chosenLocalOrderId = nextOrderId;
|
||||||
showActionMonit(t('order-message.success-save-html'), 'success');
|
showActionMonit(t('order-message.success-save-html'), 'success');
|
||||||
|
|
||||||
if (incrementOnSave) incrementOrderNo();
|
if (incrementOnSave.value) incrementOrderNo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateOrder() {
|
function updateOrder() {
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ import { API } from '../../types/apiTypes';
|
|||||||
import { ISceneryData } from '../../types/dataTypes';
|
import { ISceneryData } from '../../types/dataTypes';
|
||||||
import StorageManager from '../../managers/storageManager';
|
import StorageManager from '../../managers/storageManager';
|
||||||
import { getRegionNameById } from '../../utils/sceneryUtils';
|
import { getRegionNameById } from '../../utils/sceneryUtils';
|
||||||
|
import { getOrderFullId } from '../../utils/orderUtils';
|
||||||
|
|
||||||
const store = useStore();
|
const store = useStore();
|
||||||
const regions = ['eu', 'cae', 'usw', 'us', 'ru'];
|
const regions = ['eu', 'cae', 'usw', 'us', 'ru'];
|
||||||
@@ -238,11 +239,14 @@ function fillOrderData(train: API.ActiveTrains.Data) {
|
|||||||
store.orderData.footer.V = train.driverName;
|
store.orderData.footer.V = train.driverName;
|
||||||
store.orderData.footer.W = scenery.dispatcherName;
|
store.orderData.footer.W = scenery.dispatcherName;
|
||||||
|
|
||||||
const sceneryAbbrev = sceneriesData.value
|
const idData = store.orderData.footer.Z.split('-');
|
||||||
? (sceneriesData.value.find(({ name }) => name === scenery.stationName)?.abbr ?? null)
|
|
||||||
: null;
|
if (idData.length != 4) {
|
||||||
|
store.orderData.footer.Z = getOrderFullId(0, scenery.stationHash);
|
||||||
|
} else {
|
||||||
|
store.orderData.footer.Z = getOrderFullId(Number(idData[1]) || 0, scenery.stationHash);
|
||||||
|
}
|
||||||
|
|
||||||
store.orderData.footer.Z = `${sceneryAbbrev || scenery.stationName} ${StorageManager.getNumericValue('orderCount') || 1}`;
|
|
||||||
store.panelMode = 'OrderMessagePanel';
|
store.panelMode = 'OrderMessagePanel';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export const getOrderFullId = (orderNumber: string, sceneryHash: string) => {
|
export const getOrderFullId = (orderNumber: number, sceneryHash: string) => {
|
||||||
return `RD-${orderNumber}-${sceneryHash}-${new Date().getUTCFullYear().toString().slice(2)}`;
|
return `RD-${orderNumber}-${sceneryHash}-${new Date().getUTCFullYear().toString().slice(2)}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user