-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add committee member modal validation
- Loading branch information
1 parent
038b38b
commit f852ac9
Showing
7 changed files
with
57 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,16 @@ | ||
<% remote = request.xhr? ? true : false %> | ||
<div class="modal" id="add_committee_member_modal" tabindex="-1"> | ||
<div class="modal-dialog"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Add Committee Member</h5> | ||
<% if request.xhr? %> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
<% end %> | ||
</div> | ||
<%= simple_form_for [@student, @thesis, @committee_member], remote: remote do |f| %> | ||
<div class="modal-body"> | ||
<p id="member_first_name"> | ||
<%= f.input :first_name, label: "First Name", required: true %> | ||
</p> | ||
<p id="member_last_name"> | ||
<%= f.input :last_name, label: "Last Name", required: true %> | ||
</p> | ||
<%= f.input :role, label: "Role", required: true, collection: CommitteeMember::ROLES, as: :radio_buttons %> | ||
</div> | ||
<div class="modal-footer"> | ||
<%= f.button :submit, "Add", class: "btn btn-primary" %> | ||
<% if request.xhr? %> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> | ||
<% else %> | ||
<%= link_to "Cancel", :back, class: "btn" %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<%= simple_form_for [@student, @thesis, @committee_member], remote: request.xhr? do |f| %> | ||
<%= f.input :first_name, label: "First Name", required: true %> | ||
<%= f.input :last_name, label: "Last Name", required: true %> | ||
<%= f.input :role, label: "Role", required: true, collection: CommitteeMember::ROLES, as: :radio_buttons %> | ||
<%= f.button :submit, "Add", class: "btn btn-primary" %> | ||
<% if request.xhr? %> | ||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" aria-label="Cancel">Cancel</button> | ||
<% else %> | ||
<% if current_user.role == User::STUDENT %> | ||
<a href="<%= student_view_thesis_process_path(@thesis, Thesis::PROCESS_UPDATE) %>" class="btn btn-secondary">Cancel</a> | ||
<% else %> | ||
<a href="<%= edit_student_thesis_path(@student, @thesis) %>" class="btn btn-secondary">Cancel</a> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
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,15 @@ | ||
<div class="modal fade" id="add_committee_member_modal" data-bs-keyboard="false" tabindex="-1" aria-hidden="true" data-bs-backdrop="static"> | ||
<div class="modal-dialog modal-dialog-centered modal-dialog-scrollable"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h1 class="modal-title fs-5"> | ||
Add Committee Member | ||
</h1> | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> | ||
</div> | ||
<div class="modal-body"> | ||
<%= render "form" %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<% if @committee_member.errors.size == 0 %> | ||
$("#add_committee_member_modal").modal('hide'); | ||
$("#add_committee_member").remove(); | ||
<% if @committee_member.errors.blank? %> | ||
$("#committee_members .committee_members_list").append("<%= j render @committee_member %>"); | ||
$("#add_committee_member_modal").modal('hide'); | ||
$("#add_committee_member_modal").remove(); | ||
<% else %> | ||
$("#add_committee_member").html("<%= j render "form" %>"); | ||
$("#add_committee_member_modal .modal-body").html('<%= j render("form") %>'); | ||
<% end %> |
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 |
---|---|---|
@@ -1,5 +1,19 @@ | ||
<% title "Add Committee Member", false %> | ||
<div class="fitted"> | ||
<%= render "form" %> | ||
</div> | ||
<% title "#{@student.name} - Thesis" %> | ||
<% title_html do %> | ||
|
||
<div class="row"> | ||
<%= render partial: "students/header" %> | ||
</div> | ||
|
||
<hr /> | ||
|
||
<h2><span class="fw-lighter text-secondary lead"><%= @thesis.title %></span></h2> | ||
|
||
<h2 class="modal-title fs-5"> | ||
Add Committee Member | ||
</h2> | ||
|
||
<%= render "form" %> | ||
<% end %> |
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 |
---|---|---|
@@ -1,7 +1,2 @@ | ||
$("#add_committee_member").remove(); | ||
$("body").append("<div id='add_committee_member'></div>"); | ||
$("#add_committee_member").append('<%= j render("form") %>'); | ||
var myModal = new bootstrap.Modal(document.getElementById('add_committee_member_modal'), { | ||
backdrop: 'static' | ||
}); | ||
myModal.show(); | ||
$("body").append('<%= j render("modal") %>'); | ||
(new bootstrap.Modal($('#add_committee_member_modal'))).show(); |
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