@appcorp/fusion-storybook 0.2.42 → 0.2.44
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.
- package/base-modules/attendance/filter.js +3 -1
- package/base-modules/class/more-actions.js +47 -22
- package/base-modules/enrollment/more-actions.js +48 -23
- package/base-modules/fee-structure/more-actions.js +45 -20
- package/base-modules/rbac/context.js +1 -1
- package/base-modules/rbac/form.js +3 -1
- package/base-modules/section/more-actions.js +47 -22
- package/base-modules/student-profile/filter.js +1 -1
- package/base-modules/subject/more-actions.js +47 -22
- package/base-modules/teacher/more-actions.js +45 -20
- package/package.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
|
@@ -67,13 +67,17 @@ async function pollBulkJob(jobId, signal, onProgress) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
function formatErrorSummary(
|
|
70
|
+
function formatErrorSummary(
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
72
|
+
t, errors) {
|
|
71
73
|
if (!(errors === null || errors === void 0 ? void 0 : errors.length))
|
|
72
74
|
return "";
|
|
73
|
-
const lines = errors
|
|
75
|
+
const lines = errors
|
|
76
|
+
.slice(0, 5)
|
|
77
|
+
.map((e) => t("messagesBulkRowError", { row: e.row, error: e.error }));
|
|
74
78
|
const remaining = errors.length - 5;
|
|
75
79
|
if (remaining > 0)
|
|
76
|
-
lines.push(
|
|
80
|
+
lines.push(t("messagesBulkMoreRows", { count: remaining }));
|
|
77
81
|
return lines.join("\n");
|
|
78
82
|
}
|
|
79
83
|
export const SubjectMoreActions = () => {
|
|
@@ -106,7 +110,7 @@ export const SubjectMoreActions = () => {
|
|
|
106
110
|
const text = await file.text();
|
|
107
111
|
const records = converter.csv2json(text);
|
|
108
112
|
if (!Array.isArray(records) || records.length === 0) {
|
|
109
|
-
showErrorToast("
|
|
113
|
+
showErrorToast(t("messagesBulkCsvEmpty"));
|
|
110
114
|
return;
|
|
111
115
|
}
|
|
112
116
|
// Client-side validation — basic required field check
|
|
@@ -116,53 +120,71 @@ export const SubjectMoreActions = () => {
|
|
|
116
120
|
const msgs = [];
|
|
117
121
|
if (method === "POST") {
|
|
118
122
|
if (!((_b = row.code) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
119
|
-
msgs.push("
|
|
123
|
+
msgs.push(t("validationRequiredCode"));
|
|
120
124
|
if (!((_c = row.name) === null || _c === void 0 ? void 0 : _c.trim()))
|
|
121
|
-
msgs.push("
|
|
125
|
+
msgs.push(t("validationRequiredName"));
|
|
122
126
|
}
|
|
123
127
|
else {
|
|
124
128
|
if (!((_d = row.id) === null || _d === void 0 ? void 0 : _d.trim()))
|
|
125
|
-
msgs.push("
|
|
129
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
126
130
|
}
|
|
127
131
|
if (msgs.length > 0) {
|
|
128
132
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
129
133
|
}
|
|
130
134
|
}
|
|
131
135
|
if (validationErrors.length > 0) {
|
|
132
|
-
const
|
|
136
|
+
const errorsList = validationErrors
|
|
133
137
|
.slice(0, 5)
|
|
134
|
-
.map((e) =>
|
|
138
|
+
.map((e) => t("messagesBulkRowError", {
|
|
139
|
+
row: e.row,
|
|
140
|
+
error: e.messages.join("; "),
|
|
141
|
+
}))
|
|
135
142
|
.join("\n");
|
|
136
143
|
const remaining = validationErrors.length - 5;
|
|
137
|
-
|
|
144
|
+
const errorsStr = remaining > 0
|
|
145
|
+
? `${errorsList}\n${t("messagesBulkMoreRows", { count: remaining })}`
|
|
146
|
+
: errorsList;
|
|
147
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
148
|
+
count: validationErrors.length,
|
|
149
|
+
errors: errorsStr,
|
|
150
|
+
}));
|
|
138
151
|
return;
|
|
139
152
|
}
|
|
140
153
|
try {
|
|
141
|
-
showInfoToast(
|
|
154
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
142
155
|
let jobId;
|
|
143
156
|
try {
|
|
144
157
|
jobId = await submitBulkJob(text, method, signal);
|
|
145
158
|
}
|
|
146
159
|
catch (submitError) {
|
|
147
|
-
showErrorToast(
|
|
160
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
161
|
+
action: label,
|
|
162
|
+
error: submitError instanceof Error
|
|
163
|
+
? submitError.message
|
|
164
|
+
: t("unknownError"),
|
|
165
|
+
}));
|
|
148
166
|
return;
|
|
149
167
|
}
|
|
150
168
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
151
|
-
showInfoToast(
|
|
169
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
152
170
|
});
|
|
153
171
|
if (signal.aborted)
|
|
154
172
|
return;
|
|
155
173
|
if (status.status === "completed") {
|
|
156
174
|
const r = status.results;
|
|
157
175
|
if (r && ((_e = r.errors) === null || _e === void 0 ? void 0 : _e.length) > 0) {
|
|
158
|
-
const summary = formatErrorSummary(r.errors);
|
|
159
|
-
showSuccessToast(
|
|
176
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
177
|
+
showSuccessToast(`${t("messagesBulkResults", { created: r.created, updated: r.updated, skipped: r.skipped })}\n${summary}`);
|
|
160
178
|
}
|
|
161
179
|
else if (r) {
|
|
162
|
-
showSuccessToast(
|
|
180
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
181
|
+
created: r.created,
|
|
182
|
+
updated: r.updated,
|
|
183
|
+
skipped: r.skipped,
|
|
184
|
+
}));
|
|
163
185
|
}
|
|
164
186
|
else {
|
|
165
|
-
showSuccessToast("
|
|
187
|
+
showSuccessToast(t("messagesBulkSuccess"));
|
|
166
188
|
}
|
|
167
189
|
const schoolId = ((_f = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _f === void 0 ? void 0 : _f.id) || "";
|
|
168
190
|
fetch(`${SUBJECT_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -189,17 +211,20 @@ export const SubjectMoreActions = () => {
|
|
|
189
211
|
else {
|
|
190
212
|
const r = status.results;
|
|
191
213
|
const detail = ((_g = r === null || r === void 0 ? void 0 : r.errors) === null || _g === void 0 ? void 0 : _g.length)
|
|
192
|
-
? formatErrorSummary(r.errors)
|
|
193
|
-
: "
|
|
194
|
-
showErrorToast(
|
|
214
|
+
? formatErrorSummary(t, r.errors)
|
|
215
|
+
: t("unknownError");
|
|
216
|
+
showErrorToast(`${t("messagesBulkFailed", { action: label })}\n${detail}`);
|
|
195
217
|
}
|
|
196
218
|
}
|
|
197
219
|
catch (error) {
|
|
198
220
|
if (error.message === "Polling cancelled")
|
|
199
221
|
return;
|
|
200
|
-
showErrorToast(
|
|
222
|
+
showErrorToast(t("messagesBulkFailedDetail", {
|
|
223
|
+
action: label,
|
|
224
|
+
error: error instanceof Error ? error.message : t("unknownError"),
|
|
225
|
+
}));
|
|
201
226
|
}
|
|
202
|
-
}, [dispatch]);
|
|
227
|
+
}, [dispatch, t]);
|
|
203
228
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
204
229
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
205
230
|
const create = [
|
|
@@ -76,13 +76,15 @@ async function pollBulkJob(jobId, signal, onProgress) {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function formatErrorSummary(errors) {
|
|
79
|
+
function formatErrorSummary(t, errors) {
|
|
80
80
|
if (!(errors === null || errors === void 0 ? void 0 : errors.length))
|
|
81
81
|
return "";
|
|
82
|
-
const lines = errors
|
|
82
|
+
const lines = errors
|
|
83
|
+
.slice(0, 5)
|
|
84
|
+
.map((e) => t("messagesBulkRowError", { row: e.row, error: e.error }));
|
|
83
85
|
const remaining = errors.length - 5;
|
|
84
86
|
if (remaining > 0)
|
|
85
|
-
lines.push(
|
|
87
|
+
lines.push(t("messagesBulkMoreRows", { count: remaining }));
|
|
86
88
|
return lines.join("\n");
|
|
87
89
|
}
|
|
88
90
|
export const TeacherMoreActions = () => {
|
|
@@ -115,7 +117,7 @@ export const TeacherMoreActions = () => {
|
|
|
115
117
|
const text = await file.text();
|
|
116
118
|
const records = converter.csv2json(text);
|
|
117
119
|
if (!Array.isArray(records) || records.length === 0) {
|
|
118
|
-
showErrorToast("
|
|
120
|
+
showErrorToast(t("messagesBulkCsvEmpty"));
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
123
|
// Client-side validation — fast feedback, saves worker round-trip
|
|
@@ -131,7 +133,7 @@ export const TeacherMoreActions = () => {
|
|
|
131
133
|
}
|
|
132
134
|
else {
|
|
133
135
|
if (!((_b = row.id) === null || _b === void 0 ? void 0 : _b.trim()))
|
|
134
|
-
msgs.push("
|
|
136
|
+
msgs.push(t("validationRequiredIdForUpdate"));
|
|
135
137
|
}
|
|
136
138
|
if (msgs.length > 0) {
|
|
137
139
|
validationErrors.push({ row: i + 1, messages: msgs });
|
|
@@ -140,38 +142,58 @@ export const TeacherMoreActions = () => {
|
|
|
140
142
|
if (validationErrors.length > 0) {
|
|
141
143
|
const summary = validationErrors
|
|
142
144
|
.slice(0, 5)
|
|
143
|
-
.map((e) =>
|
|
145
|
+
.map((e) => t("messagesBulkRowError", {
|
|
146
|
+
row: e.row,
|
|
147
|
+
error: e.messages.join("; "),
|
|
148
|
+
}))
|
|
144
149
|
.join("\n");
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
showErrorToast(t("messagesBulkValidationFailed", {
|
|
151
|
+
count: validationErrors.length,
|
|
152
|
+
errors: summary,
|
|
153
|
+
}));
|
|
147
154
|
return;
|
|
148
155
|
}
|
|
149
156
|
try {
|
|
150
|
-
showInfoToast(
|
|
157
|
+
showInfoToast(t("messagesBulkJobQueued", { action: label, count: records.length }));
|
|
151
158
|
let jobId;
|
|
152
159
|
try {
|
|
153
160
|
jobId = await submitBulkJob(text, method, signal);
|
|
154
161
|
}
|
|
155
162
|
catch (submitError) {
|
|
156
|
-
showErrorToast(
|
|
163
|
+
showErrorToast(t("messagesBulkJobSubmitFailed", {
|
|
164
|
+
action: label,
|
|
165
|
+
error: submitError instanceof Error
|
|
166
|
+
? submitError.message
|
|
167
|
+
: t("unknownError"),
|
|
168
|
+
}));
|
|
157
169
|
return;
|
|
158
170
|
}
|
|
159
171
|
const status = await pollBulkJob(jobId, signal, (processed, total) => {
|
|
160
|
-
showInfoToast(
|
|
172
|
+
showInfoToast(t("messagesBulkProgress", { processed, total }));
|
|
161
173
|
});
|
|
162
174
|
if (signal.aborted)
|
|
163
175
|
return;
|
|
164
176
|
if (status.status === "completed") {
|
|
165
177
|
const r = status.results;
|
|
166
178
|
if (r && ((_c = r.errors) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
167
|
-
const summary = formatErrorSummary(r.errors);
|
|
168
|
-
showSuccessToast(
|
|
179
|
+
const summary = formatErrorSummary(t, r.errors);
|
|
180
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
181
|
+
created: r.created,
|
|
182
|
+
updated: r.updated,
|
|
183
|
+
skipped: r.skipped,
|
|
184
|
+
}) +
|
|
185
|
+
"\n" +
|
|
186
|
+
summary);
|
|
169
187
|
}
|
|
170
188
|
else if (r) {
|
|
171
|
-
showSuccessToast(
|
|
189
|
+
showSuccessToast(t("messagesBulkResults", {
|
|
190
|
+
created: r.created,
|
|
191
|
+
updated: r.updated,
|
|
192
|
+
skipped: r.skipped,
|
|
193
|
+
}));
|
|
172
194
|
}
|
|
173
195
|
else {
|
|
174
|
-
showSuccessToast("
|
|
196
|
+
showSuccessToast(t("messagesBulkSuccess"));
|
|
175
197
|
}
|
|
176
198
|
const schoolId = ((_d = workspace === null || workspace === void 0 ? void 0 : workspace.school) === null || _d === void 0 ? void 0 : _d.id) || "";
|
|
177
199
|
fetch(`${TEACHER_API_ROUTES.LIST}?currentPage=1&pageLimit=${pageLimit}&schoolId=${schoolId}`, {
|
|
@@ -199,17 +221,20 @@ export const TeacherMoreActions = () => {
|
|
|
199
221
|
else {
|
|
200
222
|
const r = status.results;
|
|
201
223
|
const detail = ((_e = r === null || r === void 0 ? void 0 : r.errors) === null || _e === void 0 ? void 0 : _e.length)
|
|
202
|
-
? formatErrorSummary(r.errors)
|
|
203
|
-
: "
|
|
204
|
-
showErrorToast(
|
|
224
|
+
? formatErrorSummary(t, r.errors)
|
|
225
|
+
: t("unknownError");
|
|
226
|
+
showErrorToast(t("messagesBulkFailed", { action: label }) + "\n" + detail);
|
|
205
227
|
}
|
|
206
228
|
}
|
|
207
229
|
catch (error) {
|
|
208
230
|
if (error.message === "Polling cancelled")
|
|
209
231
|
return;
|
|
210
|
-
showErrorToast(
|
|
232
|
+
showErrorToast(t("messagesBulkFailedDetail", {
|
|
233
|
+
action: label,
|
|
234
|
+
error: error instanceof Error ? error.message : t("unknownError"),
|
|
235
|
+
}));
|
|
211
236
|
}
|
|
212
|
-
}, [dispatch]);
|
|
237
|
+
}, [dispatch, t]);
|
|
213
238
|
const handleBulkCreate = useCallback((files) => handleBulkFlow(files, "POST"), [handleBulkFlow]);
|
|
214
239
|
const handleBulkUpdate = useCallback((files) => handleBulkFlow(files, "PUT"), [handleBulkFlow]);
|
|
215
240
|
const create = [
|