-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1111 from BCStudentSoftwareDevTeam/CreateCoursePa…
…rticipantUI_#1059 Creation of UI for Imported Courses
- Loading branch information
Showing
14 changed files
with
610 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Instructor manipulation functions | ||
// ------------------------------------- | ||
|
||
export function getRowUsername(element) { | ||
return $(element).closest("tr").data("username") | ||
} | ||
|
||
export function createNewRow(selectedInstructor) { | ||
let instructor = `${selectedInstructor["firstName"]} ${selectedInstructor["lastName"]} (${selectedInstructor["email"]})`; | ||
let username = selectedInstructor["username"]; | ||
let phone = selectedInstructor["phoneNumber"]; | ||
let tableBody = $("#instructorTable").find("tbody"); | ||
|
||
if(tableBody.prop('outerHTML').includes(instructor)){ | ||
msgFlash("Instructor is already added.", "danger"); | ||
return; | ||
} | ||
// Create new table row and update necessary attributes | ||
let lastRow = tableBody.find("tr:last"); | ||
let newRow = lastRow.clone(); | ||
|
||
let instructorName = newRow.find("td:eq(0) p") | ||
instructorName.text(instructor); | ||
|
||
let phoneInput = newRow.find("td:eq(0) input") | ||
phoneInput.val(phone); | ||
phoneInput.attr("id", `inputPhoneNumber-${username}`); | ||
$(phoneInput).inputmask('(999)-999-9999'); | ||
|
||
let removeButton = newRow.find("td:eq(1) button") | ||
let editLink = newRow.find("td:eq(0) a") | ||
editLink.attr("id", `editButton-${username}`); | ||
|
||
editLink.attr("data-username", username) | ||
newRow.prop("hidden", false); | ||
lastRow.after(newRow); | ||
|
||
phoneInput.data("value", phone) | ||
var editSelector = `#editButton-${username}` | ||
var inputSelector = `#inputPhoneNumber-${username}` | ||
if (username){ | ||
setupPhoneNumber(editSelector, inputSelector) | ||
} | ||
|
||
$("#instructorTableNames").append(`<input hidden name="instructor[]" value="${username}"/>`) | ||
} | ||
|
||
export function getCourseInstructors() { | ||
// get usernames out of the table rows | ||
return $("#instructorTableNames input").map((i,el) => $(el).val()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.