-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebhooks.js
100 lines (93 loc) · 4.69 KB
/
webhooks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
webhooks = {
init: function() {
gemini_ui.fancyInputs('#table-admin-webhooks .fancy');
webhooks.initDatatablesWithEdit("#table-admin-webhooks", { "aoColumnDefs": [{ "bSortable": false, "aTargets": [4]}] });
$('#action-button-save','#table-admin-webhooks').click(function(){
gemini_ajax.postCall("apps/webhooks", "save", function (response) {
if(!response.success) {
gemini_popup.toast(response.Message, true);
return;
}
gemini_popup.toast("Saved");
gemini_admin.getPage();
}, null, {
Description: $('#Description', '#table-admin-webhooks').val(),
Url: $('#Url', '#table-admin-webhooks').val(),
Create: $('#Create', '#table-admin-webhooks').prop('checked'),
Update: $('#Update', '#table-admin-webhooks').prop('checked')
}, null, true);
});
$('#table-admin-webhooks').off('click', '.action-button-delete').on('click', '.action-button-delete', function(){
var that=$(this);
gemini_popup.modalConfirm("Are you sure that you want to delete " + that.parent().parent().data('id') + "?", null, function () {
gemini_ui.startBusy('#colorbox2 #modal-confirm #modal-button-yes');
gemini_ajax.postCall("apps/webhooks", "delete", function () {
gemini_admin.removeRow(that);
gemini_ui.stopBusy('#modal-confirm #modal-button-yes');
}, function () { gemini_ui.stopBusy('#modal-confirm #modal-button-yes'); }, {
Url: that.parent().parent().data('id')
}, null, true);
});
});
},
initDatatablesWithEdit: function (selector, options)
{
var optionsString = {};
var editSelector = "tbody td:not([data-edit='false'])";
if (options != null) optionsString = options;
var params = $.extend({},
{
bFilter: true,
bInfo: true,
bSort: true,
bPaginate: true,
bLengthChange: false,
iDisplayLength: 20,
sPaginationType: "full_numbers",
"oLanguage": {
"sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
"sInfoEmpty": "No data."
},
fnDrawCallback: function (value, y) {
$(selector + ' ' + editSelector).editable(csVars.Url + 'apps/webhooks/saveproperty', {
placeholder: '',
detectType: function (elem) {
var th = gemini_ui.getTableTHForTD(elem);
return $(th).data('edit-type');
},
validationRequired: function (elm) {
var th = gemini_ui.getTableTHForTD(elm);
return $(th).data('required');
},
validationEmail: function (elm) {
var th = gemini_ui.getTableTHForTD(elm);
return $(th).data('email');
},
validationProgrammaticalNames: function (elm) {
var th = gemini_ui.getTableTHForTD(elm);
return $(th).data('programmaticalnames');
},
loadurl: csVars.Url + 'apps/webhooks/getproperty',
loaddata: function () {
var th = gemini_ui.getTableTHForTD(this);
var field = $(th).data('field');
return {
id: $(this).parent().data('id'),
property: field
};
},
submitdata: function () {
var th = gemini_ui.getTableTHForTD(this);
var field = $(th).data('field');
return {
id: $(this).parent().data('id'),
property: field
};
},
"height": "14px"
});
}
}, optionsString);
gemini_admin.currentTable = $(selector).dataTable(params);
},
};