feat: 검색 모드 켬/끔 추가

This commit is contained in:
2021-12-08 21:01:16 +09:00
parent 8d322a51db
commit 5ce6035192
+47 -19
View File
@@ -63,7 +63,13 @@
<div class="idx_pad center d-grid" @click="toggleTurn(turnIdx)"> <div class="idx_pad center d-grid" @click="toggleTurn(turnIdx)">
<b-button <b-button
size="sm" size="sm"
:variant="pressed[turnIdx] ? 'info' : ((turnIdx==0&&pressed.filter(t=>t).length==0)?'success':'primary')" :variant="
pressed[turnIdx]
? 'info'
: turnIdx == 0 && pressed.filter((t) => t).length == 0
? 'success'
: 'primary'
"
>{{ turnIdx + 1 }}</b-button >{{ turnIdx + 1 }}</b-button
> >
</div> </div>
@@ -128,7 +134,17 @@
</div> </div>
</div> </div>
<div class="row gx-0"> <div class="row gx-0">
<div class="col-9"> <div class="col-2 d-grid">
<b-button
:pressed="searchMode"
@click="searchCommand()"
:variant="searchMode?'info':'primary'"
v-b-tooltip.hover
title="검색 기능을 활성화합니다."
><i class="bi bi-search"></i
></b-button>
</div>
<div class="col-7">
<v-multiselect <v-multiselect
v-model="selectedCommand" v-model="selectedCommand"
:allow-empty="false" :allow-empty="false"
@@ -147,6 +163,7 @@
deselectGroupLabel="" deselectGroupLabel=""
placeholder="턴 선택" placeholder="턴 선택"
:maxHeight="400" :maxHeight="400"
:searchable="searchMode"
> >
<template v-slot:noResult>검색 결과가 없습니다.</template> <template v-slot:noResult>검색 결과가 없습니다.</template>
<template v-slot:option="props" <template v-slot:option="props"
@@ -163,12 +180,9 @@
>▼</span >▼</span
> >
<span class="compensateNeutral" v-else></span> <span class="compensateNeutral" v-else></span>
<span :class="[ <span :class="[props.option.possible ? '' : 'commandImpossible']">
props.option.possible?'':'commandImpossible',
]">
{{ props.option.title }} {{ props.option.title }}
</span> </span>
</template> </template>
<template v-else-if="props.option.category"> <template v-else-if="props.option.category">
{{ props.option.category }} {{ props.option.category }}
@@ -217,7 +231,7 @@ declare const commandList: {
values: commandItem[]; values: commandItem[];
}[]; }[];
declare const serverNow: string; declare const serverNow: string;
declare const serverID: string;
type TurnObj = { type TurnObj = {
action: string; action: string;
brief: string; brief: string;
@@ -273,6 +287,8 @@ function isDropdownChildren(e?: Event): boolean {
return false; return false;
} }
const searchModeKey = `sammo_${serverID}_searchMode`;
export default defineComponent({ export default defineComponent({
name: "ReservedCommand", name: "ReservedCommand",
@@ -394,10 +410,12 @@ export default defineComponent({
} }
style.color = "#aaffff"; style.color = "#aaffff";
tooltip.push(`자율 행동 기간: ${autorunLimitYear}년 ${autorunLimitMonth}월까지`); tooltip.push(
`자율 행동 기간: ${autorunLimitYear}년 ${autorunLimitMonth}월까지`
);
} }
if(mb_strwidth(brief) > 22){ if (mb_strwidth(brief) > 22) {
tooltip.push(brief); tooltip.push(brief);
} }
@@ -406,7 +424,7 @@ export default defineComponent({
year, year,
month, month,
time: formatTime(nextTurnTime, "HH:mm"), time: formatTime(nextTurnTime, "HH:mm"),
tooltip: tooltip.length==0?undefined:tooltip.join("\n"), tooltip: tooltip.length == 0 ? undefined : tooltip.join("\n"),
style, style,
}); });
@@ -429,7 +447,7 @@ export default defineComponent({
turnList.push(turnIdx); turnList.push(turnIdx);
} }
if(turnList.length == 0){ if (turnList.length == 0) {
turnList.push(0); turnList.push(0);
} }
@@ -459,6 +477,11 @@ export default defineComponent({
} }
await this.reloadCommandList(); await this.reloadCommandList();
}, },
searchCommand() {
const searchMode = !this.searchMode;
this.searchMode = searchMode;
localStorage.setItem(searchModeKey, searchMode ? "1" : "0");
},
}, },
data() { data() {
const serverNowObj = parseTime(serverNow); const serverNowObj = parseTime(serverNow);
@@ -473,16 +496,20 @@ export default defineComponent({
//pressed[0] = true; //pressed[0] = true;
const selectedCommand = commandList[0].values[0]; const selectedCommand = commandList[0].values[0];
for(const subCategory of commandList){ for (const subCategory of commandList) {
for(const command of subCategory.values){ for (const command of subCategory.values) {
if(command.searchText){ if (command.searchText) {
continue; continue;
} }
const [filteredTextH, filteredTextA] = filter초성withAlphabet(command.simpleName.replace(/\s+/g, '')); const [filteredTextH, filteredTextA] = filter초성withAlphabet(
command.searchText = `${command.simpleName} ${filteredTextH} ${filteredTextA}` command.simpleName.replace(/\s+/g, "")
);
command.searchText = `${command.simpleName} ${filteredTextH} ${filteredTextA}`;
} }
} }
const searchMode = (localStorage.getItem(searchModeKey) ?? "1") != "0";
const emptyTurn: TurnObjWithTime[] = Array.from<TurnObjWithTime>({ const emptyTurn: TurnObjWithTime[] = Array.from<TurnObjWithTime>({
length: maxTurn, length: maxTurn,
}).fill({ }).fill({
@@ -506,6 +533,7 @@ export default defineComponent({
selectedCommand, selectedCommand,
reservedCommandList: emptyTurn, reservedCommandList: emptyTurn,
autorun_limit: null as null | number, autorun_limit: null as null | number,
searchMode,
}; };
}, },
mounted() { mounted() {
@@ -535,12 +563,12 @@ export default defineComponent({
margin-left: 10px; margin-left: 10px;
.turn_pad { .turn_pad {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.multiselect__content-wrapper { .multiselect__content-wrapper {
width: 133.3%; margin-left: calc(-100% / 7 * 2);
width: calc(100% / 7 * 12);
} }
.multiselect__single { .multiselect__single {
@@ -561,7 +589,7 @@ export default defineComponent({
margin-top: 10px; margin-top: 10px;
margin-bottom: 10px; margin-bottom: 10px;
.btn{ .btn {
transition: none !important; transition: none !important;
} }
} }