localize library cdn, remove approve button from transaction page, fix all fitur running datatable as well, fixing sortable datatable using new cdn, fix modal approve, add note to receiver mutations
This commit is contained in:
129
resources/js/cdn/dataTables.bootstrap4.min.js
vendored
Normal file
129
resources/js/cdn/dataTables.bootstrap4.min.js
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
/*! DataTables Bootstrap 4 integration
|
||||
* ©2011-2017 SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
!(function (t) {
|
||||
var n, o;
|
||||
"function" == typeof define && define.amd
|
||||
? define(["jquery", "datatables.net"], function (e) {
|
||||
return t(e, window, document);
|
||||
})
|
||||
: "object" == typeof exports
|
||||
? ((n = require("jquery")),
|
||||
(o = function (e, a) {
|
||||
a.fn.dataTable || require("datatables.net")(e, a);
|
||||
}),
|
||||
"undefined" == typeof window
|
||||
? (module.exports = function (e, a) {
|
||||
return (
|
||||
(e = e || window),
|
||||
(a = a || n(e)),
|
||||
o(e, a),
|
||||
t(a, 0, e.document)
|
||||
);
|
||||
})
|
||||
: (o(window, n),
|
||||
(module.exports = t(n, window, window.document))))
|
||||
: t(jQuery, window, document);
|
||||
})(function (x, e, n, o) {
|
||||
"use strict";
|
||||
var r = x.fn.dataTable;
|
||||
return (
|
||||
x.extend(!0, r.defaults, {
|
||||
dom: "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>><'row'<'col-sm-12'tr>><'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>",
|
||||
renderer: "bootstrap",
|
||||
}),
|
||||
x.extend(r.ext.classes, {
|
||||
sWrapper: "dataTables_wrapper dt-bootstrap4",
|
||||
sFilterInput: "form-control form-control-sm",
|
||||
sLengthSelect:
|
||||
"custom-select custom-select-sm form-control form-control-sm",
|
||||
sProcessing: "dataTables_processing card",
|
||||
sPageButton: "paginate_button page-item",
|
||||
}),
|
||||
(r.ext.renderer.pageButton.bootstrap = function (i, e, d, a, l, c) {
|
||||
function u(e, a) {
|
||||
for (
|
||||
var t,
|
||||
n,
|
||||
o = function (e) {
|
||||
e.preventDefault(),
|
||||
x(e.currentTarget).hasClass("disabled") ||
|
||||
m.page() == e.data.action ||
|
||||
m.page(e.data.action).draw("page");
|
||||
},
|
||||
r = 0,
|
||||
s = a.length;
|
||||
r < s;
|
||||
r++
|
||||
)
|
||||
if (((t = a[r]), Array.isArray(t))) u(e, t);
|
||||
else {
|
||||
switch (((f = p = ""), t)) {
|
||||
case "ellipsis":
|
||||
(p = "…"), (f = "disabled");
|
||||
break;
|
||||
case "first":
|
||||
(p = g.sFirst),
|
||||
(f = t + (0 < l ? "" : " disabled"));
|
||||
break;
|
||||
case "previous":
|
||||
(p = g.sPrevious),
|
||||
(f = t + (0 < l ? "" : " disabled"));
|
||||
break;
|
||||
case "next":
|
||||
(p = g.sNext),
|
||||
(f = t + (l < c - 1 ? "" : " disabled"));
|
||||
break;
|
||||
case "last":
|
||||
(p = g.sLast),
|
||||
(f = t + (l < c - 1 ? "" : " disabled"));
|
||||
break;
|
||||
default:
|
||||
(p = t + 1), (f = l === t ? "active" : "");
|
||||
}
|
||||
p &&
|
||||
((n = -1 !== f.indexOf("disabled")),
|
||||
(n = x("<li>", {
|
||||
class: b.sPageButton + " " + f,
|
||||
id:
|
||||
0 === d && "string" == typeof t
|
||||
? i.sTableId + "_" + t
|
||||
: null,
|
||||
})
|
||||
.append(
|
||||
x("<a>", {
|
||||
href: n ? null : "#",
|
||||
"aria-controls": i.sTableId,
|
||||
"aria-disabled": n ? "true" : null,
|
||||
"aria-label": w[t],
|
||||
role: "link",
|
||||
"aria-current":
|
||||
"active" === f ? "page" : null,
|
||||
"data-dt-idx": t,
|
||||
tabindex: n ? -1 : i.iTabIndex,
|
||||
class: "page-link",
|
||||
}).html(p)
|
||||
)
|
||||
.appendTo(e)),
|
||||
i.oApi._fnBindAction(n, { action: t }, o));
|
||||
}
|
||||
}
|
||||
var p,
|
||||
f,
|
||||
t,
|
||||
m = new r.Api(i),
|
||||
b = i.oClasses,
|
||||
g = i.oLanguage.oPaginate,
|
||||
w = i.oLanguage.oAria.paginate || {};
|
||||
try {
|
||||
t = x(e).find(n.activeElement).data("dt-idx");
|
||||
} catch (e) {}
|
||||
u(x(e).empty().html('<ul class="pagination"/>').children("ul"), a),
|
||||
t !== o &&
|
||||
x(e)
|
||||
.find("[data-dt-idx=" + t + "]")
|
||||
.trigger("focus");
|
||||
}),
|
||||
r
|
||||
);
|
||||
});
|
||||
415
resources/js/cdn/dataTables.fixedColumns.min.js
vendored
Normal file
415
resources/js/cdn/dataTables.fixedColumns.min.js
vendored
Normal file
@@ -0,0 +1,415 @@
|
||||
/*! FixedColumns 4.2.2
|
||||
* © SpryMedia Ltd - datatables.net/license
|
||||
*/
|
||||
!(function (e) {
|
||||
var i, l;
|
||||
"function" == typeof define && define.amd
|
||||
? define(["jquery", "datatables.net"], function (t) {
|
||||
return e(t, window, document);
|
||||
})
|
||||
: "object" == typeof exports
|
||||
? ((i = require("jquery")),
|
||||
(l = function (t, s) {
|
||||
s.fn.dataTable || require("datatables.net")(t, s);
|
||||
}),
|
||||
"undefined" != typeof window
|
||||
? (module.exports = function (t, s) {
|
||||
return (
|
||||
(t = t || window),
|
||||
(s = s || i(t)),
|
||||
l(t, s),
|
||||
e(s, 0, t.document)
|
||||
);
|
||||
})
|
||||
: (l(window, i),
|
||||
(module.exports = e(i, window, window.document))))
|
||||
: e(jQuery, window, document);
|
||||
})(function (l, t, s, F) {
|
||||
"use strict";
|
||||
var A,
|
||||
i,
|
||||
e,
|
||||
o,
|
||||
r = l.fn.dataTable;
|
||||
function d(t, s) {
|
||||
var e = this;
|
||||
if (i && i.versionCheck && i.versionCheck("1.10.0"))
|
||||
return (
|
||||
(t = new i.Api(t)),
|
||||
(this.classes = A.extend(!0, {}, d.classes)),
|
||||
(this.c = A.extend(!0, {}, d.defaults, s)),
|
||||
(s && s.left !== F) ||
|
||||
this.c.leftColumns === F ||
|
||||
(this.c.left = this.c.leftColumns),
|
||||
(s && s.right !== F) ||
|
||||
this.c.rightColumns === F ||
|
||||
(this.c.right = this.c.rightColumns),
|
||||
(this.s = {
|
||||
barWidth: 0,
|
||||
dt: t,
|
||||
rtl: "rtl" === A("body").css("direction"),
|
||||
}),
|
||||
(s = {
|
||||
bottom: "0px",
|
||||
display: "block",
|
||||
position: "absolute",
|
||||
width: this.s.barWidth + 1 + "px",
|
||||
}),
|
||||
(this.dom = {
|
||||
leftBottomBlocker: A("<div>")
|
||||
.css(s)
|
||||
.css("left", 0)
|
||||
.addClass(this.classes.leftBottomBlocker),
|
||||
leftTopBlocker: A("<div>")
|
||||
.css(s)
|
||||
.css({ left: 0, top: 0 })
|
||||
.addClass(this.classes.leftTopBlocker),
|
||||
rightBottomBlocker: A("<div>")
|
||||
.css(s)
|
||||
.css("right", 0)
|
||||
.addClass(this.classes.rightBottomBlocker),
|
||||
rightTopBlocker: A("<div>")
|
||||
.css(s)
|
||||
.css({ right: 0, top: 0 })
|
||||
.addClass(this.classes.rightTopBlocker),
|
||||
}),
|
||||
this.s.dt.settings()[0]._bInitComplete
|
||||
? (this._addStyles(), this._setKeyTableListener())
|
||||
: t.one("init.dt", function () {
|
||||
e._addStyles(), e._setKeyTableListener();
|
||||
}),
|
||||
t.on("column-sizing.dt", function () {
|
||||
return e._addStyles();
|
||||
}),
|
||||
(t.settings()[0]._fixedColumns = this)
|
||||
);
|
||||
throw new Error("StateRestore requires DataTables 1.10 or newer");
|
||||
}
|
||||
function h(t, s) {
|
||||
void 0 === s && (s = null);
|
||||
(t = new r.Api(t)),
|
||||
(s = s || t.init().fixedColumns || r.defaults.fixedColumns);
|
||||
new e(t, s);
|
||||
}
|
||||
return (
|
||||
(d.prototype.left = function (t) {
|
||||
return (
|
||||
t !== F && ((this.c.left = t), this._addStyles()), this.c.left
|
||||
);
|
||||
}),
|
||||
(d.prototype.right = function (t) {
|
||||
return (
|
||||
t !== F && ((this.c.right = t), this._addStyles()), this.c.right
|
||||
);
|
||||
}),
|
||||
(d.prototype._addStyles = function () {
|
||||
this.s.dt.settings()[0].oScroll.sY &&
|
||||
((s = A(this.s.dt.table().node()).closest(
|
||||
"div.dataTables_scrollBody"
|
||||
)[0]),
|
||||
(e = this.s.dt.settings()[0].oBrowser.barWidth),
|
||||
s.offsetWidth - s.clientWidth >= e
|
||||
? (this.s.barWidth = e)
|
||||
: (this.s.barWidth = 0),
|
||||
this.dom.rightTopBlocker.css("width", this.s.barWidth + 1),
|
||||
this.dom.leftTopBlocker.css("width", this.s.barWidth + 1),
|
||||
this.dom.rightBottomBlocker.css("width", this.s.barWidth + 1),
|
||||
this.dom.leftBottomBlocker.css("width", this.s.barWidth + 1));
|
||||
for (
|
||||
var t = null,
|
||||
s = this.s.dt.column(0).header(),
|
||||
e = null,
|
||||
i =
|
||||
(null !== s &&
|
||||
((e = (s = A(s)).outerHeight() + 1),
|
||||
(t = A(s.closest("div.dataTables_scroll")).css(
|
||||
"position",
|
||||
"relative"
|
||||
))),
|
||||
this.s.dt.column(0).footer()),
|
||||
l = null,
|
||||
o =
|
||||
(null !== i &&
|
||||
((l = (i = A(i)).outerHeight()), null === t) &&
|
||||
(t = A(i.closest("div.dataTables_scroll")).css(
|
||||
"position",
|
||||
"relative"
|
||||
)),
|
||||
this.s.dt.columns().data().toArray().length),
|
||||
r = 0,
|
||||
d = 0,
|
||||
h = A(this.s.dt.table().node())
|
||||
.children("tbody")
|
||||
.children("tr"),
|
||||
n = 0,
|
||||
a = new Map(),
|
||||
c = 0;
|
||||
c < o;
|
||||
c++
|
||||
) {
|
||||
var f = this.s.dt.column(c);
|
||||
if ((0 < c && a.set(c - 1, n), f.visible())) {
|
||||
var u = A(f.header()),
|
||||
g = A(f.footer());
|
||||
if (c - n < this.c.left) {
|
||||
if (
|
||||
(A(this.s.dt.table().node()).addClass(
|
||||
this.classes.tableFixedLeft
|
||||
),
|
||||
t.addClass(this.classes.tableFixedLeft),
|
||||
0 < c - n)
|
||||
)
|
||||
for (var C = c; C + 1 < o; ) {
|
||||
if (
|
||||
(y = this.s.dt.column(C - 1, {
|
||||
page: "current",
|
||||
})).visible()
|
||||
) {
|
||||
(r += A(y.nodes()[0]).outerWidth()),
|
||||
(d +=
|
||||
y.header() || y.footer()
|
||||
? A(y.header()).outerWidth()
|
||||
: 0);
|
||||
break;
|
||||
}
|
||||
C--;
|
||||
}
|
||||
for (var m = 0, p = h; m < p.length; m++) {
|
||||
var x = p[m];
|
||||
A(A(x).children()[c - n])
|
||||
.css(this._getCellCSS(!1, r, "left"))
|
||||
.addClass(this.classes.fixedLeft);
|
||||
}
|
||||
u
|
||||
.css(this._getCellCSS(!0, d, "left"))
|
||||
.addClass(this.classes.fixedLeft),
|
||||
g
|
||||
.css(this._getCellCSS(!0, d, "left"))
|
||||
.addClass(this.classes.fixedLeft);
|
||||
} else {
|
||||
for (var b = 0, v = h; b < v.length; b++) {
|
||||
x = v[b];
|
||||
(R = A(A(x).children()[c - n])).hasClass(
|
||||
this.classes.fixedLeft
|
||||
) &&
|
||||
R.css(this._clearCellCSS("left")).removeClass(
|
||||
this.classes.fixedLeft
|
||||
);
|
||||
}
|
||||
u.hasClass(this.classes.fixedLeft) &&
|
||||
u
|
||||
.css(this._clearCellCSS("left"))
|
||||
.removeClass(this.classes.fixedLeft),
|
||||
g.hasClass(this.classes.fixedLeft) &&
|
||||
g
|
||||
.css(this._clearCellCSS("left"))
|
||||
.removeClass(this.classes.fixedLeft);
|
||||
}
|
||||
} else n++;
|
||||
}
|
||||
for (var B = 0, S = 0, _ = 0, c = o - 1; 0 <= c; c--)
|
||||
if ((f = this.s.dt.column(c)).visible()) {
|
||||
var u = A(f.header()),
|
||||
g = A(f.footer()),
|
||||
k = a.get(c);
|
||||
if ((k === F && (k = n), c + _ >= o - this.c.right)) {
|
||||
if (
|
||||
(A(this.s.dt.table().node()).addClass(
|
||||
this.classes.tableFixedRight
|
||||
),
|
||||
t.addClass(this.classes.tableFixedRight),
|
||||
c + 1 + _ < o)
|
||||
)
|
||||
for (var y, C = c; C + 1 < o; ) {
|
||||
if (
|
||||
(y = this.s.dt.column(C + 1, {
|
||||
page: "current",
|
||||
})).visible()
|
||||
) {
|
||||
(B += A(y.nodes()[0]).outerWidth()),
|
||||
(S +=
|
||||
y.header() || y.footer()
|
||||
? A(y.header()).outerWidth()
|
||||
: 0);
|
||||
break;
|
||||
}
|
||||
C++;
|
||||
}
|
||||
for (var w = 0, T = h; w < T.length; w++) {
|
||||
x = T[w];
|
||||
A(A(x).children()[c - k])
|
||||
.css(this._getCellCSS(!1, B, "right"))
|
||||
.addClass(this.classes.fixedRight);
|
||||
}
|
||||
u
|
||||
.css(this._getCellCSS(!0, S, "right"))
|
||||
.addClass(this.classes.fixedRight),
|
||||
g
|
||||
.css(this._getCellCSS(!0, S, "right"))
|
||||
.addClass(this.classes.fixedRight);
|
||||
} else {
|
||||
for (var L = 0, W = h; L < W.length; L++) {
|
||||
var R,
|
||||
x = W[L];
|
||||
(R = A(A(x).children()[c - k])).hasClass(
|
||||
this.classes.fixedRight
|
||||
) &&
|
||||
R.css(this._clearCellCSS("right")).removeClass(
|
||||
this.classes.fixedRight
|
||||
);
|
||||
}
|
||||
u.hasClass(this.classes.fixedRight) &&
|
||||
u
|
||||
.css(this._clearCellCSS("right"))
|
||||
.removeClass(this.classes.fixedRight),
|
||||
g.hasClass(this.classes.fixedRight) &&
|
||||
g
|
||||
.css(this._clearCellCSS("right"))
|
||||
.removeClass(this.classes.fixedRight);
|
||||
}
|
||||
} else _++;
|
||||
s &&
|
||||
(this.s.rtl
|
||||
? (this.dom.leftTopBlocker.outerHeight(e),
|
||||
t.append(this.dom.leftTopBlocker))
|
||||
: (this.dom.rightTopBlocker.outerHeight(e),
|
||||
t.append(this.dom.rightTopBlocker))),
|
||||
i &&
|
||||
(this.s.rtl
|
||||
? (this.dom.leftBottomBlocker.outerHeight(l),
|
||||
t.append(this.dom.leftBottomBlocker))
|
||||
: (this.dom.rightBottomBlocker.outerHeight(l),
|
||||
t.append(this.dom.rightBottomBlocker)));
|
||||
}),
|
||||
(d.prototype._getCellCSS = function (t, s, e) {
|
||||
return "left" === e
|
||||
? this.s.rtl
|
||||
? { position: "sticky", right: s + "px" }
|
||||
: { left: s + "px", position: "sticky" }
|
||||
: this.s.rtl
|
||||
? {
|
||||
left: s + (t ? this.s.barWidth : 0) + "px",
|
||||
position: "sticky",
|
||||
}
|
||||
: {
|
||||
position: "sticky",
|
||||
right: s + (t ? this.s.barWidth : 0) + "px",
|
||||
};
|
||||
}),
|
||||
(d.prototype._clearCellCSS = function (t) {
|
||||
return "left" === t
|
||||
? this.s.rtl
|
||||
? { position: "", right: "" }
|
||||
: { left: "", position: "" }
|
||||
: this.s.rtl
|
||||
? { left: "", position: "" }
|
||||
: { position: "", right: "" };
|
||||
}),
|
||||
(d.prototype._setKeyTableListener = function () {
|
||||
var h = this;
|
||||
this.s.dt.on("key-focus", function (t, s, e) {
|
||||
var i,
|
||||
l,
|
||||
o,
|
||||
r = A(e.node()).offset(),
|
||||
d = A(
|
||||
A(h.s.dt.table().node()).closest(
|
||||
"div.dataTables_scrollBody"
|
||||
)
|
||||
);
|
||||
0 < h.c.left &&
|
||||
((i = (l = A(
|
||||
h.s.dt.column(h.c.left - 1).header()
|
||||
)).offset()),
|
||||
(l = l.outerWidth()),
|
||||
r.left < i.left + l) &&
|
||||
((o = d.scrollLeft()),
|
||||
d.scrollLeft(o - (i.left + l - r.left))),
|
||||
0 < h.c.right &&
|
||||
((i = h.s.dt.columns().data().toArray().length),
|
||||
(l = A(e.node()).outerWidth()),
|
||||
(e = A(h.s.dt.column(i - h.c.right).header()).offset()),
|
||||
r.left + l > e.left) &&
|
||||
((o = d.scrollLeft()),
|
||||
d.scrollLeft(o - (e.left - (r.left + l))));
|
||||
}),
|
||||
this.s.dt.on("draw", function () {
|
||||
h._addStyles();
|
||||
}),
|
||||
this.s.dt.on("column-reorder", function () {
|
||||
h._addStyles();
|
||||
}),
|
||||
this.s.dt.on("column-visibility", function (t, s, e, i, l) {
|
||||
l &&
|
||||
!s.bDestroying &&
|
||||
setTimeout(function () {
|
||||
h._addStyles();
|
||||
}, 50);
|
||||
});
|
||||
}),
|
||||
(d.version = "4.2.2"),
|
||||
(d.classes = {
|
||||
fixedLeft: "dtfc-fixed-left",
|
||||
fixedRight: "dtfc-fixed-right",
|
||||
leftBottomBlocker: "dtfc-left-bottom-blocker",
|
||||
leftTopBlocker: "dtfc-left-top-blocker",
|
||||
rightBottomBlocker: "dtfc-right-bottom-blocker",
|
||||
rightTopBlocker: "dtfc-right-top-blocker",
|
||||
tableFixedLeft: "dtfc-has-left",
|
||||
tableFixedRight: "dtfc-has-right",
|
||||
}),
|
||||
(d.defaults = { i18n: { button: "FixedColumns" }, left: 1, right: 0 }),
|
||||
(e = d),
|
||||
(i = (A = l).fn.dataTable),
|
||||
(l.fn.dataTable.FixedColumns = e),
|
||||
(l.fn.DataTable.FixedColumns = e),
|
||||
(o = r.Api.register)("fixedColumns()", function () {
|
||||
return this;
|
||||
}),
|
||||
o("fixedColumns().left()", function (t) {
|
||||
var s = this.context[0];
|
||||
return t !== F
|
||||
? (s._fixedColumns.left(t), this)
|
||||
: s._fixedColumns.left();
|
||||
}),
|
||||
o("fixedColumns().right()", function (t) {
|
||||
var s = this.context[0];
|
||||
return t !== F
|
||||
? (s._fixedColumns.right(t), this)
|
||||
: s._fixedColumns.right();
|
||||
}),
|
||||
(r.ext.buttons.fixedColumns = {
|
||||
action: function (t, s, e, i) {
|
||||
l(e).attr("active")
|
||||
? (l(e).removeAttr("active").removeClass("active"),
|
||||
s.fixedColumns().left(0),
|
||||
s.fixedColumns().right(0))
|
||||
: (l(e).attr("active", "true").addClass("active"),
|
||||
s.fixedColumns().left(i.config.left),
|
||||
s.fixedColumns().right(i.config.right));
|
||||
},
|
||||
config: { left: 1, right: 0 },
|
||||
init: function (t, s, e) {
|
||||
t.settings()[0]._fixedColumns === F && h(t.settings(), e),
|
||||
l(s).attr("active", "true").addClass("active"),
|
||||
t
|
||||
.button(s)
|
||||
.text(
|
||||
e.text ||
|
||||
t.i18n(
|
||||
"buttons.fixedColumns",
|
||||
t.settings()[0]._fixedColumns.c.i18n.button
|
||||
)
|
||||
);
|
||||
},
|
||||
text: null,
|
||||
}),
|
||||
l(s).on("plugin-init.dt", function (t, s) {
|
||||
"dt" !== t.namespace ||
|
||||
(!s.oInit.fixedColumns && !r.defaults.fixedColumns) ||
|
||||
s._fixedColumns ||
|
||||
h(s, null);
|
||||
}),
|
||||
r
|
||||
);
|
||||
});
|
||||
5690
resources/js/cdn/jquery.dataTables.min.js
vendored
Normal file
5690
resources/js/cdn/jquery.dataTables.min.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
resources/js/vendor.js
Normal file
16
resources/js/vendor.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// Import vendor libraries
|
||||
import "datatables.net";
|
||||
import "datatables.net-bs4";
|
||||
import "datatables.net-fixedcolumns";
|
||||
import "datatables.net-fixedcolumns-bs4";
|
||||
import Swal from "sweetalert2";
|
||||
import Chart from "chart.js/auto";
|
||||
import ChartDataLabels from "chartjs-plugin-datalabels";
|
||||
|
||||
// Make libraries globally available
|
||||
window.Swal = Swal;
|
||||
window.Chart = Chart;
|
||||
window.ChartDataLabels = ChartDataLabels;
|
||||
|
||||
// Register Chart.js plugin
|
||||
Chart.register(ChartDataLabels);
|
||||
@@ -1,74 +1,96 @@
|
||||
$(document).ready(function () {
|
||||
console.log("Mutations index.js loaded");
|
||||
|
||||
// Check if DataTables is available
|
||||
if (typeof $.fn.DataTable === "undefined") {
|
||||
console.error("DataTables not available!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Destroy existing table if any
|
||||
if ($.fn.DataTable.isDataTable("#mutations-table")) {
|
||||
$("#mutations-table").DataTable().destroy();
|
||||
}
|
||||
|
||||
// Initialize DataTable
|
||||
var table = $("#mutations-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
destroy: true,
|
||||
ajax: {
|
||||
url: $("#mutations-table").data("url"),
|
||||
type: "GET",
|
||||
error: function (xhr, error, code) {
|
||||
console.error("DataTables AJAX error:", error, code);
|
||||
},
|
||||
},
|
||||
columns: [
|
||||
columnDefs: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
targets: 0, // No. column
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: "5%",
|
||||
},
|
||||
{
|
||||
data: "mutation_number",
|
||||
name: "mutation_number",
|
||||
width: "12%",
|
||||
targets: [1, 2, 3, 4, 5, 6, 7], // All sortable columns
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "created_at",
|
||||
name: "created_at",
|
||||
width: "12%",
|
||||
},
|
||||
{
|
||||
data: "from_dealer",
|
||||
name: "fromDealer.name",
|
||||
width: "13%",
|
||||
},
|
||||
{
|
||||
data: "to_dealer",
|
||||
name: "toDealer.name",
|
||||
width: "13%",
|
||||
},
|
||||
{
|
||||
data: "requested_by",
|
||||
name: "requestedBy.name",
|
||||
width: "12%",
|
||||
},
|
||||
{
|
||||
data: "total_items",
|
||||
name: "total_items",
|
||||
width: "8%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
data: "status",
|
||||
name: "status",
|
||||
width: "12%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
data: "action",
|
||||
name: "action",
|
||||
targets: 8, // Action column
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
width: "20%",
|
||||
className: "text-center",
|
||||
},
|
||||
{
|
||||
targets: [6, 7], // Total Items and Status columns
|
||||
className: "text-center",
|
||||
},
|
||||
],
|
||||
order: [[2, "desc"]], // Order by created_at desc
|
||||
columns: [
|
||||
{
|
||||
data: "DT_RowIndex",
|
||||
name: "DT_RowIndex",
|
||||
},
|
||||
{
|
||||
data: "mutation_number",
|
||||
name: "mutation_number",
|
||||
},
|
||||
{
|
||||
data: "created_at",
|
||||
name: "created_at",
|
||||
},
|
||||
{
|
||||
data: "from_dealer",
|
||||
name: "fromDealer.name",
|
||||
},
|
||||
{
|
||||
data: "to_dealer",
|
||||
name: "toDealer.name",
|
||||
},
|
||||
{
|
||||
data: "requested_by",
|
||||
name: "requestedBy.name",
|
||||
},
|
||||
{
|
||||
data: "total_items",
|
||||
name: "total_items",
|
||||
},
|
||||
{
|
||||
data: "status",
|
||||
name: "status",
|
||||
},
|
||||
{
|
||||
data: "action",
|
||||
name: "action",
|
||||
},
|
||||
],
|
||||
order: [[1, "desc"]], // Order by mutation_number desc (which follows ID order)
|
||||
pageLength: 10,
|
||||
responsive: true,
|
||||
});
|
||||
|
||||
// Modal event handlers are now handled by Bootstrap 5 data attributes
|
||||
// No need for manual modal show/hide handlers
|
||||
|
||||
// Handle Cancel Button Click with SweetAlert
|
||||
$(document).on("click", ".btn-cancel", function () {
|
||||
var mutationId = $(this).data("id");
|
||||
|
||||
@@ -3,26 +3,119 @@ $.ajaxSetup({
|
||||
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
});
|
||||
let tableContainer = $("#products-table");
|
||||
let url = tableContainer.data("url");
|
||||
let table = $("#products-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: url,
|
||||
order: [[0, "desc"]],
|
||||
columns: [
|
||||
{ data: "code", name: "code" },
|
||||
{ data: "name", name: "name" },
|
||||
{ data: "category_name", name: "category.name" },
|
||||
{ data: "unit", name: "unit" },
|
||||
{
|
||||
data: "total_stock",
|
||||
name: "total_stock",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
|
||||
// Wait for DataTables to be available
|
||||
function initializeDataTable() {
|
||||
// Debug: Check if DataTables is loaded
|
||||
console.log("DataTables available:", typeof $.fn.DataTable !== "undefined");
|
||||
console.log("jQuery version:", $.fn.jquery);
|
||||
|
||||
if (typeof $.fn.DataTable === "undefined") {
|
||||
console.error("DataTables is not loaded! Retrying in 1 second...");
|
||||
setTimeout(initializeDataTable, 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
let tableContainer = $("#products-table");
|
||||
let url = tableContainer.data("url");
|
||||
|
||||
console.log("Table URL:", url);
|
||||
console.log("Initializing DataTable...");
|
||||
|
||||
let table = $("#products-table").DataTable({
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
url: url,
|
||||
error: function (xhr, error, thrown) {
|
||||
console.error("DataTables Ajax Error:", error, thrown);
|
||||
console.error("Response:", xhr.responseText);
|
||||
},
|
||||
},
|
||||
{ data: "action", name: "action", orderable: false, searchable: false },
|
||||
],
|
||||
order: [[0, "asc"]], // Order by first column (code) ascending
|
||||
columns: [
|
||||
{
|
||||
data: "code",
|
||||
name: "code",
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "name",
|
||||
name: "name",
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "category_name",
|
||||
name: "category.name",
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "unit",
|
||||
name: "unit",
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "total_stock",
|
||||
name: "total_stock",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
},
|
||||
{
|
||||
data: "action",
|
||||
name: "action",
|
||||
orderable: false,
|
||||
searchable: false,
|
||||
},
|
||||
],
|
||||
columnDefs: [
|
||||
{
|
||||
targets: [4, 5], // total_stock and action columns
|
||||
orderable: false,
|
||||
},
|
||||
],
|
||||
initComplete: function (settings, json) {
|
||||
console.log("DataTables initialized successfully");
|
||||
console.log("Settings:", settings);
|
||||
console.log(
|
||||
"Column ordering enabled for:",
|
||||
settings.aoColumns.map((col, index) => ({
|
||||
index: index,
|
||||
orderable: col.bSortable,
|
||||
name: col.sName || col.mData,
|
||||
}))
|
||||
);
|
||||
},
|
||||
drawCallback: function (settings) {
|
||||
console.log("DataTables draw completed");
|
||||
},
|
||||
headerCallback: function (thead, data, start, end, display) {
|
||||
console.log("Header callback - sorting icons should be visible");
|
||||
},
|
||||
});
|
||||
|
||||
// Debug: Log table instance
|
||||
console.log("DataTable instance:", table);
|
||||
|
||||
// Test column ordering programmatically
|
||||
setTimeout(function () {
|
||||
console.log("Testing column ordering...");
|
||||
try {
|
||||
table.order([1, "desc"]).draw();
|
||||
console.log("Column ordering test successful");
|
||||
} catch (e) {
|
||||
console.error("Column ordering test failed:", e);
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
// Initialize when document is ready
|
||||
$(document).ready(function () {
|
||||
console.log("Document ready, checking for DataTables...");
|
||||
initializeDataTable();
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-destroy-product", function () {
|
||||
@@ -44,17 +137,22 @@ $(document).on("click", ".btn-destroy-product", function () {
|
||||
_token: $('meta[name="csrf-token"]').attr("content"),
|
||||
},
|
||||
success: function () {
|
||||
alert("Produk berhasil dihapus.");
|
||||
Swal.fire(
|
||||
"Berhasil!",
|
||||
"Produk berhasil dihapus.",
|
||||
"success"
|
||||
);
|
||||
$("#products-table").DataTable().ajax.reload();
|
||||
},
|
||||
error: function (xhr) {
|
||||
alert("Gagal menghapus produk.");
|
||||
Swal.fire("Error!", "Gagal menghapus produk.", "error");
|
||||
console.error(xhr.responseText);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-toggle-active", function () {
|
||||
let button = $(this);
|
||||
let url = button.data("url");
|
||||
@@ -79,16 +177,21 @@ $(document).on("click", ".btn-toggle-active", function () {
|
||||
$("#products-table")
|
||||
.DataTable()
|
||||
.ajax.reload(null, false);
|
||||
alert(response.message);
|
||||
Swal.fire("Berhasil!", response.message, "success");
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
alert("Gagal mengubah status produk.");
|
||||
Swal.fire(
|
||||
"Error!",
|
||||
"Gagal mengubah status produk.",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".btn-product-stock-dealers", function () {
|
||||
const productId = $(this).data("id");
|
||||
const productName = $(this).data("name");
|
||||
@@ -99,7 +202,7 @@ $(document).on("click", ".btn-product-stock-dealers", function () {
|
||||
|
||||
// Initialize or reload DataTable inside modal
|
||||
$("#dealer-stock-table").DataTable({
|
||||
destroy: true, // reinit if exists
|
||||
destroy: true,
|
||||
processing: true,
|
||||
serverSide: true,
|
||||
ajax: {
|
||||
@@ -109,14 +212,25 @@ $(document).on("click", ".btn-product-stock-dealers", function () {
|
||||
},
|
||||
},
|
||||
columns: [
|
||||
{ data: "dealer_name", name: "dealer_name" },
|
||||
{ data: "quantity", name: "quantity" },
|
||||
{
|
||||
data: "dealer_name",
|
||||
name: "dealer_name",
|
||||
orderable: true,
|
||||
searchable: true,
|
||||
},
|
||||
{
|
||||
data: "quantity",
|
||||
name: "quantity",
|
||||
orderable: true,
|
||||
searchable: false,
|
||||
},
|
||||
],
|
||||
initComplete: function () {
|
||||
$("#dealerStockModal").modal("show");
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", "#dealerStockModal .close", function () {
|
||||
$("#dealerStockModal").modal("hide");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user