|
127 | 127 | setTimeout(() => { tooltip.fadeOut(200, function() { $(this).remove(); }); }, 800);
|
128 | 128 | }
|
129 | 129 |
|
| 130 | + /** |
| 131 | + * Post the update, and update the term status. |
| 132 | + * We only need to update the status as that's the only |
| 133 | + * thing that might change as a side-effect of setting |
| 134 | + * the parent. |
| 135 | + */ |
130 | 136 | function post_update(td, term_id, update_type, update) {
|
| 137 | + |
| 138 | + // Update via datatables dom manipulation, keeps the dt |
| 139 | + // model consistent. |
| 140 | + const _update_status_in_row = function(updated_status) { |
| 141 | + const table = $('#termtable').DataTable(); |
| 142 | + const row = table.row(td.closest('tr')); |
| 143 | + const select = row.node().querySelector('.term-status-select'); |
| 144 | + if (select) |
| 145 | + select.value = updated_status; |
| 146 | + }; |
| 147 | + |
131 | 148 | const payload = {
|
132 | 149 | term_id: term_id,
|
133 | 150 | update_type: update_type,
|
|
140 | 157 | contentType: 'application/json',
|
141 | 158 | data: JSON.stringify(payload),
|
142 | 159 | success: function(response) {
|
143 |
| - // console.log('Success:', response.status); |
144 | 160 | _show_saved_checkmark(td);
|
145 |
| - // Stay on page 2 if editing an element on page 2. :-P |
146 |
| - const change_current_page_on_redraw = false; |
147 |
| - $('#termtable').DataTable().draw(change_current_page_on_redraw); |
| 161 | + _update_status_in_row(response.status); |
148 | 162 | },
|
149 | 163 | error: function(xhr) {
|
150 | 164 | if (xhr.responseJSON && xhr.responseJSON.error) {
|
|
262 | 276 | const editableStatusCell = function (td, cellData, rowData, row, col) {
|
263 | 277 | function makeDropdown(td) {
|
264 | 278 | const select = document.createElement('select');
|
| 279 | + select.classList.add('term-status-select'); |
265 | 280 | select.innerHTML = '';
|
266 | 281 | {% for s in update_statuses %}
|
267 | 282 | select.innerHTML += '<option value="{{s.id}}">{{ s.text }}</option>';
|
|
0 commit comments