Fixed conflict between components

This commit is contained in:
Gregorio Chiko Putra
2019-05-16 13:47:48 +07:00
parent c4b05cb525
commit ac77c45f30
5 changed files with 115 additions and 94 deletions

97
public/js/app.js vendored
View File

@@ -4744,6 +4744,10 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var mithril__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! mithril */ "./node_modules/mithril/mithril.mjs");
/* harmony import */ var _components_SuratKelulusan__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/SuratKelulusan */ "./resources/js/components/SuratKelulusan.js");
/* harmony import */ var _components_SKHasilBelajar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/SKHasilBelajar */ "./resources/js/components/SKHasilBelajar.js");
/* harmony import */ var _models_Siswa__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./models/Siswa */ "./resources/js/models/Siswa.js");
/* harmony import */ var _models_AccessLog__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./models/AccessLog */ "./resources/js/models/AccessLog.js");
@@ -4751,6 +4755,52 @@ mithril__WEBPACK_IMPORTED_MODULE_0__["default"].route.prefix('#');
mithril__WEBPACK_IMPORTED_MODULE_0__["default"].route(document.body.querySelector('.container'), '/', {
'/': _components_SuratKelulusan__WEBPACK_IMPORTED_MODULE_1__["default"],
'/hasil-belajar': _components_SKHasilBelajar__WEBPACK_IMPORTED_MODULE_2__["default"]
}); // Below is to handle Ctrl+P or MouseR->Print
window.addEventListener("beforeprint", function () {
if (mithril__WEBPACK_IMPORTED_MODULE_0__["default"].route.get() === '/hasil-belajar') {
// If the print button did not exists, show nothing when printing
if (document.body.querySelector('button.print-button') === null) document.body.style.display = 'none';else {
if (!component.confirmPrint) {
alert('Surat Keterangan ini hanya dapat dicetak satu kali. Lanjutkan?');
component.confirmPrint = 1;
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].create({
siswaId: _models_Siswa__WEBPACK_IMPORTED_MODULE_3__["default"].current.id,
src: 'sk-hasil-belajar'
}).then(function () {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].fetch('sk-hasil-belajar');
})["catch"](function (e) {
if (e.code === 0) {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].error = {
message: e.message,
errors: {
create: ['Terjadi kesalahan saat menghubungkan ke server.']
}
};
} else {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].error = JSON.parse(e.message);
}
});
}
}
}
});
window.addEventListener("afterprint", function () {
if (mithril__WEBPACK_IMPORTED_MODULE_0__["default"].route.get() === '/hasil-belajar') {
// Give back the whole document.body
if (document.body.querySelector('button.print-button') === null) document.body.style.display = 'block'; // Hide the print button
if (document.body.querySelector('button.print-button') !== null) document.body.querySelector('button.print-button').style.display = 'none'; // To redraw the content to prevent printing
var nisn = document.body.querySelector('input[name=nisn]').value,
tanggalLahir = document.body.querySelector('input[name=tanggalLahir]').value;
_models_Siswa__WEBPACK_IMPORTED_MODULE_3__["default"].cariData({
nisn: nisn,
tanggalLahir: tanggalLahir,
src: 'sk-hasil-belajar',
"with": ['hasilBelajar', 'accessLog']
});
}
});
/***/ }),
@@ -4778,7 +4828,7 @@ __webpack_require__.r(__webpack_exports__);
var component = {
oninit: function oninit() {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].fetch('sk-hasil-belajar');
_models_Siswa__WEBPACK_IMPORTED_MODULE_3__["default"].current = {}, _models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].fetch('sk-hasil-belajar');
},
namaMapel: {
'agama': 'Pendidikan Agama',
@@ -4905,49 +4955,7 @@ var component = {
}
}))), Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('tr', Object(mithril__WEBPACK_IMPORTED_MODULE_0__["default"])('td', 'Drs. Engkos Kosasih, M.M.'))])])])];
}
}; // Below is to handle Ctrl+P or MouseR->Print
window.addEventListener("beforeprint", function () {
// If the print button did not exists, show nothing when printing
if (document.body.querySelector('button.print-button') === null) document.body.style.display = 'none';else {
if (!component.confirmPrint) {
alert('Surat Keterangan ini hanya dapat dicetak satu kali. Lanjutkan?');
component.confirmPrint = 1;
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].create({
siswaId: _models_Siswa__WEBPACK_IMPORTED_MODULE_3__["default"].current.id,
src: 'sk-hasil-belajar'
}).then(function () {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].fetch('sk-hasil-belajar');
})["catch"](function (e) {
if (e.code === 0) {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].error = {
message: e.message,
errors: {
create: ['Terjadi kesalahan saat menghubungkan ke server.']
}
};
} else {
_models_AccessLog__WEBPACK_IMPORTED_MODULE_4__["default"].error = JSON.parse(e.message);
}
});
}
}
});
window.addEventListener("afterprint", function () {
// Give back the whole document.body
if (document.body.querySelector('button.print-button') === null) document.body.style.display = 'block'; // Hide the print button
if (document.body.querySelector('button.print-button') !== null) document.body.querySelector('button.print-button').style.display = 'none'; // To redraw the content to prevent printing
var nisn = document.body.querySelector('input[name=nisn]').value,
tanggalLahir = document.body.querySelector('input[name=tanggalLahir]').value;
_models_Siswa__WEBPACK_IMPORTED_MODULE_3__["default"].cariData({
nisn: nisn,
tanggalLahir: tanggalLahir,
src: 'sk-hasil-belajar',
"with": ['hasilBelajar', 'accessLog']
});
});
};
/* harmony default export */ __webpack_exports__["default"] = (component);
/***/ }),
@@ -4972,6 +4980,7 @@ __webpack_require__.r(__webpack_exports__);
var component = {
oninit: function oninit() {
_models_Siswa__WEBPACK_IMPORTED_MODULE_2__["default"].current = {};
_models_AccessLog__WEBPACK_IMPORTED_MODULE_3__["default"].fetch('surat-kelulusan');
},
view: function view() {