Added possibillity to delete attachments in admin page.

This commit is contained in:
Jan Böhmer 2019-04-06 18:38:36 +02:00
parent 72cd9a3722
commit 7c43feefbe
10 changed files with 133 additions and 19 deletions

View file

@ -256,12 +256,9 @@ class AjaxUI {
console.debug('Links registered!');
}
/**
* Register all forms for loading via ajax.
*/
public registerForm()
protected getFormOptions() : JQueryFormOptions
{
let options : JQueryFormOptions = {
return {
success: this.onAjaxComplete,
beforeSerialize: function() : boolean {
@ -285,12 +282,34 @@ class AjaxUI {
return true;
}
};
}
/**
* Register all forms for loading via ajax.
*/
public registerForm()
{
let options = this.getFormOptions();
$('form').not('[data-no-ajax]').ajaxForm(options);
console.debug('Forms registered!');
}
/**
* Submits the given form via ajax.
* @param form The form that will be submmitted.
*/
public submitForm(form)
{
let options = ajaxUI.getFormOptions();
$(form).ajaxSubmit(options);
}
/**
* Show the progressbar
*/

View file

@ -29,6 +29,7 @@
*/
import {ajaxUI} from "./ajax_ui";
import "bootbox";
/************************************
*
@ -188,6 +189,29 @@ $(document).on("ajaxUI:start ajaxUI:reload", function() {
});
});
$(document).on("ajaxUI:start ajaxUI:reload", function() {
$("[data-delete-form]").unbind('submit').submit(function(event) {
event.preventDefault();
let form = this;
let title = $(this).data("title");
let message = $(this).data("message");
bootbox.confirm({
message: message,
title: title,
callback: function(result) {
//If the dialog was confirmed, then submit the form.
if(result) {
ajaxUI.submitForm(form);
}
}});
return false;
});
});
/**
* Register the button, to jump to the top of the page.