feat: rebuild Ref-compatible command editors
This commit is contained in:
@@ -8,6 +8,7 @@ import ChiefTurnCard from '../components/chief/ChiefTurnCard.vue';
|
||||
import ChiefCommandEditor from '../components/chief/ChiefCommandEditor.vue';
|
||||
import { trpc } from '../utils/trpc';
|
||||
import { formatOfficerLevelText } from '../utils/nationFormat';
|
||||
import type { CommandPatternEntry } from '../components/command/types';
|
||||
|
||||
type ChiefTurn = {
|
||||
index: number;
|
||||
@@ -103,6 +104,9 @@ type TurnRow = {
|
||||
time: string;
|
||||
action: string;
|
||||
isRest: boolean;
|
||||
args: unknown;
|
||||
label: string;
|
||||
actionCode: string;
|
||||
};
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -243,6 +247,9 @@ const buildTurnRows = (chief: ChiefEntry): TurnRow[] => {
|
||||
index: turn.index,
|
||||
time: timeLabel,
|
||||
action: actionLabel,
|
||||
label: actionLabel,
|
||||
actionCode: turn.action,
|
||||
args: turn.args,
|
||||
isRest: turn.action === '휴식',
|
||||
};
|
||||
});
|
||||
@@ -296,14 +303,12 @@ const shiftTurns = async (amount: number) => {
|
||||
}
|
||||
};
|
||||
|
||||
const reserveTurn = async (payload: { index: number; action: string; args: Record<string, unknown> }) => {
|
||||
const reserveTurns = async (entries: CommandPatternEntry[]) => {
|
||||
if (!data.value || !isEditingAllowed.value) return;
|
||||
try {
|
||||
const result = await trpc.turns.reserved.setNation.mutate({
|
||||
const result = await trpc.turns.reserved.setNationBulk.mutate({
|
||||
generalId: data.value.me.id,
|
||||
turnIndex: payload.index,
|
||||
action: payload.action,
|
||||
args: payload.args,
|
||||
entries,
|
||||
expectedRevision: selectedChief.value?.revision ?? 0,
|
||||
});
|
||||
updateMyTurns(result.turns, result.revision);
|
||||
@@ -352,8 +357,10 @@ const repeatTurns = async (amount: number) => {
|
||||
:rows="selectedChiefRows"
|
||||
:command-table="commandTable"
|
||||
:loading="commandLoading"
|
||||
:general-id="data.me.id"
|
||||
:officer-level="selectedChief.officerLevel"
|
||||
:mobile="true"
|
||||
@reserve="reserveTurn"
|
||||
@reserve-bulk="reserveTurns"
|
||||
@shift="shiftTurns"
|
||||
@repeat="repeatTurns"
|
||||
/>
|
||||
@@ -411,7 +418,9 @@ const repeatTurns = async (amount: number) => {
|
||||
:rows="chief.rows"
|
||||
:command-table="commandTable"
|
||||
:loading="commandLoading"
|
||||
@reserve="reserveTurn"
|
||||
:general-id="data.me.id"
|
||||
:officer-level="chief.officerLevel"
|
||||
@reserve-bulk="reserveTurns"
|
||||
@shift="shiftTurns"
|
||||
@repeat="repeatTurns"
|
||||
/>
|
||||
|
||||
@@ -20,6 +20,7 @@ import { formatLog } from '../utils/formatLog';
|
||||
import { useSessionStore } from '../stores/session';
|
||||
import { useMainDashboardStore } from '../stores/mainDashboard';
|
||||
import { trpc } from '../utils/trpc';
|
||||
import type { CommandPatternEntry } from '../components/command/types';
|
||||
|
||||
const session = useSessionStore();
|
||||
const dashboard = useMainDashboardStore();
|
||||
@@ -40,12 +41,10 @@ const {
|
||||
nation,
|
||||
worldMap,
|
||||
mapLayout,
|
||||
selectedCity,
|
||||
commandTable,
|
||||
messages,
|
||||
boardAccess,
|
||||
reservedGeneralTurns,
|
||||
reservedNationTurns,
|
||||
globalRecords,
|
||||
generalRecords,
|
||||
worldHistory,
|
||||
@@ -94,20 +93,16 @@ onUnmounted(() => {
|
||||
}
|
||||
});
|
||||
|
||||
const reserveGeneralTurn = (payload: { index: number; action: string; args: Record<string, unknown> }) => {
|
||||
void dashboard.setGeneralTurn(payload.index, payload.action, payload.args);
|
||||
};
|
||||
|
||||
const shiftGeneralTurns = (amount: number) => {
|
||||
void dashboard.shiftGeneralTurns(amount);
|
||||
};
|
||||
|
||||
const reserveNationTurn = (payload: { index: number; action: string; args: Record<string, unknown> }) => {
|
||||
void dashboard.setNationTurn(payload.index, payload.action, payload.args);
|
||||
const reserveGeneralTurns = (entries: CommandPatternEntry[]) => {
|
||||
void dashboard.setGeneralTurns(entries);
|
||||
};
|
||||
|
||||
const shiftNationTurns = (amount: number) => {
|
||||
void dashboard.shiftNationTurns(amount);
|
||||
const repeatGeneralTurns = (amount: number) => {
|
||||
void dashboard.repeatGeneralTurns(amount);
|
||||
};
|
||||
|
||||
const loadMainData = async () => {
|
||||
@@ -206,14 +201,14 @@ watch(
|
||||
<CommandListPanel
|
||||
:command-table="commandTable"
|
||||
:loading="loading"
|
||||
:selected-city="selectedCity"
|
||||
:reserved-general-turns="reservedGeneralTurns"
|
||||
:reserved-nation-turns="reservedNationTurns"
|
||||
:general="general"
|
||||
@set-general-turn="reserveGeneralTurn"
|
||||
:current-year="lobbyInfo?.year"
|
||||
:current-month="lobbyInfo?.month"
|
||||
:turn-term-minutes="lobbyInfo?.turnTerm"
|
||||
@set-general-turns="reserveGeneralTurns"
|
||||
@shift-general-turns="shiftGeneralTurns"
|
||||
@set-nation-turn="reserveNationTurn"
|
||||
@shift-nation-turns="shiftNationTurns"
|
||||
@repeat-general-turns="repeatGeneralTurns"
|
||||
/>
|
||||
</PanelCard>
|
||||
</div>
|
||||
@@ -329,14 +324,14 @@ watch(
|
||||
<CommandListPanel
|
||||
:command-table="commandTable"
|
||||
:loading="loading"
|
||||
:selected-city="selectedCity"
|
||||
:reserved-general-turns="reservedGeneralTurns"
|
||||
:reserved-nation-turns="reservedNationTurns"
|
||||
:general="general"
|
||||
@set-general-turn="reserveGeneralTurn"
|
||||
:current-year="lobbyInfo?.year"
|
||||
:current-month="lobbyInfo?.month"
|
||||
:turn-term-minutes="lobbyInfo?.turnTerm"
|
||||
@set-general-turns="reserveGeneralTurns"
|
||||
@shift-general-turns="shiftGeneralTurns"
|
||||
@set-nation-turn="reserveNationTurn"
|
||||
@shift-nation-turns="shiftNationTurns"
|
||||
@repeat-general-turns="repeatGeneralTurns"
|
||||
/>
|
||||
</PanelCard>
|
||||
<PanelCard title="도시 정보" data-main-target="city">
|
||||
|
||||
Reference in New Issue
Block a user