Group employee portal tabs
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<div>
|
||||
<p class="text-xs font-semibold uppercase tracking-[0.22em] text-brand-100">My Workspace</p>
|
||||
<h2 class="mt-2 text-2xl font-semibold">Employee Portal</h2>
|
||||
<p class="mt-2 max-w-3xl text-sm text-brand-100">Punch attendance, view priority work, track documents, leave, payslips and alerts from one staff workspace.</p>
|
||||
<p class="mt-2 max-w-3xl text-sm text-brand-100">Punch attendance, view priority work, track HR details, documents, payslips and alerts from one staff workspace.</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
{% if employee %}
|
||||
@@ -21,30 +21,21 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{% set tabs = [
|
||||
{% set main_tabs = [
|
||||
('overview','Overview'),
|
||||
('work','My Work Board'),
|
||||
('due-today','Due Today'),
|
||||
('overdue','Overdue'),
|
||||
('client-pending','Client Pending'),
|
||||
('returned','Returned / Blocked'),
|
||||
('attendance','My Attendance'),
|
||||
('profile','My Profile'),
|
||||
('leave','My Leave'),
|
||||
('documents','My Documents'),
|
||||
('payslips','My Payslips'),
|
||||
('offboarding','My Offboarding'),
|
||||
('alerts','My Alert'),
|
||||
('reports','My Reports')
|
||||
('work','Work'),
|
||||
('attendance','Attendance'),
|
||||
('hr','HR & Profile'),
|
||||
('reports','Reports')
|
||||
] %}
|
||||
|
||||
<section class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
|
||||
<div class="mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-slate-500">My Workspace</div>
|
||||
<div class="mb-2 px-1 text-xs font-semibold uppercase tracking-wide text-slate-500">Employee Workspace</div>
|
||||
<div class="overflow-x-auto pb-1">
|
||||
<div class="flex min-w-max flex-nowrap gap-2" id="employee-portal-tabs">
|
||||
{% for code, label in tabs %}
|
||||
<button type="button" data-tab="{{ code }}" class="employee-portal-tab inline-flex shrink-0 items-center rounded-xl px-3 py-2 text-sm font-semibold whitespace-nowrap transition {% if active_tab == code %}bg-brand-600 text-white shadow-soft{% else %}border border-slate-300 bg-white text-slate-700 hover:bg-slate-50{% endif %}">
|
||||
{{ label }}{% if code == 'alerts' and unread_alert_count is defined and unread_alert_count > 0 %}<span class="ml-2 rounded-full bg-white/20 px-2 py-0.5 text-[10px]">{{ unread_alert_count }}</span>{% endif %}
|
||||
{% for code, label in main_tabs %}
|
||||
<button type="button" data-tab="{{ code }}" class="employee-portal-tab employee-portal-main-tab inline-flex shrink-0 items-center rounded-xl px-4 py-2 text-sm font-semibold whitespace-nowrap transition {% if active_tab == code %}bg-brand-600 text-white shadow-soft{% else %}border border-slate-300 bg-white text-slate-700 hover:bg-slate-50{% endif %}">
|
||||
{{ label }}{% if code == 'hr' and unread_alert_count is defined and unread_alert_count > 0 %}<span class="ml-2 rounded-full bg-white/20 px-2 py-0.5 text-[10px]">{{ unread_alert_count }}</span>{% endif %}
|
||||
</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@@ -59,12 +50,35 @@
|
||||
<script>
|
||||
(function () {
|
||||
const panel = document.getElementById('employee-portal-panel');
|
||||
const tabs = Array.from(document.querySelectorAll('.employee-portal-tab'));
|
||||
if (!panel || !tabs.length) return;
|
||||
const mainTabs = Array.from(document.querySelectorAll('.employee-portal-main-tab'));
|
||||
if (!panel || !mainTabs.length) return;
|
||||
|
||||
const groupMap = {
|
||||
'overview': 'overview',
|
||||
'work': 'work',
|
||||
'work-board': 'work',
|
||||
'due-today': 'work',
|
||||
'overdue': 'work',
|
||||
'client-pending': 'work',
|
||||
'returned': 'work',
|
||||
'documents': 'work',
|
||||
'attendance': 'attendance',
|
||||
'attendance-details': 'attendance',
|
||||
'attendance-punch': 'attendance',
|
||||
'attendance-history': 'attendance',
|
||||
'hr': 'hr',
|
||||
'profile': 'hr',
|
||||
'leave': 'hr',
|
||||
'payslips': 'hr',
|
||||
'offboarding': 'hr',
|
||||
'alerts': 'hr',
|
||||
'reports': 'reports'
|
||||
};
|
||||
|
||||
function setActive(tabName) {
|
||||
tabs.forEach(function (button) {
|
||||
const active = button.dataset.tab === tabName;
|
||||
const activeGroup = groupMap[tabName] || tabName || 'overview';
|
||||
mainTabs.forEach(function (button) {
|
||||
const active = button.dataset.tab === activeGroup;
|
||||
button.classList.toggle('bg-brand-600', active);
|
||||
button.classList.toggle('text-white', active);
|
||||
button.classList.toggle('shadow-soft', active);
|
||||
@@ -77,18 +91,19 @@
|
||||
}
|
||||
|
||||
async function loadTab(tabName, pushState) {
|
||||
setActive(tabName);
|
||||
const safeTab = tabName || 'overview';
|
||||
setActive(safeTab);
|
||||
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
|
||||
try {
|
||||
const response = await fetch('/employee/dashboard/tab/' + encodeURIComponent(tabName), {
|
||||
const response = await fetch('/employee/dashboard/tab/' + encodeURIComponent(safeTab), {
|
||||
headers: {'X-Requested-With': 'fetch'}
|
||||
});
|
||||
if (!response.ok) throw new Error('HTTP ' + response.status);
|
||||
panel.innerHTML = await response.text();
|
||||
if (pushState) {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set('tab', tabName);
|
||||
window.history.pushState({tab: tabName}, '', url.toString());
|
||||
url.searchParams.set('tab', safeTab);
|
||||
window.history.pushState({tab: safeTab}, '', url.toString());
|
||||
}
|
||||
if (window.EmployeePortalGeo && typeof window.EmployeePortalGeo.bind === 'function') {
|
||||
window.EmployeePortalGeo.bind();
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<div class="space-y-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-slate-900">Attendance Centre</h3>
|
||||
<p class="mt-1 text-sm text-slate-600">Punch in/out and review recent attendance details.</p>
|
||||
</div>
|
||||
<a href="/employee/attendance" class="af-btn af-btn-secondary">Open Full Attendance Page</a>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" data-tab="attendance-details" class="employee-portal-tab rounded-xl bg-brand-600 px-3 py-2 text-sm font-semibold text-white">Punch & Details</button>
|
||||
<a href="/employee/attendance" class="rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Full Attendance History</a>
|
||||
<button type="button" data-tab="leave" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Leave Balance</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "modules/employees/templates/employees/portal_partials/attendance.html" %}
|
||||
</div>
|
||||
@@ -0,0 +1,44 @@
|
||||
<div class="space-y-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-slate-900">HR & Profile Centre</h3>
|
||||
<p class="mt-1 text-sm text-slate-600">Access your profile, leave, payslips, offboarding and alerts from one grouped section.</p>
|
||||
</div>
|
||||
<a href="/employee/profile" class="af-btn af-btn-secondary">Open Profile</a>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" data-tab="profile" class="employee-portal-tab rounded-xl bg-brand-600 px-3 py-2 text-sm font-semibold text-white">Profile</button>
|
||||
<button type="button" data-tab="leave" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Leave</button>
|
||||
<button type="button" data-tab="payslips" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Payslips</button>
|
||||
<button type="button" data-tab="offboarding" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Offboarding</button>
|
||||
<button type="button" data-tab="alerts" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Alerts{% if unread_alert_count is defined and unread_alert_count > 0 %}<span class="ml-2 rounded-full bg-red-100 px-2 py-0.5 text-[10px] text-red-700">{{ unread_alert_count }}</span>{% endif %}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<a href="/employee/profile" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft hover:border-brand-200">
|
||||
<div class="text-xs font-semibold uppercase text-slate-500">Profile</div>
|
||||
<h4 class="mt-2 text-base font-semibold text-slate-900">My Profile</h4>
|
||||
<p class="mt-1 text-sm text-slate-600">View employee master details, contact details and emergency contact.</p>
|
||||
</a>
|
||||
<a href="/employee/leave" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft hover:border-brand-200">
|
||||
<div class="text-xs font-semibold uppercase text-slate-500">Leave</div>
|
||||
<h4 class="mt-2 text-base font-semibold text-slate-900">My Leave</h4>
|
||||
<p class="mt-1 text-sm text-slate-600">View leave balances and request history.</p>
|
||||
</a>
|
||||
<a href="/employee/payslips" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft hover:border-brand-200">
|
||||
<div class="text-xs font-semibold uppercase text-slate-500">Payroll</div>
|
||||
<h4 class="mt-2 text-base font-semibold text-slate-900">My Payslips</h4>
|
||||
<p class="mt-1 text-sm text-slate-600">Open available payslips and payroll status.</p>
|
||||
</a>
|
||||
<a href="/alerts" class="rounded-2xl border border-slate-200 bg-white p-5 shadow-soft hover:border-brand-200">
|
||||
<div class="text-xs font-semibold uppercase text-slate-500">Alerts</div>
|
||||
<h4 class="mt-2 text-base font-semibold text-slate-900">My Alerts</h4>
|
||||
<p class="mt-1 text-sm text-slate-600">Check task, attendance, leave and system alerts.</p>
|
||||
</a>
|
||||
</section>
|
||||
|
||||
{% include "modules/employees/templates/employees/portal_partials/profile.html" %}
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
<div class="space-y-5">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<h3 class="text-lg font-semibold text-slate-900">Work Centre</h3>
|
||||
<p class="mt-1 text-sm text-slate-600">Use the sub-menu to filter your assigned work without leaving the employee portal.</p>
|
||||
</div>
|
||||
<a href="/employee/work" class="af-btn af-btn-primary">Open Full Work Board</a>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-slate-200 bg-white p-3 shadow-soft">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" data-tab="work-board" class="employee-portal-tab rounded-xl bg-brand-600 px-3 py-2 text-sm font-semibold text-white">My Work Board</button>
|
||||
<button type="button" data-tab="due-today" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Due Today</button>
|
||||
<button type="button" data-tab="overdue" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Overdue</button>
|
||||
<button type="button" data-tab="client-pending" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Client Pending</button>
|
||||
<button type="button" data-tab="returned" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Returned / Blocked</button>
|
||||
<button type="button" data-tab="documents" class="employee-portal-tab rounded-xl border border-slate-300 bg-white px-3 py-2 text-sm font-semibold text-slate-700 hover:bg-slate-50">Documents</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% include "modules/employees/templates/employees/portal_partials/work.html" %}
|
||||
</div>
|
||||
Reference in New Issue
Block a user