Skip to content

Commit 96a9277

Browse files
committed
ui(pages): improve bulk processing notifications
1 parent 792333a commit 96a9277

File tree

12 files changed

+513
-74
lines changed

12 files changed

+513
-74
lines changed

apps/client/src/layouts/PagesLayout/LeftSidebar/SelectedPages.vue

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
</template>
139139

140140
<script setup lang="ts">
141-
import { negateProp } from '@stdlib/misc';
141+
import { negateProp, pluralS } from '@stdlib/misc';
142142
import type { QNotifyUpdateOptions } from 'quasar';
143143
import { deletePage } from 'src/code/api-interface/pages/deletion/delete';
144144
import { movePage } from 'src/code/api-interface/pages/move';
@@ -162,6 +162,8 @@ async function movePages() {
162162
message: 'Moving pages...',
163163
});
164164
165+
const numTotal = pageSelectionStore().selectedPages.size;
166+
165167
let numSuccess = 0;
166168
let numFailed = 0;
167169
@@ -170,7 +172,7 @@ async function movePages() {
170172
).entries()) {
171173
try {
172174
notif({
173-
caption: `${index + 1} of ${pageSelectionStore().selectedPages.size}`,
175+
caption: `${index} of ${numTotal}`,
174176
});
175177
176178
await movePage({
@@ -187,23 +189,23 @@ async function movePages() {
187189
188190
let notifUpdateOptions: QNotifyUpdateOptions = {
189191
timeout: undefined,
192+
caption: undefined,
190193
};
191194
192195
if (numFailed === 0) {
193196
notifUpdateOptions = {
194197
...notifUpdateOptions,
195-
message: 'Pages moved successfully.',
198+
message: `Page${pluralS(numSuccess)} moved successfully.`,
196199
color: 'positive',
197200
};
198201
} else {
199202
notifUpdateOptions = {
200203
...notifUpdateOptions,
201-
message: `${
202-
numSuccess > 0 ? numSuccess : 'No'
203-
} pages were moved successfully.<br/>Failed to move ${numFailed} page${
204-
numFailed === 1 ? '' : 's'
205-
}.`,
206-
caption: undefined,
204+
message: `${numSuccess > 0 ? numSuccess : 'No'} page${
205+
numSuccess === 1 ? ' was' : 's were'
206+
} moved successfully.<br/>Failed to move ${numFailed} page${pluralS(
207+
numFailed,
208+
)}.`,
207209
color: 'negative',
208210
html: true,
209211
};
@@ -228,6 +230,8 @@ async function deletePages() {
228230
message: 'Deleting pages...',
229231
});
230232
233+
const numTotal = pageSelectionStore().selectedPages.size;
234+
231235
let numSuccess = 0;
232236
let numFailed = 0;
233237
@@ -236,7 +240,7 @@ async function deletePages() {
236240
).entries()) {
237241
try {
238242
notif({
239-
caption: `${index + 1} of ${pageSelectionStore().selectedPages.size}`,
243+
caption: `${index} of ${numTotal}`,
240244
});
241245
242246
await deletePage(pageId);
@@ -249,23 +253,23 @@ async function deletePages() {
249253
250254
let notifUpdateOptions: QNotifyUpdateOptions = {
251255
timeout: undefined,
256+
caption: undefined,
252257
};
253258
254259
if (numFailed === 0) {
255260
notifUpdateOptions = {
256261
...notifUpdateOptions,
257-
message: 'Pages deleted successfully.',
262+
message: `Page${pluralS(numSuccess)} deleted successfully.`,
258263
color: 'positive',
259264
};
260265
} else {
261266
notifUpdateOptions = {
262267
...notifUpdateOptions,
263-
message: `${
264-
numSuccess > 0 ? numSuccess : 'No'
265-
} pages were deleted successfully.<br/>Failed to delete ${numFailed} page${
266-
numFailed === 1 ? '' : 's'
267-
}.`,
268-
caption: undefined,
268+
message: `${numSuccess > 0 ? numSuccess : 'No'} page${
269+
numSuccess === 1 ? ' was' : 's were'
270+
} deleted successfully.<br/>Failed to delete ${numFailed} page${pluralS(
271+
numFailed,
272+
)}.`,
269273
color: 'negative',
270274
html: true,
271275
};

apps/client/src/layouts/PagesLayout/MainContent/DisplayUI/DisplayBottomRight.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
class="selection-count"
1919
>
2020
{{ page.selection.react.elems.length }}
21-
item{{ page.selection.react.elems.length > 1 ? 's' : '' }} selected
21+
item{{ pluralS(page.selection.react.elems.length) }} selected
2222
</div>
2323

2424
<div
@@ -32,6 +32,7 @@
3232

3333
<script setup lang="ts">
3434
import { rolesMap } from '@deeplib/misc';
35+
import { pluralS } from '@stdlib/misc';
3536
import { useRealtimeContext } from 'src/code/realtime/context';
3637
3738
const page = computed(() => internals.pages.react.page);

apps/client/src/layouts/PagesLayout/MainToolbar/PagesSettingsDialog/GroupsTab.vue

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@
8585

8686
<script setup lang="ts">
8787
import { rolesMap } from '@deeplib/misc';
88+
import { pluralS } from '@stdlib/misc';
89+
import type { QNotifyUpdateOptions } from 'quasar';
8890
import { removeGroupUser } from 'src/code/api-interface/groups/remove-user';
8991
import { groupNames } from 'src/code/pages/computed/group-names';
9092
import type { RealtimeContext } from 'src/code/realtime/context';
@@ -148,14 +150,61 @@ async function leaveSelectedGroups() {
148150
ok: { label: 'Yes', flat: true, color: 'negative' },
149151
});
150152
151-
for (const groupId of finalSelectedGroupIds.value) {
152-
await removeGroupUser({
153-
groupId,
154-
patientId: authStore().userId,
155-
});
153+
const notif = $quasar().notify({
154+
group: false,
155+
timeout: 0,
156+
message: 'Leaving groups...',
157+
});
158+
159+
const numTotal = finalSelectedGroupIds.value.length;
160+
161+
let numSuccess = 0;
162+
let numFailed = 0;
163+
164+
for (const [index, groupId] of finalSelectedGroupIds.value.entries()) {
165+
try {
166+
notif({
167+
caption: `${index} of ${numTotal}`,
168+
});
169+
170+
await removeGroupUser({
171+
groupId,
172+
patientId: authStore().userId,
173+
});
174+
175+
numSuccess++;
176+
} catch (error) {
177+
numFailed++;
178+
}
156179
}
157180
158181
baseSelectedGroupIds.value.clear();
182+
183+
let notifUpdateOptions: QNotifyUpdateOptions = {
184+
timeout: undefined,
185+
caption: undefined,
186+
};
187+
188+
if (numFailed === 0) {
189+
notifUpdateOptions = {
190+
...notifUpdateOptions,
191+
message: `Group${pluralS(numSuccess)} left successfully.`,
192+
color: 'positive',
193+
};
194+
} else {
195+
notifUpdateOptions = {
196+
...notifUpdateOptions,
197+
message: `${numSuccess > 0 ? numSuccess : 'No'} group${
198+
numSuccess === 1 ? ' was' : 's were'
199+
} left successfully.<br/>Failed to leave ${numFailed} group${pluralS(
200+
numFailed,
201+
)}.`,
202+
color: 'negative',
203+
html: true,
204+
};
205+
}
206+
207+
notif(notifUpdateOptions);
159208
} catch (error: any) {
160209
handleError(error);
161210
}

apps/client/src/layouts/PagesLayout/MainToolbar/PagesSettingsDialog/InvitationsTab.vue

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@
101101

102102
<script setup lang="ts">
103103
import { rolesMap } from '@deeplib/misc';
104+
import { pluralS } from '@stdlib/misc';
105+
import type { QNotifyUpdateOptions } from 'quasar';
104106
import { rejectJoinInvitation } from 'src/code/api-interface/groups/join-invitations/reject';
105107
import { groupNames } from 'src/code/pages/computed/group-names';
106108
import type { RealtimeContext } from 'src/code/realtime/context';
@@ -186,11 +188,58 @@ async function rejectSelectedInvitations() {
186188
ok: { label: 'Yes', flat: true, color: 'negative' },
187189
});
188190
189-
for (const groupId of finalSelectedGroupIds.value) {
190-
await rejectJoinInvitation({ groupId });
191+
const notif = $quasar().notify({
192+
group: false,
193+
timeout: 0,
194+
message: 'Rejecting join invitations...',
195+
});
196+
197+
const numTotal = finalSelectedGroupIds.value.length;
198+
199+
let numSuccess = 0;
200+
let numFailed = 0;
201+
202+
for (const [index, groupId] of finalSelectedGroupIds.value.entries()) {
203+
try {
204+
notif({
205+
caption: `${index} of ${numTotal}`,
206+
});
207+
208+
await rejectJoinInvitation({ groupId });
209+
210+
numSuccess++;
211+
} catch (error) {
212+
numFailed++;
213+
}
191214
}
192215
193216
baseSelectedGroupIds.value.clear();
217+
218+
let notifUpdateOptions: QNotifyUpdateOptions = {
219+
timeout: undefined,
220+
caption: undefined,
221+
};
222+
223+
if (numFailed === 0) {
224+
notifUpdateOptions = {
225+
...notifUpdateOptions,
226+
message: `Join invitation${pluralS(numSuccess)} rejected successfully.`,
227+
color: 'positive',
228+
};
229+
} else {
230+
notifUpdateOptions = {
231+
...notifUpdateOptions,
232+
message: `${numSuccess > 0 ? numSuccess : 'No'} join invitation${
233+
numSuccess === 1 ? ' was' : 's were'
234+
} rejected successfully.<br/>Failed to reject ${numFailed} join invitation${pluralS(
235+
numFailed,
236+
)}.`,
237+
color: 'negative',
238+
html: true,
239+
};
240+
}
241+
242+
notif(notifUpdateOptions);
194243
} catch (error: any) {
195244
handleError(error);
196245
}

apps/client/src/layouts/PagesLayout/MainToolbar/PagesSettingsDialog/RequestsTab.vue

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
</template>
7979

8080
<script setup lang="ts">
81+
import { pluralS } from '@stdlib/misc';
82+
import type { QNotifyUpdateOptions } from 'quasar';
8183
import { cancelJoinRequest } from 'src/code/api-interface/groups/join-requests/cancel';
8284
import { groupNames } from 'src/code/pages/computed/group-names';
8385
import type { RealtimeContext } from 'src/code/realtime/context';
@@ -152,13 +154,60 @@ async function cancelSelectedRequests() {
152154
ok: { label: 'Yes', flat: true, color: 'negative' },
153155
});
154156
155-
for (const groupId of finalSelectedGroupIds.value) {
156-
await cancelJoinRequest({
157-
groupId,
158-
});
157+
const notif = $quasar().notify({
158+
group: false,
159+
timeout: 0,
160+
message: 'Canceling join requests...',
161+
});
162+
163+
const numTotal = finalSelectedGroupIds.value.length;
164+
165+
let numSuccess = 0;
166+
let numFailed = 0;
167+
168+
for (const [index, groupId] of finalSelectedGroupIds.value.entries()) {
169+
try {
170+
notif({
171+
caption: `${index} of ${numTotal}`,
172+
});
173+
174+
await cancelJoinRequest({
175+
groupId,
176+
});
177+
178+
numSuccess++;
179+
} catch (error) {
180+
numFailed++;
181+
}
159182
}
160183
161184
baseSelectedGroupIds.value.clear();
185+
186+
let notifUpdateOptions: QNotifyUpdateOptions = {
187+
timeout: undefined,
188+
caption: undefined,
189+
};
190+
191+
if (numFailed === 0) {
192+
notifUpdateOptions = {
193+
...notifUpdateOptions,
194+
message: `Join request${pluralS(numSuccess)} canceled successfully.`,
195+
color: 'positive',
196+
};
197+
} else {
198+
notifUpdateOptions = {
199+
...notifUpdateOptions,
200+
message: `${numSuccess > 0 ? numSuccess : 'No'} join request${
201+
numSuccess === 1 ? ' was' : 's were'
202+
} canceled successfully.<br/>Failed to cancel ${numFailed} join request${pluralS(
203+
numFailed,
204+
)}.`,
205+
color: 'negative',
206+
html: true,
207+
};
208+
}
209+
210+
notif(notifUpdateOptions);
162211
} catch (error: any) {
163212
handleError(error);
164213
}

0 commit comments

Comments
 (0)