Merge branch 'bugfix/error-on-banner' into 'main'
DONE: error on banner where it is not updated, use uploaded file for etika.pdf See merge request erahn/voting!12
This commit is contained in:
@@ -11,5 +11,5 @@
|
||||
[x] bug on pagination page (kehadiran)
|
||||
[x] hardcode on daftar kehadiran
|
||||
[x] buang flow pengesahan
|
||||
|
||||
[ ] tambah siapa yang bagi duit (activity log)
|
||||
[x] tambah siapa yang bagi duit (activity log)
|
||||
[ ] there is certain part/files that is hardcoded
|
||||
@@ -15,12 +15,14 @@ class GetController extends Controller
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'updated_at' => optional($setting->updated_at)->toIso8601String(),
|
||||
'home_mat_label' => $setting->home_mat_label ?? $defaults['home_mat_label'],
|
||||
'home_banner_image_path' => $setting->home_banner_image_path ?? $defaults['home_banner_image_path'],
|
||||
'zoom_meeting_label' => $setting->zoom_meeting_label ?? $defaults['zoom_meeting_label'],
|
||||
'zoom_subtitle' => $setting->zoom_subtitle ?? $defaults['zoom_subtitle'],
|
||||
'zoom_image_url' => $setting->zoom_image_url ?? $defaults['zoom_image_url'],
|
||||
'zoom_meeting_url' => $setting->zoom_meeting_url ?? $defaults['zoom_meeting_url'],
|
||||
'attendance_etika_url' => $setting->attendance_etika_url ?? $defaults['attendance_etika_url'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ class UpdateController extends Controller
|
||||
'zoom_image_url' => 'nullable|string|max:2048',
|
||||
'zoom_meeting_url' => 'nullable|string|max:2048',
|
||||
'home_banner_image' => 'nullable|file|mimes:jpg,jpeg,png,webp|max:5120',
|
||||
'attendance_etika_file' => 'nullable|file|mimes:pdf,jpg,jpeg,png,webp|max:10240',
|
||||
]);
|
||||
|
||||
if ($request->hasFile('home_banner_image')) {
|
||||
@@ -31,6 +32,15 @@ class UpdateController extends Controller
|
||||
$validated['home_banner_image_path'] = '/storage/' . $relativePath;
|
||||
}
|
||||
|
||||
if ($request->hasFile('attendance_etika_file')) {
|
||||
$file = $request->file('attendance_etika_file');
|
||||
$ext = strtolower($file->getClientOriginalExtension() ?: 'pdf');
|
||||
$name = 'etika.' . $ext;
|
||||
$relativePath = 'portal/' . $name;
|
||||
Storage::disk('public')->putFileAs('portal', $file, $name);
|
||||
$validated['attendance_etika_url'] = '/storage/' . $relativePath;
|
||||
}
|
||||
|
||||
$setting->fill([
|
||||
'home_mat_label' => $validated['home_mat_label'] ?? $setting->home_mat_label,
|
||||
'home_banner_image_path' => $validated['home_banner_image_path'] ?? $setting->home_banner_image_path,
|
||||
@@ -38,6 +48,7 @@ class UpdateController extends Controller
|
||||
'zoom_subtitle' => $validated['zoom_subtitle'] ?? $setting->zoom_subtitle,
|
||||
'zoom_image_url' => $validated['zoom_image_url'] ?? $setting->zoom_image_url,
|
||||
'zoom_meeting_url' => $validated['zoom_meeting_url'] ?? $setting->zoom_meeting_url,
|
||||
'attendance_etika_url' => $validated['attendance_etika_url'] ?? $setting->attendance_etika_url,
|
||||
]);
|
||||
$setting->save();
|
||||
|
||||
|
||||
@@ -15,12 +15,14 @@ class GetController extends Controller
|
||||
return response()->json([
|
||||
'status' => 'success',
|
||||
'data' => [
|
||||
'updated_at' => optional($setting->updated_at)->toIso8601String(),
|
||||
'home_mat_label' => $setting->home_mat_label ?? $defaults['home_mat_label'],
|
||||
'home_banner_image_path' => $setting->home_banner_image_path ?? $defaults['home_banner_image_path'],
|
||||
'zoom_meeting_label' => $setting->zoom_meeting_label ?? $defaults['zoom_meeting_label'],
|
||||
'zoom_subtitle' => $setting->zoom_subtitle ?? $defaults['zoom_subtitle'],
|
||||
'zoom_image_url' => $setting->zoom_image_url ?? $defaults['zoom_image_url'],
|
||||
'zoom_meeting_url' => $setting->zoom_meeting_url ?? $defaults['zoom_meeting_url'],
|
||||
'attendance_etika_url' => $setting->attendance_etika_url ?? $defaults['attendance_etika_url'],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class PortalSetting extends Model
|
||||
'zoom_subtitle',
|
||||
'zoom_image_url',
|
||||
'zoom_meeting_url',
|
||||
'attendance_etika_url',
|
||||
];
|
||||
|
||||
public static function defaults(): array
|
||||
@@ -26,6 +27,7 @@ class PortalSetting extends Model
|
||||
'zoom_subtitle' => 'Sertai Mesyuarat Agung Tahunan KoPKB kali ke-29/2025 melalui pautan rasmi di bawah.',
|
||||
'zoom_image_url' => 'https://th.bing.com/th/id/OIP.TGLvYXfe4xq5MTZe4UnTDgHaEy?w=255&h=180&c=7&r=0&o=5&dpr=1.8&pid=1.7',
|
||||
'zoom_meeting_url' => 'https://meet.google.com/paa-tpck-ssq',
|
||||
'attendance_etika_url' => 'https://drive.google.com/uc?export=download&id=1O5DVDIbGy-w0bejV6RqtJGIty-_5LJD8',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddAttendanceEtikaUrlToPortalSettingsTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('portal_settings', function (Blueprint $table) {
|
||||
$table->string('attendance_etika_url')->nullable()->after('zoom_meeting_url');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('portal_settings', function (Blueprint $table) {
|
||||
$table->dropColumn('attendance_etika_url');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user