@rkosafo/cai.components 0.0.71 → 0.0.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
class:bg-white={!isRead && !isChecked}
|
|
47
47
|
class:shadow={!isRead && !isChecked}
|
|
48
48
|
class:border={!isRead && !isChecked}
|
|
49
|
+
class:border-gray-300={!isRead && !isChecked}
|
|
49
50
|
class="flex items-center border-y px-2"
|
|
50
51
|
role="button"
|
|
51
52
|
tabindex="0"
|
|
@@ -61,7 +62,7 @@
|
|
|
61
62
|
}}
|
|
62
63
|
/>
|
|
63
64
|
<div class="my-1 flex w-full cursor-pointer items-center justify-between p-1">
|
|
64
|
-
<div class="flex w-full
|
|
65
|
+
<div class="flex w-full items-center">
|
|
65
66
|
<div class="flex">
|
|
66
67
|
<div class="mr-4 flex items-center gap-1 space-x-1">
|
|
67
68
|
<button
|
|
@@ -98,7 +99,7 @@
|
|
|
98
99
|
<span class="mx-1">-</span>
|
|
99
100
|
</div>
|
|
100
101
|
|
|
101
|
-
<p class="
|
|
102
|
+
<p class=" max-l truncate text-sm text-gray-600 xl:max-w-2xl 2xl:max-w-5xl">{message}</p>
|
|
102
103
|
</div>
|
|
103
104
|
<div class="flex w-32 shrink-0 items-center justify-end">
|
|
104
105
|
<span class="text-sm" class:font-bold={!isRead} class:text-gray-500={isRead}>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { PageInfo } from '../../utils/paginate.svelte.js';
|
|
18
18
|
import AlertDialog from '../../ui/alertDialog/AlertDialog.svelte';
|
|
19
19
|
import MailingMessageViewer from './MailingMessageViewer.svelte';
|
|
20
|
+
import debounce from 'lodash/debounce';
|
|
20
21
|
|
|
21
22
|
let {
|
|
22
23
|
showSidePanel = true,
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
toggleArchieve = async (id: string | number) => {
|
|
43
44
|
return { success: false, data: null, error: null } as any;
|
|
44
45
|
},
|
|
45
|
-
toggleAsRead = async (id: string | number) => {
|
|
46
|
+
toggleAsRead = async (id: string | number, type?: MailMarkReadToggleType) => {
|
|
46
47
|
return { success: false, data: null, error: null } as any;
|
|
47
48
|
},
|
|
48
49
|
toggleFavourite = async (id: string | number) => {
|
|
@@ -73,6 +74,8 @@
|
|
|
73
74
|
let selectedMessages = $state<number[]>([]);
|
|
74
75
|
let messageSelected = $state<number>(0);
|
|
75
76
|
|
|
77
|
+
let paginationInfo = new PageInfo();
|
|
78
|
+
|
|
76
79
|
function toggleSideBar(val: MailMenu) {
|
|
77
80
|
const { title } = val;
|
|
78
81
|
if (title === 'Inbox') activeBox = 'inbox';
|
|
@@ -197,7 +200,7 @@
|
|
|
197
200
|
const results = [];
|
|
198
201
|
|
|
199
202
|
for (const msg of selectedMessages) {
|
|
200
|
-
const res = await toggleAsRead(msg);
|
|
203
|
+
const res = await toggleAsRead(msg, val);
|
|
201
204
|
results.push(res);
|
|
202
205
|
}
|
|
203
206
|
selectedMessages = [];
|
|
@@ -318,11 +321,31 @@
|
|
|
318
321
|
|
|
319
322
|
function updatePageInfo(val: MailPageInfo) {
|
|
320
323
|
// console.log({ val });
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
324
|
+
paginationInfo.totalItems = 1;
|
|
325
|
+
paginationInfo.setHasNextPage(val.hasNextPage);
|
|
326
|
+
paginationInfo.setHasPrevPage(val.hasPreviousPage);
|
|
327
|
+
paginationInfo.setTotalPages(1);
|
|
328
|
+
paginationInfo.setPageSize(1);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
const debouncedSearch = debounce(fetchData, 300);
|
|
332
|
+
|
|
333
|
+
function handleSearch(val: string) {
|
|
334
|
+
// query = val;
|
|
335
|
+
debouncedSearch(pageNumber, { search: val }, activeBox);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
async function getIsRead(id: number): Promise<boolean> {
|
|
339
|
+
let status = false;
|
|
340
|
+
try {
|
|
341
|
+
const ret = await readAMessage(id);
|
|
342
|
+
if (!ret?.success) {
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
status = ret.data?.isRead || false;
|
|
346
|
+
return status;
|
|
347
|
+
} catch (error) {}
|
|
348
|
+
return status;
|
|
326
349
|
}
|
|
327
350
|
|
|
328
351
|
$effect(() => {
|
|
@@ -333,15 +356,13 @@
|
|
|
333
356
|
<div class="h-full w-full">
|
|
334
357
|
<div class="flex h-full w-full gap-2">
|
|
335
358
|
<div class:hidden={!showSidePanel} class="loginbox h-full w-20 rounded-md bg-white">
|
|
336
|
-
<MailSidebar onClick={toggleSideBar} menus={menutItems} {setActiveMenu}
|
|
337
|
-
|
|
338
|
-
/>
|
|
359
|
+
<MailSidebar onClick={toggleSideBar} menus={menutItems} {setActiveMenu} />
|
|
339
360
|
</div>
|
|
340
361
|
<div class="flex w-full flex-grow flex-col gap-1">
|
|
341
362
|
<div class="loginbox h-14 rounded bg-white px-4">
|
|
342
363
|
<MailToolBar
|
|
343
364
|
isFavoriteActive={false}
|
|
344
|
-
isReadActive={
|
|
365
|
+
isReadActive={async () => await getIsRead(messageSelected)}
|
|
345
366
|
showBackButton={Boolean(messageSelected)}
|
|
346
367
|
{showPagination}
|
|
347
368
|
{showComposeButton}
|
|
@@ -357,7 +378,8 @@
|
|
|
357
378
|
onMarkAsSpamClick={handleMarkAsSpam}
|
|
358
379
|
onToggleMarkReadClick={handleMarkAsRead}
|
|
359
380
|
onToggleFavoriteClick={handleMarkAsFavorite}
|
|
360
|
-
|
|
381
|
+
onsearchChange={handleSearch}
|
|
382
|
+
onBackClick={() => {
|
|
361
383
|
messageSelected = 0;
|
|
362
384
|
selectedMessages = [];
|
|
363
385
|
}}
|
|
@@ -367,11 +389,11 @@
|
|
|
367
389
|
}}
|
|
368
390
|
selectedMails={selectedMessages}
|
|
369
391
|
pageInfo={{
|
|
370
|
-
currentPage: pageInfo.currentPage,
|
|
371
|
-
pageSize: pageInfo.pageSize,
|
|
372
|
-
totalCount: pageInfo.totalItems,
|
|
373
|
-
hasNextPage: pageInfo.hasNextPage,
|
|
374
|
-
hasPreviousPage: pageInfo.hasPrevPage
|
|
392
|
+
currentPage: !messageSelected ? pageInfo.currentPage : paginationInfo.currentPage,
|
|
393
|
+
pageSize: !messageSelected ? pageInfo.pageSize : paginationInfo.pageSize,
|
|
394
|
+
totalCount: !messageSelected ? pageInfo.totalItems : paginationInfo.totalItems,
|
|
395
|
+
hasNextPage: !messageSelected ? pageInfo.hasNextPage : paginationInfo.hasNextPage,
|
|
396
|
+
hasPreviousPage: !messageSelected ? pageInfo.hasPrevPage : paginationInfo.hasPrevPage
|
|
375
397
|
}}
|
|
376
398
|
/>
|
|
377
399
|
</div>
|
|
@@ -67,7 +67,7 @@ export interface MailingModuleProps {
|
|
|
67
67
|
toggleArchieve?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
68
68
|
toggleSpam?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
69
69
|
deleteEntry?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
70
|
-
toggleAsRead?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
70
|
+
toggleAsRead?: (id: string | number, type?: MailMarkReadToggleType) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
71
71
|
toggleFavourite?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
72
72
|
toggelImportant?: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|
|
73
73
|
readAMessage: (id: string | number) => Promise<CrudResult<any>> | CrudResult<any> | null;
|