DONE: error on banner where it is not updated, use uploaded file for etika.pdf

This commit is contained in:
ISMAIL MASSERAN
2026-04-30 13:14:23 +08:00
parent b93b51c005
commit 4569decd92
10 changed files with 99 additions and 11 deletions
@@ -19,6 +19,22 @@
<hr>
<div class="form-group">
<label>Etika Mesyuarat Agung (Muat Turun)</label>
<div v-if="form.attendance_etika_url" class="help-block">
Semasa:
<a :href="form.attendance_etika_url" target="_blank" rel="noopener noreferrer">
{{ form.attendance_etika_url }}
</a>
</div>
<input type="file" class="form-control" @change="onEtikaChange" accept="application/pdf,image/*">
<small class="help-block">
Format: PDF/JPG/PNG/WEBP. Fail akan disimpan ke <code>storage/app/public/portal/</code>.
</small>
</div>
<hr>
<div class="form-group">
<label>Label KoPKB (Zoom) contoh: KoPKB KALI KE-29/2025</label>
<input v-model="form.zoom_meeting_label" type="text" class="form-control" placeholder="KoPKB KALI KE-29/2025">
@@ -61,13 +77,15 @@ export default {
loading: false,
saving: false,
bannerFile: null,
etikaFile: null,
form: {
home_mat_label: "",
home_banner_image_path: "",
zoom_meeting_label: "",
zoom_subtitle: "",
zoom_image_url: "",
zoom_meeting_url: ""
zoom_meeting_url: "",
attendance_etika_url: ""
}
};
},
@@ -83,6 +101,11 @@ export default {
this.bannerFile = files && files.length ? files[0] : null;
},
onEtikaChange(e) {
const files = e && e.target ? e.target.files : null;
this.etikaFile = files && files.length ? files[0] : null;
},
async fetch() {
this.loading = true;
try {
@@ -96,7 +119,8 @@ export default {
zoom_meeting_label: d.zoom_meeting_label || "",
zoom_subtitle: d.zoom_subtitle || "",
zoom_image_url: d.zoom_image_url || "",
zoom_meeting_url: d.zoom_meeting_url || ""
zoom_meeting_url: d.zoom_meeting_url || "",
attendance_etika_url: d.attendance_etika_url || ""
};
} else {
this.util.showResult(res, "error");
@@ -120,6 +144,7 @@ export default {
// zoom_image_url is intentionally not editable from UI (uses default icon / design).
fd.append("zoom_meeting_url", this.form.zoom_meeting_url || "");
if (this.bannerFile) fd.append("home_banner_image", this.bannerFile);
if (this.etikaFile) fd.append("attendance_etika_file", this.etikaFile);
const res = await axios.post(config.API + "admin/portal-settings", fd, {
headers: { "Content-Type": "multipart/form-data" }
@@ -128,6 +153,7 @@ export default {
if (res && res.data && res.data.status === "success") {
this.util.notify("Berjaya simpan tetapan portal.", "success");
this.bannerFile = null;
this.etikaFile = null;
await this.fetch();
} else {
this.util.showResult(res, "error");
@@ -76,9 +76,6 @@
<option value="1">Fizikal</option>
<option value="2">Maya</option>
</select>
<small class="form-text text-muted attendance-helper-text">
Sila pilih kehadiran (Maya/Fizikal) kemudian klik SAYA TERIMA.
</small>
</div>
<div v-if="selectedKehadiran === '1'" class="form-group attendance-field">
@@ -145,8 +142,7 @@
<p class="attendance-page-subtitle">
Sila semak maklumat anda, pilih kaedah kehadiran, dan sahkan penyertaan sebelum meneruskan.
</p>
<a href="https://drive.google.com/uc?export=download&id=1O5DVDIbGy-w0bejV6RqtJGIty-_5LJD8"
target="_blank" class="attendance-download-button">
<a :href="etikaUrl" target="_blank" class="attendance-download-button">
Muat Turun Etika Mesyuarat Agung
</a>
</div>
@@ -442,6 +438,7 @@ export default {
loading: false,
userSubmitted: false, // Add a flag to track if the user has already submitted
selectedKehadiran: '0',
portalSettings: null,
}
},
@@ -450,9 +447,17 @@ export default {
var el = document.getElementById('kehadiran');
if (el) this.selectedKehadiran = el.value || '0';
}
this.fetchPortalSettings();
},
computed: {
etikaUrl: function () {
var url = this.portalSettings && this.portalSettings.attendance_etika_url
? String(this.portalSettings.attendance_etika_url).trim()
: '';
if (url) return url;
return 'https://drive.google.com/uc?export=download&id=1O5DVDIbGy-w0bejV6RqtJGIty-_5LJD8';
},
/**
* Status 2 = pilihan raya sedang berjalan (butang SAYA TERIMA dibuka).
*/
@@ -485,6 +490,17 @@ export default {
},
methods: {
fetchPortalSettings: async function () {
try {
this.util.setAuthorization();
const res = await axios.get(config.API + "portal-settings");
if (res && res.data && res.data.status === "success") {
this.portalSettings = res.data.data || null;
}
} catch (e) {
// Non-critical — fall back to default URL.
}
},
onPhysicalGateCodeInput: function (e) {
var el = e.target;
var upper = el.value.toUpperCase();
@@ -224,7 +224,13 @@ export default {
const p = this.portalSettings && this.portalSettings.home_banner_image_path
? this.portalSettings.home_banner_image_path
: "/images/banner.jpeg";
return p;
const v = this.portalSettings && this.portalSettings.updated_at
? encodeURIComponent(this.portalSettings.updated_at)
: "";
if (!v) return p;
return p.includes("?") ? `${p}&v=${v}` : `${p}?v=${v}`;
},
/**
* Maya: boleh mengundi selepas daftar kehadiran. Fizikal: perlu disahkan pentadbir dahulu.