Skip to content

Commit

Permalink
Shopping cart touch ups
Browse files Browse the repository at this point in the history
Submit button is disabled when nothing is selected. Return defaults to today.

Request page shows all devices by default
  • Loading branch information
arc12012 committed Apr 23, 2017
1 parent 1a3e3d4 commit abe4856
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 2 additions & 0 deletions WebContent/html/javascript/request.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ for(var a = 0; a < softwareOptions.length; a++){
// searchbar listener
var searchbar = document.getElementsByName('searchBar');
searchbar[0].onkeyup = refresh;
// populate page with all devices by default
show(devices);
function refresh() {
show(fuzzyFilter(filter(devices)));
}
Expand Down
19 changes: 14 additions & 5 deletions WebContent/html/webpages/shoppingCart.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ pageEncoding="ISO-8859-1"%>
</div>
<div class="form-group row">
<label for="timeNeeded">When will you be able to return it?</label><br/>
<input type="date" class="form-control" name="timeNeeded" style="width:20%; margin:0% auto" required/>
<input type="date" class="form-control" id="datePicker" name="timeNeeded" style="width:20%; margin:0% auto" required/>
</div>
<div class="form-group row">
<label for="urgent">This is an urgent request</label>
<input type = "checkbox" name = "checkboxes" value="urgent"><br>
<label for="urgent">This is a permanent loan</label>
<input type = "checkbox" name = "checkboxes" value = "perm">
</div>
<button type="submit" class="btn btn-primary" name="Submit">Submit</button>
<button type="submit" class="btn btn-primary" id = "Submit" name="Submit">Submit</button>
</form>
</div>

Expand Down Expand Up @@ -239,6 +239,7 @@ var orderForm = document.getElementById('orderInfoModal');
var orderFormCloseButton = document.getElementById('closeOrderForm');
orderFormCloseButton.addEventListener('click',hidePopup);
// done applying event listeners
document.getElementById('datePicker').valueAsDate = new Date();
var employee = {
id:"",
Expand Down Expand Up @@ -336,15 +337,23 @@ function changeStatus(){
// These functions just redirect button pressed to call the showPopup method with the appropriate parameter
function orderSelected_showPopup() {
showPopup("false");
showPopup(false);
}
function orderAll_showPopup() {
showPopup("true");
showPopup(true);
}
// Opens order form and calls autofill method. Parameter is actually a string, not a boolean, because it will be put into a text field.
// It indicaties which button was used to call the method.
// If true, submitting the form will order everything in the cart. If false it only orders selected devices.
function showPopup(orderAllBool){
if(checked.length==0 && !orderAllBool){
$('#Submit').attr('disabled',true);
$('#Submit').attr('title',"There aren't any devices selected to order!");
}
else{
$('#Submit').attr('disabled',false);
$('#Submit').removeAttr('title');
}
orderForm.style.display = "block";
autoFillFields(orderAllBool);
}
Expand Down Expand Up @@ -385,7 +394,7 @@ function autoFillFields(orderAllBool) {
// and fill in the location sub-fieds
forceUpdateLocationMetadata();
// finally mark hidden orderAll field appropriately
document.orderForm.orderAll.value=orderAllBool;
document.orderForm.orderAll.value=orderAllBool?"true":"false";
// Also, this is where I'm going to restrict the date input to the future
var dtToday = new Date();
Expand Down

0 comments on commit abe4856

Please sign in to comment.