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

View File

@@ -6,6 +6,7 @@ import AccessLog from "../models/AccessLog"
var component = {
oninit: () => {
Siswa.current = {},
AccessLog.fetch('sk-hasil-belajar');
},
namaMapel: {
@@ -350,53 +351,4 @@ var component = {
},
};
// 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;
AccessLog.create({siswaId: Siswa.current.id, src: 'sk-hasil-belajar'}).then(() => {
AccessLog.fetch('sk-hasil-belajar');
})
.catch(e => {
if (e.code === 0) {
AccessLog.error = {
message: e.message,
errors: {
create: ['Terjadi kesalahan saat menghubungkan ke server.'],
},
};
}
else {
AccessLog.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
let nisn = document.body.querySelector('input[name=nisn]').value,
tanggalLahir = document.body.querySelector('input[name=tanggalLahir]').value;
Siswa.cariData({
nisn,
tanggalLahir,
src: 'sk-hasil-belajar',
with: ['hasilBelajar', 'accessLog'],
});
});
export default component;

View File

@@ -5,6 +5,7 @@ import AccessLog from "../models/AccessLog"
var component = {
oninit: () => {
Siswa.current = {};
AccessLog.fetch('surat-kelulusan');
},
view: () => {