Elements can be deleted, add overlay during AJAX operations

merge-requests/60/head
Mike Koch 7 years ago
parent 8682bd236e
commit 5cdd216cdb

@ -56,16 +56,14 @@ require_once(HESK_PATH . 'inc/show_admin_nav.inc.php');
</tr> </tr>
</thead> </thead>
<tbody id="table-body"> <tbody id="table-body">
<tr id="loader">
<td colspan="6">
<i class="fa fa-spinner fa-spin"></i> Loading Custom Nav Elements&hellip;
</td>
</tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
<div class="overlay" id="overlay">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div> </div>
</section> </section>
</div> </div>

@ -2,6 +2,10 @@
color: #fff; color: #fff;
} }
.black {
color: #000;
}
.red, .red,
.important, .important,
.critical-priority { .critical-priority {

@ -4,6 +4,7 @@ $(document).ready(function() {
loadTable(); loadTable();
bindEditModal(); bindEditModal();
bindCreateModal(); bindCreateModal();
bindDeleteButton();
$('[data-toggle="nav-iconpicker"]').iconpicker({ $('[data-toggle="nav-iconpicker"]').iconpicker({
iconset: ['fontawesome', 'octicon'], iconset: ['fontawesome', 'octicon'],
@ -143,7 +144,6 @@ function loadTable(modalToClose) {
} }
$template.find('ul[data-property="subtext"]').html(subtext); $template.find('ul[data-property="subtext"]').html(subtext);
console.log($template);
$('#table-body').append($template); $('#table-body').append($template);
elements[this.id] = this; elements[this.id] = this;
@ -157,7 +157,7 @@ function loadTable(modalToClose) {
console.error(data); console.error(data);
}, },
complete: function() { complete: function() {
$('#loader').hide(); $('#overlay').hide();
} }
}); });
} }
@ -240,4 +240,26 @@ function bindCreateModal() {
$modal.modal('show'); $modal.modal('show');
}); });
}
function bindDeleteButton() {
$(document).on('click', '[data-action="delete"]', function() {
$('#overlay').show();
var heskUrl = $('#heskUrl').text();
var element = elements[$(this).parent().parent().find('[data-property="id"]').text()];
$.ajax({
method: 'DELETE',
url: heskUrl + '/api/v1-internal/custom-navigation/' + element.id,
headers: { 'X-Internal-Call': true },
success: function() {
console.log('DELETED!');
loadTable();
},
error: function(data) {
console.error(data);
}
});
});
} }
Loading…
Cancel
Save