From 79f6223f69c29b9c9ebace12ca2bb2ca57fff8b1 Mon Sep 17 00:00:00 2001
From: Dmytro <98233552+DmytroAlipov@users.noreply.github.com>
Date: Thu, 21 Mar 2024 10:24:30 +0100
Subject: [PATCH] fix: validation error for empty Batch Enrollment/Beta Tester
(#32684)
Co-authored-by: Muhammad Abdullah Waheed <42172960+abdullahwaheed@users.noreply.github.com>
---
.../js/instructor_dashboard/membership.js | 48 +++++++++++++------
1 file changed, 34 insertions(+), 14 deletions(-)
diff --git a/lms/static/js/instructor_dashboard/membership.js b/lms/static/js/instructor_dashboard/membership.js
index 5fdf4a42ef..2d4c54d88c 100644
--- a/lms/static/js/instructor_dashboard/membership.js
+++ b/lms/static/js/instructor_dashboard/membership.js
@@ -503,14 +503,20 @@ such that the value can be defined later than this assignment (file load order).
}));
$idsList = $('
');
$taskResSection.append($idsList);
- for (j = 0, len1 = ids.length; j < len1; j++) {
- identifier = ids[j];
- $idsList.append($('', {
- text: identifier
- }));
- }
+ if (ids && ids.length > 0) {
+ for (j = 0, len1 = ids.length; j < len1; j++) {
+ identifier = ids[j];
+ $idsList.append($('', {
+ text: identifier
+ }));
+ }
+ }
return displayResponse.$task_response.append($taskResSection);
};
+ if (errors.length === 0 && successes.length === 0 && noUsers.length === 0) {
+ // Translators: For cases when the input field is empty;
+ renderList(gettext('This field must not be blank'), []);
+ }
if (successes.length && dataFromServer.action === 'add') {
var j, len1, inActiveUsers, activeUsers; // eslint-disable-line vars-on-top
activeUsers = [];
@@ -574,9 +580,6 @@ such that the value can be defined later than this assignment (file load order).
}()));
}
if (noUsers.length) {
- noUsers.push($(
- gettext('Users must create and activate their account before they can be promoted to beta tester.'))
- );
return renderList(gettext('Could not find users associated with the following identifiers:'), (function() { // eslint-disable-line max-len
// eslint-disable-next-line no-shadow
var j, len1, results;
@@ -585,6 +588,9 @@ such that the value can be defined later than this assignment (file load order).
sr = noUsers[j];
results.push(sr.identifier);
}
+ results.unshift(
+ gettext('Users must create and activate their account before they can be promoted to beta tester.')
+ );
return results;
}()));
}
@@ -699,14 +705,28 @@ such that the value can be defined later than this assignment (file load order).
}));
$idsList = $('');
$taskResSection.append($idsList);
- for (h = 0, len3 = ids.length; h < len3; h++) {
- identifier = ids[h];
- $idsList.append($('', {
- text: identifier
- }));
+ if (ids && ids.length > 0) {
+ for (h = 0, len3 = ids.length; h < len3; h++) {
+ identifier = ids[h];
+ $idsList.append($('', {
+ text: identifier
+ }));
+ }
}
return displayResponse.$task_response.append($taskResSection);
};
+ if (
+ invalidIdentifier.length === 0
+ && errors.length === 0
+ && enrolled.length === 0
+ && allowed.length === 0
+ && autoenrolled.length === 0
+ && notenrolled.length === 0
+ && notunenrolled.length === 0
+ ) {
+ // Translators: For cases when the input field is empty;
+ renderList(gettext('This field must not be blank'), []);
+ }
if (invalidIdentifier.length) {
renderList(gettext('The following email addresses and/or usernames are invalid:'), (function() {
var m, len4, results;