Changeset 46fd0c7 for src/main/resources
- Timestamp:
- 03/13/23 00:58:07 (21 months ago)
- Branches:
- master
- Children:
- 9050790
- Parents:
- 2b0a4db
- Location:
- src/main/resources
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/resources/static/js/register_business.js
r2b0a4db r46fd0c7 3 3 $.ajax({ 4 4 url: "http://localhost:8080/api/nomenclatures/businessTypes" 5 }).then(function (data) {5 }).then(function (data) { 6 6 enumerations = data; 7 7 var $el = $("#companyType"); 8 8 //$el.empty(); // remove old options 9 9 10 $.each(data, function (index, obj) {10 $.each(data, function (index, obj) { 11 11 $el.append("<option value=" + obj.value + ">" + obj.text + "</option>"); 12 12 }); 13 13 }); 14 14 15 $("#companyType").change(function () {15 $("#companyType").change(function () { 16 16 var selectedVal = $(this).find(':selected').val(); 17 alert(JSON.stringify(enumerations[selectedVal-1])); 18 var selectedObj = enumerations[selectedVal-1]; 17 var selectedObj = enumerations[selectedVal - 1]; 19 18 var $el = $("#predefined_services"); 20 19 $el.empty(); 21 20 $.each(selectedObj['serviceTypes'], function (index, obj) { 22 21 $el.append( 23 '<div class="form-check">\n' + 24 ' <input class="form-check-input" type="checkbox" value=\"' + obj.id + '\" id=\"'+ obj.id +'\">\n' + 25 ' <label class="form-check-label" for=\"' + obj.id + '\">\n' + 26 obj.name + 27 ' </label>\n' + 28 ' </div>') 22 '<div class=\"form-outline mb-4\">' + 23 ' <div class="row">' + 24 ' <div class="col-md-8">\n' + 25 ' <input class="form-check-input" type="checkbox" value=\"' + obj.id + '\" id=\"' + obj.id + '\">\n' + 26 ' <label class="form-check-label" for=\"' + obj.id + '\">\n' + 27 obj.name + 28 ' </label>\n' + 29 ' </div>' + 30 ' <div class=\"form-outline col-md-2 d-grid\">' + 31 ' <input type=\"text\" id=\"' + obj.id + obj.name.replace(/\s/g, "") + '\" class=\"form-control\" />' + 32 ' </div>' + 33 ' </div>' + 34 '</div>'); 29 35 }); 30 }) 36 $("#input_service").prop('disabled', false); 37 $("#add_service").prop('disabled', false); 38 }); 39 40 $("#add_service").click(function () { 41 var input_service = $("#input_service").val(); 42 // clear the input 43 $("#input_service").val(''); 44 45 /*$("#predefined_services").append( 46 '<div class="form-check">\n' + 47 ' <input class="form-check-input" type="checkbox" checked value=\"' + -1 + '\" id=\"'+ -1 +'\">\n' + 48 ' <label class="form-check-label" for=\"' + -1 + '\">\n' + 49 input_service + 50 ' </label>\n' + 51 ' </div>' 52 );*/ 53 54 $("#predefined_services").append( 55 '<div class="form-outline mb-4">' + 56 ' <div class="row">' + 57 ' <div class="col-md-8">\n' + 58 ' <input class="form-check-input" type="checkbox" checked value="' + -1 + '" id="' + -1 + '">\n' + 59 ' <label class="form-check-label" for="' + -1 + '">\n' + 60 input_service + 61 ' </label>\n' + 62 ' </div>' + 63 ' <div class="form-outline col-md-2 d-grid">' + 64 ' <input type="text" id="' + -1 + input_service.replace(/\s/g, "") + '" class="form-control" />' + 65 ' </div>' + 66 ' </div>' + 67 '</div>'); 68 event.preventDefault(); 69 }); 70 71 $('#signup_business_button').click(function () { 72 let businessObj = {}; 73 let ownerObj = {}; 74 75 ownerObj['firstName'] = $('#firstName').val(); 76 ownerObj['lastName'] = $('#lastName').val(); 77 ownerObj['email'] = $('#email').val(); 78 ownerObj['username'] = $('#username').val(); 79 ownerObj['password'] = $('#password').val(); 80 businessObj['owner'] = ownerObj; 81 82 businessObj['companyName'] = $('#companyName').val(); 83 84 businessObj['businessType'] = {'value': $('#companyType').val()}; 85 86 servicesObj = []; 87 88 $.each($('#predefined_services input:checked').siblings(), function(index, label) { 89 90 let service = {}; 91 var id = $(label).prop('for'); 92 var text = $(label).text(); 93 var time = $($($(label).parent()).siblings()[0]).children()[0].value; 94 95 var serviceType = {} 96 if(parseInt(id) != -1) { 97 serviceType['id'] = id; 98 } 99 serviceType['name'] = text.trim(); 100 service['serviceType'] = serviceType; 101 service['duration'] = time; 102 servicesObj.push(service); 103 }); 104 businessObj['services'] = servicesObj; 105 console.log(JSON.stringify(businessObj)); 106 $.ajax({ 107 url: "http://localhost:8080/api/business", 108 type:"POST", 109 data: JSON.stringify(businessObj), 110 contentType:"application/json; charset=utf-8", 111 dataType: 'text', 112 success: function(succ){ 113 alert( "Well done! You have finished the registration process. " + 114 "Please check periodically to see if the company has been approved." ); 115 window.location.href = "/homepage"; 116 }, 117 error: function(err) { 118 alert(err); 119 } 120 }); 121 event.preventDefault(); 122 }); 31 123 }); -
src/main/resources/templates/register_business.html
r2b0a4db r46fd0c7 37 37 <div class="col-md-6 mb-4"> 38 38 <div class="form-outline"> 39 <input type="text" id="firstName" class="form-control" placeholder=" Username"40 aria-label=" Username"/>39 <input type="text" id="firstName" class="form-control" placeholder="First name" 40 aria-label="Firstname"/> 41 41 </div> 42 42 </div> … … 72 72 73 73 <div class="form-outline mb-4"> 74 <input type=" email" id="companyName" class="form-control" placeholder="Company Name"74 <input type="text" id="companyName" class="form-control" placeholder="Company Name" 75 75 aria-label="companyName"/> 76 76 </div> … … 86 86 </div> 87 87 88 <div class="row"> 89 <div class="form-outline col-md-10"> 90 <div class="form-outline"> 91 <input type="text" id="services" class="form-control" placeholder="Services" 92 aria-label="services"/> 88 <div class="form-outline mb-4"> 89 <div class="row"> 90 <div class="col-md-10"> 91 <div class="form-outline"> 92 <input type="text" id="input_service" class="form-control" 93 placeholder="Services" 94 aria-label="services" disabled="true"/> 95 </div> 93 96 </div> 94 </div>95 <div class="form-outline col-md-2 d-grid">96 < button class="btn btn-primary" id="add_service">Add</button>97 <div class="form-outline col-md-2 d-grid"> 98 <button class="btn btn-primary" id="add_service" disabled="true">Add</button> 99 </div> 97 100 </div> 98 101 </div> … … 104 107 105 108 <!-- Submit button --> 106 <button type=" submit" class="btn btn-primary btn-block mb-4">109 <button type="buttom" class="btn btn-primary btn-block mb-4" id="signup_business_button"> 107 110 Sign up 108 111 </button>
Note:
See TracChangeset
for help on using the changeset viewer.