Update console output for forms.js

This commit is contained in:
Oliver Walters 2022-04-27 21:45:00 +10:00
parent 340d4d8a89
commit 24af2bd2c8

View File

@ -135,7 +135,7 @@ function getApiEndpointOptions(url, callback) {
success: callback, success: callback,
error: function(xhr) { error: function(xhr) {
// TODO: Handle error // TODO: Handle error
console.log(`ERROR in getApiEndpointOptions at '${url}'`); console.error(`Error in getApiEndpointOptions at '${url}'`);
showApiError(xhr, url); showApiError(xhr, url);
} }
}); });
@ -227,7 +227,7 @@ function constructChangeForm(fields, options) {
}, },
error: function(xhr) { error: function(xhr) {
// TODO: Handle error here // TODO: Handle error here
console.log(`ERROR in constructChangeForm at '${options.url}'`); console.error(`Error in constructChangeForm at '${options.url}'`);
showApiError(xhr, options.url); showApiError(xhr, options.url);
} }
@ -268,7 +268,7 @@ function constructDeleteForm(fields, options) {
}, },
error: function(xhr) { error: function(xhr) {
// TODO: Handle error here // TODO: Handle error here
console.log(`ERROR in constructDeleteForm at '${options.url}`); console.error(`Error in constructDeleteForm at '${options.url}`);
showApiError(xhr, options.url); showApiError(xhr, options.url);
} }
@ -354,7 +354,7 @@ function constructForm(url, options) {
icon: 'fas fa-user-times', icon: 'fas fa-user-times',
}); });
console.log(`'POST action unavailable at ${url}`); console.warn(`'POST action unavailable at ${url}`);
} }
break; break;
case 'PUT': case 'PUT':
@ -369,7 +369,7 @@ function constructForm(url, options) {
icon: 'fas fa-user-times', icon: 'fas fa-user-times',
}); });
console.log(`${options.method} action unavailable at ${url}`); console.warn(`${options.method} action unavailable at ${url}`);
} }
break; break;
case 'DELETE': case 'DELETE':
@ -383,7 +383,7 @@ function constructForm(url, options) {
icon: 'fas fa-user-times', icon: 'fas fa-user-times',
}); });
console.log(`DELETE action unavailable at ${url}`); console.warn(`DELETE action unavailable at ${url}`);
} }
break; break;
case 'GET': case 'GET':
@ -397,11 +397,11 @@ function constructForm(url, options) {
icon: 'fas fa-user-times', icon: 'fas fa-user-times',
}); });
console.log(`GET action unavailable at ${url}`); console.warn(`GET action unavailable at ${url}`);
} }
break; break;
default: default:
console.log(`constructForm() called with invalid method '${options.method}'`); console.warn(`constructForm() called with invalid method '${options.method}'`);
break; break;
} }
}); });
@ -731,7 +731,7 @@ function submitFormData(fields, options) {
data[name] = value; data[name] = value;
} }
} else { } else {
console.log(`WARNING: Could not find field matching '${name}'`); console.warn(`Could not find field matching '${name}'`);
} }
} }
@ -776,7 +776,7 @@ function submitFormData(fields, options) {
default: default:
$(options.modal).modal('hide'); $(options.modal).modal('hide');
console.log(`upload error at ${options.url}`); console.error(`Upload error at ${options.url}`);
showApiError(xhr, options.url); showApiError(xhr, options.url);
break; break;
} }
@ -827,7 +827,7 @@ function updateFieldValue(name, value, field, options) {
var el = getFormFieldElement(name, options); var el = getFormFieldElement(name, options);
if (!el) { if (!el) {
console.log(`WARNING: updateFieldValue could not find field '${name}'`); console.warn(`updateFieldValue could not find field '${name}'`);
return; return;
} }
@ -870,7 +870,7 @@ function getFormFieldElement(name, options) {
} }
if (!el.exists) { if (!el.exists) {
console.log(`ERROR: Could not find form element for field '${name}'`); console.error(`Could not find form element for field '${name}'`);
} }
return el; return el;
@ -918,7 +918,7 @@ function getFormFieldValue(name, field={}, options={}) {
var el = getFormFieldElement(name, options); var el = getFormFieldElement(name, options);
if (!el.exists()) { if (!el.exists()) {
console.log(`ERROR: getFormFieldValue could not locate field '${name}'`); console.error(`getFormFieldValue could not locate field '${name}'`);
return null; return null;
} }
@ -1104,7 +1104,7 @@ function handleNestedErrors(errors, field_name, options={}) {
// Nest list must be provided! // Nest list must be provided!
if (!nest_list) { if (!nest_list) {
console.log(`WARNING: handleNestedErrors missing nesting options for field '${fieldName}'`); console.warn(`handleNestedErrors missing nesting options for field '${fieldName}'`);
return; return;
} }
@ -1113,7 +1113,7 @@ function handleNestedErrors(errors, field_name, options={}) {
var error_item = error_list[idx]; var error_item = error_list[idx];
if (idx >= nest_list.length) { if (idx >= nest_list.length) {
console.log(`WARNING: handleNestedErrors returned greater number of errors (${error_list.length}) than could be handled (${nest_list.length})`); console.warn(`handleNestedErrors returned greater number of errors (${error_list.length}) than could be handled (${nest_list.length})`);
break; break;
} }
@ -1285,7 +1285,7 @@ function addFieldErrorMessage(name, error_text, error_idx=0, options={}) {
field_dom.append(error_html); field_dom.append(error_html);
} else { } else {
console.log(`WARNING: addFieldErrorMessage could not locate field '${field_name}'`); console.warn(`addFieldErrorMessage could not locate field '${field_name}'`);
} }
} }
@ -1358,7 +1358,7 @@ function addClearCallback(name, field, options={}) {
} }
if (!el) { if (!el) {
console.log(`WARNING: addClearCallback could not find field '${name}'`); console.warn(`addClearCallback could not find field '${name}'`);
return; return;
} }
@ -1582,7 +1582,7 @@ function initializeRelatedField(field, fields, options={}) {
var name = field.name; var name = field.name;
if (!field.api_url) { if (!field.api_url) {
console.log(`WARNING: Related field '${name}' missing 'api_url' parameter.`); console.warn(`Related field '${name}' missing 'api_url' parameter.`);
return; return;
} }
@ -1712,7 +1712,7 @@ function initializeRelatedField(field, fields, options={}) {
return $(html); return $(html);
} else { } else {
// Return a simple renderering // Return a simple renderering
console.log(`WARNING: templateResult() missing 'field.model' for '${name}'`); console.warn(`templateResult() missing 'field.model' for '${name}'`);
return `${name} - ${item.id}`; return `${name} - ${item.id}`;
} }
}, },
@ -1742,7 +1742,7 @@ function initializeRelatedField(field, fields, options={}) {
return $(html); return $(html);
} else { } else {
// Return a simple renderering // Return a simple renderering
console.log(`WARNING: templateSelection() missing 'field.model' for '${name}'`); console.warn(`templateSelection() missing 'field.model' for '${name}'`);
return `${name} - ${item.id}`; return `${name} - ${item.id}`;
} }
} }
@ -1916,7 +1916,7 @@ function renderModelData(name, model, data, parameters, options) {
if (html != null) { if (html != null) {
return html; return html;
} else { } else {
console.log(`ERROR: Rendering not implemented for model '${model}'`); console.error(`Rendering not implemented for model '${model}'`);
// Simple text rendering // Simple text rendering
return `${model} - ID ${data.id}`; return `${model} - ID ${data.id}`;
} }
@ -2201,7 +2201,7 @@ function constructInput(name, parameters, options={}) {
if (func != null) { if (func != null) {
html = func(name, parameters, options); html = func(name, parameters, options);
} else { } else {
console.log(`WARNING: Unhandled form field type: '${parameters.type}'`); console.warn(`Unhandled form field type: '${parameters.type}'`);
} }
return html; return html;
@ -2504,12 +2504,12 @@ function constructHelpText(name, parameters) {
function selectImportFields(url, data={}, options={}) { function selectImportFields(url, data={}, options={}) {
if (!data.model_fields) { if (!data.model_fields) {
console.log(`WARNING: selectImportFields is missing 'model_fields'`); console.warn(`selectImportFields is missing 'model_fields'`);
return; return;
} }
if (!data.file_fields) { if (!data.file_fields) {
console.log(`WARNING: selectImportFields is missing 'file_fields'`); console.warn(`selectImportFields is missing 'file_fields'`);
return; return;
} }
@ -2600,7 +2600,7 @@ function selectImportFields(url, data={}, options={}) {
default: default:
$(opts.modal).modal('hide'); $(opts.modal).modal('hide');
console.log(`upload error at ${opts.url}`); console.error(`upload error at ${opts.url}`);
showApiError(xhr, opts.url); showApiError(xhr, opts.url);
break; break;
} }