Better UX when saving notes

This commit is contained in:
Oliver 2023-04-17 17:11:56 +10:00
parent 34ec78649b
commit 87f2ebced1
2 changed files with 6 additions and 3 deletions

View File

@ -476,12 +476,15 @@ function setupNotesField(element, url, options={}) {
data[options.notes_field || 'notes'] = mde.value(); data[options.notes_field || 'notes'] = mde.value();
$('#save-notes').find('#save-icon').removeClass('fa-save').addClass('fa-spin fa-spinner');
inventreePut(url, data, { inventreePut(url, data, {
method: 'PATCH', method: 'PATCH',
success: function(response) { success: function(response) {
showMessage('{% trans "Notes updated" %}', {style: 'success'}); $('#save-notes').find('#save-icon').removeClass('fa-spin fa-spinner').addClass('fa-check-circle');
}, },
error: function(xhr) { error: function(xhr) {
$('#save-notes').find('#save-icon').removeClass('fa-spin fa-spinner').addClass('fa-times-circle icon-red');
showApiError(xhr, url); showApiError(xhr, url);
} }
}); });

View File

@ -1,8 +1,8 @@
{% load i18n %} {% load i18n %}
<button type='button' id='edit-notes' title='{% trans "Edit" %}' class='btn btn-primary'> <button type='button' id='edit-notes' title='{% trans "Edit" %}' class='btn btn-primary'>
<span class='fas fa-edit'></span> {% trans "Edit" %} <span id='edit-icon' class='fas fa-edit'></span> {% trans "Edit" %}
</button> </button>
<button type='button' id='save-notes' title='{% trans "Save" %}' class='btn btn-success' style='display: none;'> <button type='button' id='save-notes' title='{% trans "Save" %}' class='btn btn-success' style='display: none;'>
<span class='fas fa-save'></span> {% trans "Save" %} <span id='save-icon' class='fas fa-save'></span> {% trans "Save" %}
</button> </button>