Adds salary specifications with detailed accordion view
Introduces new salary specification feature with interactive accordion component Implements detailed salary breakdown including: - Salary specification JSON data model - Salary specification page with printable view - Accordion component for expanding/collapsing salary details - Localization support for new salary labels Enhances employee salary transparency and detail presentation
This commit is contained in:
parent
f3c54dde35
commit
a1059adf06
14 changed files with 1613 additions and 46 deletions
|
|
@ -572,6 +572,50 @@ Dashed border knap til tilføjelse af elementer.
|
|||
|
||||
---
|
||||
|
||||
## Accordion (accordion.css)
|
||||
|
||||
Genbrugeligt accordion component med expand/collapse animation og single-open behavior.
|
||||
|
||||
```html
|
||||
<swp-accordion>
|
||||
<swp-accordion-item>
|
||||
<swp-accordion-header>
|
||||
<swp-accordion-info>
|
||||
<swp-accordion-title>Titel</swp-accordion-title>
|
||||
<swp-accordion-meta>Subtitle</swp-accordion-meta>
|
||||
</swp-accordion-info>
|
||||
<swp-accordion-summary>
|
||||
<swp-summary-item>
|
||||
<swp-summary-value>1.234 kr</swp-summary-value>
|
||||
<swp-summary-label>Label</swp-summary-label>
|
||||
</swp-summary-item>
|
||||
<swp-accordion-toggle>
|
||||
<i class="ph ph-caret-down"></i>
|
||||
</swp-accordion-toggle>
|
||||
</swp-accordion-summary>
|
||||
</swp-accordion-header>
|
||||
<swp-accordion-content>
|
||||
<!-- Content shown when expanded -->
|
||||
</swp-accordion-content>
|
||||
</swp-accordion-item>
|
||||
</swp-accordion>
|
||||
```
|
||||
|
||||
**Features:**
|
||||
- Single-open behavior (kun en udvidet ad gangen)
|
||||
- Smooth expand/collapse animation (250ms/200ms)
|
||||
- Caret icon roterer 180 ved expand
|
||||
- Config row (`swp-config-row`) til key-value info
|
||||
|
||||
**TypeScript:**
|
||||
```typescript
|
||||
import { Accordion } from './modules/accordion';
|
||||
|
||||
const accordion = new Accordion('#my-accordion', { singleOpen: true });
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Fil Reference
|
||||
|
||||
| Fil | Indhold |
|
||||
|
|
@ -582,7 +626,8 @@ Dashed border knap til tilføjelse af elementer.
|
|||
| `components.css` | Buttons, badges, cards, section-label, add-button, avatars, icon-btn, **swp-data-table** |
|
||||
| `stats.css` | Stat cards, stat rows |
|
||||
| `tabs.css` | Tab bar, tab content |
|
||||
| `employees.css` | User info, edit forms, document lists, context styles (.employees-list, .salary-history, .stats-bookings) |
|
||||
| `accordion.css` | Accordion component (swp-accordion, swp-accordion-item, expand/collapse) |
|
||||
| `employees.css` | User info, edit forms, document lists, context styles (.employees-list, .salary-history, .salary-specifications, .stats-bookings) |
|
||||
| `account.css` | Account/billing styles, context styles (.invoice-history) |
|
||||
| `bookings.css` | Booking list items |
|
||||
| `notifications.css` | Notification items |
|
||||
|
|
|
|||
203
PlanTempus.Application/wwwroot/css/accordion.css
Normal file
203
PlanTempus.Application/wwwroot/css/accordion.css
Normal file
|
|
@ -0,0 +1,203 @@
|
|||
/**
|
||||
* Accordion Component
|
||||
*
|
||||
* Generic reusable accordion with expand/collapse behavior.
|
||||
* Based on POC employee-card pattern from poc-loen-provision.html.
|
||||
*
|
||||
* Usage:
|
||||
* <swp-accordion>
|
||||
* <swp-accordion-item>
|
||||
* <swp-accordion-header>
|
||||
* <swp-accordion-info>
|
||||
* <swp-accordion-title>Title</swp-accordion-title>
|
||||
* <swp-accordion-meta>Subtitle</swp-accordion-meta>
|
||||
* </swp-accordion-info>
|
||||
* <swp-accordion-summary>
|
||||
* <swp-summary-item>
|
||||
* <swp-summary-value>Value</swp-summary-value>
|
||||
* <swp-summary-label>Label</swp-summary-label>
|
||||
* </swp-summary-item>
|
||||
* </swp-accordion-summary>
|
||||
* <swp-accordion-toggle>
|
||||
* <i class="ph ph-caret-down"></i>
|
||||
* </swp-accordion-toggle>
|
||||
* </swp-accordion-header>
|
||||
* <swp-accordion-content>
|
||||
* <!-- Content -->
|
||||
* </swp-accordion-content>
|
||||
* </swp-accordion-item>
|
||||
* </swp-accordion>
|
||||
*/
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION CONTAINER
|
||||
=========================================== */
|
||||
swp-accordion {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--spacing-4);
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION ITEM
|
||||
=========================================== */
|
||||
swp-accordion-item {
|
||||
display: block;
|
||||
background: var(--color-surface);
|
||||
border-radius: var(--radius-md);
|
||||
border: 1px solid var(--color-border);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION HEADER (clickable)
|
||||
=========================================== */
|
||||
swp-accordion-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: var(--spacing-5) var(--spacing-6);
|
||||
cursor: pointer;
|
||||
transition: background var(--transition-fast);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
swp-accordion-header:hover {
|
||||
background: var(--color-background-alt);
|
||||
}
|
||||
|
||||
/* Info section (left side) */
|
||||
swp-accordion-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
swp-accordion-title {
|
||||
font-size: var(--font-size-base);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
swp-accordion-meta {
|
||||
font-size: var(--font-size-sm);
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
/* Summary section (right side values) */
|
||||
swp-accordion-summary {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-6);
|
||||
}
|
||||
|
||||
swp-summary-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
swp-summary-value {
|
||||
font-size: var(--font-size-lg);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
font-family: var(--font-mono);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
swp-summary-label {
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
/* Toggle icon */
|
||||
swp-accordion-toggle {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--color-text-secondary);
|
||||
transition: transform 200ms ease;
|
||||
margin-left: var(--spacing-4);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
swp-accordion-toggle i {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
/* Expanded state - rotate toggle */
|
||||
swp-accordion-item.expanded swp-accordion-toggle {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION CONTENT
|
||||
=========================================== */
|
||||
swp-accordion-content {
|
||||
display: none;
|
||||
border-top: 1px solid var(--color-border);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Expanded state - show content */
|
||||
swp-accordion-item.expanded swp-accordion-content {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
CONFIG ROW (inside accordion content)
|
||||
=========================================== */
|
||||
swp-config-row {
|
||||
display: flex;
|
||||
gap: var(--spacing-6);
|
||||
padding: var(--spacing-5) var(--spacing-6);
|
||||
background: var(--color-background-alt);
|
||||
border-bottom: 1px solid var(--color-border);
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
swp-config-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--spacing-2);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
swp-config-label {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
swp-config-value {
|
||||
font-weight: var(--font-weight-medium);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
swp-config-value.mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION TABLE WRAPPER
|
||||
=========================================== */
|
||||
swp-accordion-table {
|
||||
display: block;
|
||||
padding: var(--spacing-6);
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
ACCORDION FOOTER (inside accordion content)
|
||||
=========================================== */
|
||||
swp-accordion-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-3);
|
||||
padding: var(--spacing-4) var(--spacing-6);
|
||||
background: var(--color-background-alt);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
|
@ -954,3 +954,59 @@ swp-employee-display {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================================
|
||||
SALARY SPECIFICATIONS ACCORDION
|
||||
Reuses: swp-accordion (accordion.css), swp-data-table (components.css)
|
||||
=========================================== */
|
||||
swp-card.salary-specifications {
|
||||
margin-top: var(--spacing-8);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-accordion {
|
||||
padding: 0 var(--spacing-6) var(--spacing-6);
|
||||
}
|
||||
|
||||
/* Table columns for weeks data (9 columns) */
|
||||
swp-card.salary-specifications swp-data-table.specification-weeks {
|
||||
grid-template-columns: 70px repeat(8, 1fr);
|
||||
}
|
||||
|
||||
/* Cell styling */
|
||||
swp-card.salary-specifications swp-data-table-cell {
|
||||
padding: var(--spacing-3) var(--spacing-2);
|
||||
font-size: var(--font-size-sm);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-data-table-cell.mono {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-data-table-cell.warning {
|
||||
color: var(--color-amber);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-data-table-cell.highlight {
|
||||
color: var(--color-teal);
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
|
||||
/* Footer row styling */
|
||||
swp-card.salary-specifications swp-data-table-footer {
|
||||
display: grid;
|
||||
grid-column: 1 / -1;
|
||||
grid-template-columns: subgrid;
|
||||
background: var(--color-background-alt);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-data-table-footer swp-data-table-cell {
|
||||
font-weight: var(--font-weight-semibold);
|
||||
padding: var(--spacing-4) var(--spacing-2);
|
||||
}
|
||||
|
||||
swp-card.salary-specifications swp-data-table-footer swp-data-table-cell:first-child {
|
||||
font-size: var(--font-size-xs);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
|
|
|||
190
PlanTempus.Application/wwwroot/ts/modules/accordion.ts
Normal file
190
PlanTempus.Application/wwwroot/ts/modules/accordion.ts
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
/**
|
||||
* Accordion Controller
|
||||
*
|
||||
* Generic accordion component with smooth expand/collapse animations.
|
||||
* Supports single-open behavior (only one item expanded at a time).
|
||||
*/
|
||||
|
||||
export interface AccordionOptions {
|
||||
/** Only allow one item to be expanded at a time (default: true) */
|
||||
singleOpen?: boolean;
|
||||
/** Animation duration for expand in ms (default: 250) */
|
||||
expandDuration?: number;
|
||||
/** Animation duration for collapse in ms (default: 200) */
|
||||
collapseDuration?: number;
|
||||
}
|
||||
|
||||
export class Accordion {
|
||||
private container: HTMLElement;
|
||||
private singleOpen: boolean;
|
||||
private expandDuration: number;
|
||||
private collapseDuration: number;
|
||||
|
||||
constructor(selector: string | HTMLElement, options: AccordionOptions = {}) {
|
||||
// Get container element
|
||||
if (typeof selector === 'string') {
|
||||
const el = document.querySelector<HTMLElement>(selector);
|
||||
if (!el) {
|
||||
console.warn(`Accordion: Element not found for selector "${selector}"`);
|
||||
return;
|
||||
}
|
||||
this.container = el;
|
||||
} else {
|
||||
this.container = selector;
|
||||
}
|
||||
|
||||
// Set options with defaults
|
||||
this.singleOpen = options.singleOpen ?? true;
|
||||
this.expandDuration = options.expandDuration ?? 250;
|
||||
this.collapseDuration = options.collapseDuration ?? 200;
|
||||
|
||||
this.setupEventListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup click listeners on accordion headers
|
||||
*/
|
||||
private setupEventListeners(): void {
|
||||
const headers = this.container.querySelectorAll<HTMLElement>('swp-accordion-header');
|
||||
|
||||
headers.forEach(header => {
|
||||
header.addEventListener('click', (e) => {
|
||||
// Don't toggle if clicking on interactive elements
|
||||
const target = e.target as HTMLElement;
|
||||
if (target.closest('input, button, a, select')) return;
|
||||
|
||||
const item = header.closest<HTMLElement>('swp-accordion-item');
|
||||
if (item) {
|
||||
this.toggle(item);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle an accordion item
|
||||
*/
|
||||
toggle(item: HTMLElement): void {
|
||||
const isExpanded = item.classList.contains('expanded');
|
||||
|
||||
if (isExpanded) {
|
||||
this.collapse(item);
|
||||
} else {
|
||||
// Close other items first if single-open mode
|
||||
if (this.singleOpen) {
|
||||
this.container.querySelectorAll<HTMLElement>('swp-accordion-item.expanded').forEach(otherItem => {
|
||||
if (otherItem !== item) {
|
||||
this.collapse(otherItem);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.expand(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand an accordion item with animation
|
||||
*/
|
||||
expand(item: HTMLElement): void {
|
||||
const content = item.querySelector<HTMLElement>('swp-accordion-content');
|
||||
const toggle = item.querySelector<HTMLElement>('swp-accordion-toggle');
|
||||
|
||||
if (!content) return;
|
||||
|
||||
// Add expanded class immediately for CSS to show content
|
||||
item.classList.add('expanded');
|
||||
|
||||
// Animate toggle icon rotation
|
||||
toggle?.animate([
|
||||
{ transform: 'rotate(0deg)' },
|
||||
{ transform: 'rotate(180deg)' }
|
||||
], {
|
||||
duration: this.expandDuration,
|
||||
easing: 'ease-out',
|
||||
fill: 'forwards'
|
||||
});
|
||||
|
||||
// Animate content height
|
||||
const height = content.scrollHeight;
|
||||
content.animate([
|
||||
{ height: '0px', opacity: 0 },
|
||||
{ height: `${height}px`, opacity: 1 }
|
||||
], {
|
||||
duration: this.expandDuration,
|
||||
easing: 'ease-out',
|
||||
fill: 'forwards'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapse an accordion item with animation
|
||||
*/
|
||||
collapse(item: HTMLElement): void {
|
||||
const content = item.querySelector<HTMLElement>('swp-accordion-content');
|
||||
const toggle = item.querySelector<HTMLElement>('swp-accordion-toggle');
|
||||
|
||||
if (!content) return;
|
||||
|
||||
// Animate toggle icon rotation
|
||||
toggle?.animate([
|
||||
{ transform: 'rotate(180deg)' },
|
||||
{ transform: 'rotate(0deg)' }
|
||||
], {
|
||||
duration: this.collapseDuration,
|
||||
easing: 'ease-out',
|
||||
fill: 'forwards'
|
||||
});
|
||||
|
||||
// Animate content height
|
||||
const height = content.scrollHeight;
|
||||
const animation = content.animate([
|
||||
{ height: `${height}px`, opacity: 1 },
|
||||
{ height: '0px', opacity: 0 }
|
||||
], {
|
||||
duration: this.collapseDuration,
|
||||
easing: 'ease-out',
|
||||
fill: 'forwards'
|
||||
});
|
||||
|
||||
// Remove expanded class after animation completes
|
||||
animation.onfinish = () => {
|
||||
item.classList.remove('expanded');
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand all items (only useful when singleOpen is false)
|
||||
*/
|
||||
expandAll(): void {
|
||||
this.container.querySelectorAll<HTMLElement>('swp-accordion-item:not(.expanded)').forEach(item => {
|
||||
this.expand(item);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapse all items
|
||||
*/
|
||||
collapseAll(): void {
|
||||
this.container.querySelectorAll<HTMLElement>('swp-accordion-item.expanded').forEach(item => {
|
||||
this.collapse(item);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all expanded items
|
||||
*/
|
||||
getExpanded(): HTMLElement[] {
|
||||
return Array.from(this.container.querySelectorAll<HTMLElement>('swp-accordion-item.expanded'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all accordions on the page
|
||||
*/
|
||||
export function initAccordions(options: AccordionOptions = {}): Accordion[] {
|
||||
const accordions: Accordion[] = [];
|
||||
document.querySelectorAll<HTMLElement>('swp-accordion').forEach(container => {
|
||||
accordions.push(new Accordion(container, options));
|
||||
});
|
||||
return accordions;
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import { createChart } from '@sevenweirdpeople/swp-charting';
|
||||
import { Accordion, initAccordions } from './accordion';
|
||||
|
||||
/**
|
||||
* Employees Controller
|
||||
|
|
@ -72,6 +73,7 @@ export class EmployeesController {
|
|||
private ratesSync: RatesSyncController | null = null;
|
||||
private scheduleController: ScheduleController | null = null;
|
||||
private statsController: EmployeeStatsController | null = null;
|
||||
private salaryAccordions: Accordion[] = [];
|
||||
private listView: HTMLElement | null = null;
|
||||
private detailView: HTMLElement | null = null;
|
||||
|
||||
|
|
@ -91,6 +93,20 @@ export class EmployeesController {
|
|||
this.ratesSync = new RatesSyncController();
|
||||
this.scheduleController = new ScheduleController();
|
||||
this.statsController = new EmployeeStatsController();
|
||||
this.initSalaryAccordions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize salary accordions when they exist
|
||||
*/
|
||||
private initSalaryAccordions(): void {
|
||||
// Initialize all accordions in the salary tab
|
||||
const salaryTab = document.querySelector('swp-tab-content[data-tab="salary"]');
|
||||
if (salaryTab) {
|
||||
salaryTab.querySelectorAll<HTMLElement>('swp-accordion').forEach(accordion => {
|
||||
this.salaryAccordions.push(new Accordion(accordion, { singleOpen: true }));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue