Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bring back validation colors on fields #1459

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/ims/element/static/ims.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,14 @@ function enableEditing() {

// Add an error indication to a control
function controlHasError(element) {
element.parent().addClass("has-error");
element.parent().addClass("is-invalid");
}


// Add a success indication to a control
function controlHasSuccess(element, clearTimeout) {
element.parent().addClass("has-success");
if (clearTimeout != undefined) {
element.addClass("is-valid");
if (clearTimeout !== undefined) {
element.delay("1000").queue(function(next) {
controlClear(element);
next();
Expand All @@ -319,9 +319,8 @@ function controlHasSuccess(element, clearTimeout) {

// Clear error/success indication from a control
function controlClear(element) {
var parent = element.parent();
parent.removeClass("has-error");
parent.removeClass("has-success");
element.removeClass("is-invalid");
element.removeClass("is-valid");
}


Expand Down Expand Up @@ -890,8 +889,10 @@ function submitReportEntry() {
console.log("New report entry:\n" + text);

function ok() {
const $textArea = $("#incident_report_add");
// Clear the report entry
$("#incident_report_add").val("");
$textArea.val("");
controlHasSuccess($textArea, 1000);
// Reset the submit button
reportEntryEdited();
}
Expand All @@ -901,6 +902,7 @@ function submitReportEntry() {
submitButton.removeClass("btn-default");
submitButton.removeClass("btn-warning");
submitButton.addClass("btn-danger");
controlHasError($("#incident_report_add"), 1000);
}

sendEdits({"report_entries": [{"text": text}]}, ok, fail);
Expand All @@ -910,7 +912,7 @@ function submitReportEntry() {
function editFromElement(element, jsonKey, transform) {
var value = element.val();

if (transform != undefined) {
if (transform !== undefined) {
value = transform(value);
}

Expand All @@ -931,7 +933,7 @@ function editFromElement(element, jsonKey, transform) {

// Location must include type

if (edits.location != undefined) {
if (edits.location !== undefined) {
edits.location.type = "garett"; // UI only supports one type
}

Expand Down
2 changes: 2 additions & 0 deletions src/ims/element/static/incident.js
Original file line number Diff line number Diff line change
Expand Up @@ -1173,13 +1173,15 @@ function attachIncidentReport() {

function ok(data, status, xhr) {
loadAndDisplayIncidentReports();
controlHasSuccess(select, 1000);
}

function fail(requestError, status, xhr) {
var message = "Failed to attach field report";
console.log(message + ": " + requestError);
loadAndDisplayIncidentReports();
setErrorMessage(message);
controlHasError(select);
}

var url = (
Expand Down
Loading