Skip to content

Commit 9902cd6

Browse files
committed
disable the confirm button when the field are not modified
1 parent a60d0eb commit 9902cd6

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/public/js/location_report.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
location_report.js is used in the report on a single location,
33
pages/location_report/collapsed.blade.php.
44
*/
5+
var suggestion_counter = 0;
56
function initMap() {
67
var map = new google.maps.Map(document.getElementById('map'), {
78
zoom: 15,
@@ -172,11 +173,22 @@ function suggestionButtonClicked() {
172173
function highlightDiffField(id) {
173174
var element = document.getElementById(id);
174175
element.addEventListener("change",function(event){
176+
//highlight modified suggestion fields
175177
if(element.dataset.value != element.value){
178+
if(!$(element).hasClass('highlight'))
179+
suggestion_counter += 1;
176180
$(element).addClass('highlight');
177181
} else {
182+
if($(element).hasClass('highlight'))
183+
suggestion_counter -= 1;
178184
$(element).removeClass('highlight');
179185
}
186+
// disable submit button when there is no difference in the fields
187+
if(suggestion_counter > 0)
188+
$("#suggestionFormConfirm").prop("disabled",false);
189+
else
190+
$("#suggestionFormConfirm").prop("disabled",true);
191+
180192
})
181193
}
182194

app/resources/views/pages/location_report/collapsed.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
<button type="button" class="btn btn-default"
152152
data-dismiss="modal">Close
153153
</button>
154-
<button type="button" class="btn btn-primary" id="suggestionFormConfirm">
154+
<button type="button" class="btn btn-primary" id="suggestionFormConfirm" disabled>
155155
Confirm
156156
</button>
157157
</div>

0 commit comments

Comments
 (0)