mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-31 23:40:20 +02:00
Added possibillity to delete attachments in admin page.
This commit is contained in:
parent
72cd9a3722
commit
7c43feefbe
10 changed files with 133 additions and 19 deletions
|
@ -46,6 +46,8 @@ require('patternfly-bootstrap-treeview/src/js/bootstrap-treeview')
|
|||
|
||||
require('./datatables.js');
|
||||
|
||||
window.bootbox = require('bootbox')
|
||||
|
||||
|
||||
require('../ts_src/ajax_ui');
|
||||
import {ajaxUI} from "../ts_src/ajax_ui";
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"target": "es5",
|
||||
"sourceMap": true,
|
||||
"typeRoots": ["../node_modules"],
|
||||
"types": ["jquery", "js-cookie", "bootstrap", "jquery.form", "bootstrap-treeview"]
|
||||
"types": ["jquery", "js-cookie", "bootstrap", "jquery.form", "bootstrap-treeview", "bootbox"]
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue