Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Deli authored and Dennis Deli committed Dec 17, 2024
1 parent 911f7c0 commit 0f53db2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
38 changes: 37 additions & 1 deletion app/assets/javascripts/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ var COURSE;

$(document).ready(function() {


$(".click_redirect").click(function() {
var path = $(this).data("redirect-path");
location.href=path;
Expand Down Expand Up @@ -57,6 +56,43 @@ $(document).ready(function() {
$("#request_reserve_end_date").val(end_year + "-" + end_month_day);


}).trigger("input_load");;

$("#rollover_course_term, #rollover_course_year").on("input_load change", function(e) {
console.log("testie")
var term = $("#rollover_course_term").val();
var year = parseInt($("#rollover_course_year").val());
//console.log("Here I am" + year);

var start_month_day = "09-01"; // F, Y, FW
var end_month_day = "04-30"; // Y, FW, W
var start_year = year; // F, Y, FW
var end_year = year + 1; // Y, FW, W
//console.log(term)


switch(term) {
case "F":
end_month_day = "12-31";
end_year = year;
break;
case "W":
start_month_day = "01-01";
start_year = year + 1;
break;
case "S":
case "SU":
case "S1":
case "S2":
start_month_day = "05-01";
start_year = year + 1;
end_month_day = "08-30";
}

$("#rollover_start_date").val(start_year + "-" + start_month_day);
$("#rollover_end_date").val(end_year + "-" + end_month_day);


}).trigger("input_load");;

$(".change-item-status").each(function() {
Expand Down
8 changes: 4 additions & 4 deletions app/views/requests/_form_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@
<%= f.input :reserve_location_id, collection: Location.active, required: true, hint: "Where do you want students to pick up your items?" %>
</div>
<div class="col-sm-3">
<%= f.input :reserve_start_date, as: :string, readonly: ! current_user.admin?, required: false, hint: "Prefilled after term selection.",
input_html: { id: "request_reserve_start_date", class: current_user.admin? ? "datepicker" : "" } %>
<%= f.input :reserve_start_date, as: :string, readonly: true, required: false, hint: "Prefilled after term selection.",
input_html: { id: "request_reserve_start_date", class: "" } %>
</div>
<div class="col-sm-3">
<%= f.input :reserve_end_date, as: :string, readonly: ! current_user.admin?, required: false,
input_html: { id: "request_reserve_end_date", class: current_user.admin? ? "datepicker" : "" } %>
<%= f.input :reserve_end_date, as: :string, readonly: true, required: false,
input_html: { id: "request_reserve_end_date", class: "" } %>
</div>
</div> <!-- row end -->
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/views/requests/rollover_confirm.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<%= f.input :course_section, collection: Course::SECTIONS, label: false, input_html: { class: "input-sm" } %>
<%= f.input :course_credits, collection: Course::TERM_CREDITS, label: false, input_html: { class: "input-sm" } %>
<%= f.input :course_student_count, label: false, input_html: { class: "input-sm", placeholder: "Course Enrollment" } %>
<br>
<%= f.input :reserve_start_date, as: :string, readonly: true, required: false,
input_html: { id: "rollover_start_date", class: "" } %>
<%= f.input :reserve_end_date, as: :string, readonly: true, required: false,
input_html: { id: "rollover_end_date", class: "" } %>
<br/><br/>
<%= f.submit "Keep Item(s) On Reserve", class: "btn btn-success", data: { confirm: "Are you sure?"} %>
<hr/>
Expand Down

0 comments on commit 0f53db2

Please sign in to comment.