Skip to content

Commit a60d0eb

Browse files
committed
highlight modified fields in suggestion form
1 parent 0a72290 commit a60d0eb

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

app/public/js/location_report.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,22 @@ function suggestionButtonClicked() {
169169
});
170170
}
171171

172+
function highlightDiffField(id) {
173+
var element = document.getElementById(id);
174+
element.addEventListener("change",function(event){
175+
if(element.dataset.value != element.value){
176+
$(element).addClass('highlight');
177+
} else {
178+
$(element).removeClass('highlight');
179+
}
180+
})
181+
}
182+
172183
function setupSuggestionFeature() {
184+
highlightDiffField("location-name");
185+
highlightDiffField("phone-number");
186+
highlightDiffField("address");
187+
highlightDiffField("url");
173188
$("#suggestionFormConfirm").click(suggestionButtonClicked);
174189
}
175190

app/resources/assets/sass/_location_map_report.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ This is where to put SCSS for the location report that shows a map.
3737
}
3838
}
3939

40+
.highlight {
41+
background-color: rgba(77, 121, 255,0.3) !important;
42+
}
43+
4044
.suggestion-form {
4145
label {
4246
margin-top: 7px;

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88
<div class="col-sm-6 col-xs-12">
99
<div class="input-group">
1010
<label for="location-name">Location name:</label>
11-
<input type="text" class="form-control" name="location-name" id="location-name" value="{{ $location->name }}" required>
11+
<input type="text" class="form-control" name="location-name" id="location-name" data-value="{{ $location->name }}" value="{{ $location->name }}" required>
1212
</div>
1313
</div>
1414
<div class="col-sm-6 col-xs-12">
1515
<div class="input-group">
1616
<label for="phone-number">Phone number:</label>
17-
<input type="tel" class="form-control" name="phone-number" id="phone-number" value="{{ $location->phone_number }}">
17+
<input type="tel" class="form-control" name="phone-number" id="phone-number" data-value="{{ $location->phone_number }}" value="{{ $location->phone_number }}">
1818
</div>
1919
</div>
2020
<div class="col-xs-12">
2121
<div class="input-group">
2222
<label for="address">Address:</label>
23-
<input type="text" class="form-control" name="address" id="address" value="{{ $location->address }}" required>
23+
<input type="text" class="form-control" name="address" id="address" data-value="{{ $location->address }}" value="{{ $location->address }}" required>
2424
</div>
2525
</div>
2626
<div class="col-xs-12">
2727
<div class="input-group">
2828
<label for="url">External website:</label>
29-
<input type="url" class="form-control" name="url" id="url" value="{{ $location->external_web_url }}">
29+
<input type="url" class="form-control" name="url" id="url" data-value="{{ $location->external_web_url }}" value="{{ $location->external_web_url }}">
3030
</div>
3131
</div>
3232
</div>

0 commit comments

Comments
 (0)