Skip to content

Commit 491c938

Browse files
authored
Merge pull request #402 from iceljc/features/refine-chat-window
Features/refine chat window
2 parents 6e754ee + b0d1d0d commit 491c938

File tree

2 files changed

+41
-18
lines changed

2 files changed

+41
-18
lines changed

src/lib/scss/custom/pages/_agent.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
gap: 15px;
66
align-items: center;
77

8-
@media (max-width: 576px) {
8+
@media (max-width: 1024px) {
99
flex-direction: column;
1010
justify-content: center;
1111
gap: 12px;
@@ -23,7 +23,7 @@
2323
gap: 10px;
2424
align-items: center;
2525

26-
@media (max-width: 576px) {
26+
@media (max-width: 1024px) {
2727
width: 100%;
2828
flex-direction: column;
2929
gap: 8px;

src/routes/page/agent/+page.svelte

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@
6161
/** @type {import('$commonTypes').LabelValuePair[]} */
6262
let agentLabelOptions = [];
6363
64-
/** @type {string[]} */
65-
let selectedAgentTypes = [];
66-
/** @type {string[]} */
67-
let selectedAgentLabels = [];
64+
/** @type {{ name: string, types: string[], labels: string[] }} */
65+
let searchItem = {
66+
name: '',
67+
types: [],
68+
labels: []
69+
};
6870
6971
onMount(async () => {
7072
isPageMounted = true;
@@ -98,8 +100,8 @@
98100
page: firstPage,
99101
count: 0
100102
},
101-
types: selectedAgentTypes?.length > 0 ? selectedAgentTypes : null,
102-
labels: selectedAgentLabels?.length > 0 ? selectedAgentLabels : null,
103+
types: searchItem.types?.length > 0 ? searchItem.types : null,
104+
labels: searchItem.labels?.length > 0 ? searchItem.labels : null,
103105
similarName: event.payload?.trim() || null
104106
};
105107
@@ -221,17 +223,34 @@
221223
222224
getPagedAgents();
223225
}
226+
227+
/** @param {any} e */
228+
function changeSearchName(e) {
229+
searchItem.name = e.target.value || '';
230+
filter = {
231+
...filter,
232+
similarName: searchItem.name?.trim()
233+
};
234+
}
235+
236+
/** @param {any} e */
237+
function searchKeyDown(e) {
238+
if (e.key === 'Enter' && filter?.similarName) {
239+
e.preventDefault();
240+
search();
241+
}
242+
}
224243
225244
/** @param {any} e */
226245
function selectAgentTypeOption(e) {
227246
// @ts-ignore
228-
selectedAgentTypes = e.detail.selecteds?.map(x => x.label) || [];
247+
searchItem.types = e.detail.selecteds?.map(x => x.label) || [];
229248
}
230249
231250
/** @param {any} e */
232251
function selectAgentLabelOption(e) {
233252
// @ts-ignore
234-
selectedAgentLabels = e.detail.selecteds?.map(x => x.label) || [];
253+
searchItem.labels = e.detail.selecteds?.map(x => x.label) || [];
235254
}
236255
237256
function search() {
@@ -241,8 +260,11 @@
241260
}
242261
243262
function reset() {
244-
selectedAgentTypes = [];
245-
selectedAgentLabels = [];
263+
searchItem = {
264+
name: '',
265+
types: [],
266+
labels: []
267+
};
246268
247269
filter = { ...initFilter };
248270
getPagedAgents();
@@ -251,8 +273,8 @@
251273
function refreshFilter() {
252274
filter = {
253275
...filter,
254-
types: selectedAgentTypes?.length > 0 ? selectedAgentTypes : null,
255-
labels: selectedAgentLabels?.length > 0 ? selectedAgentLabels : null,
276+
types: searchItem.types?.length > 0 ? searchItem.types : null,
277+
labels: searchItem.labels?.length > 0 ? searchItem.labels : null,
256278
pager: initFilter.pager
257279
};
258280
}
@@ -285,16 +307,17 @@
285307
type="text"
286308
placeholder="Search by name"
287309
style="width: fit-content;"
288-
value={filter.similarName}
289-
on:input={e => filter.similarName = e.target.value?.trim()}
310+
value={searchItem.name}
311+
on:input={e => changeSearchName(e)}
312+
on:keydown={e => searchKeyDown(e)}
290313
/>
291314
<Select
292315
tag={'agent-label-select'}
293316
placeholder={'Select labels'}
294317
selectedText={'labels'}
295318
multiSelect
296319
searchMode
297-
selectedValues={selectedAgentLabels}
320+
selectedValues={searchItem.labels}
298321
options={agentLabelOptions}
299322
on:select={e => selectAgentLabelOption(e)}
300323
/>
@@ -304,7 +327,7 @@
304327
selectedText={'types'}
305328
multiSelect
306329
searchMode
307-
selectedValues={selectedAgentTypes}
330+
selectedValues={searchItem.types}
308331
options={agentTypeOptions}
309332
on:select={e => selectAgentTypeOption(e)}
310333
/>

0 commit comments

Comments
 (0)