HR: update schedule layout (#2202)

This commit is contained in:
Alexander Platov 2022-07-04 21:16:04 +03:00 committed by GitHub
parent 19764866f7
commit 26d998a2dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 28 deletions

View File

@ -434,13 +434,13 @@
&:hover { background-color: var(--highlight-select-hover); } &:hover { background-color: var(--highlight-select-hover); }
} }
} }
}
.scroller-thead { .scroller-thead {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 2; z-index: 2;
background-color: var(--body-color); background-color: var(--body-color);
}
} }
// THead background-color in Tooltip and Popups // THead background-color in Tooltip and Popups

View File

@ -119,6 +119,4 @@
<SpaceSelector _class={hr.class.Department} label={hr.string.Department} bind:space={department} /> <SpaceSelector _class={hr.class.Department} label={hr.string.Department} bind:space={department} />
</div> </div>
<div class="mr-6 h-full"> <ScheduleMonthView {department} {descendants} departmentById={departments} {currentDate} {mode} />
<ScheduleMonthView {department} {descendants} departmentById={departments} {currentDate} {mode} />
</div>

View File

@ -189,47 +189,60 @@
} }
return total return total
} }
let hoveredIndex: number = -1
</script> </script>
{#if departmentStaff.length} {#if departmentStaff.length}
<Scroller> <Scroller tableFade>
<table> <table>
<thead class="scroller-thead"> <thead class="scroller-thead">
<tr class="scroller-thead__tr"> <tr class="scroller-thead__tr">
<th> <th>
<Label label={contact.string.Employee} /> <Label label={contact.string.Employee} />
</th> </th>
{#each values as value} {#each values as value, i}
{#if mode === CalendarMode.Year} {#if mode === CalendarMode.Year}
{@const month = getMonth(currentDate, value)} {@const month = getMonth(currentDate, value)}
<th <th
class="fixed" class="fixed"
class:today={month.getFullYear() === todayDate.getFullYear() && class:today={month.getFullYear() === todayDate.getFullYear() &&
month.getMonth() === todayDate.getMonth()} month.getMonth() === todayDate.getMonth()}
on:mousemove={() => {
hoveredIndex = i
}}
on:mouseleave={() => {
hoveredIndex = -1
}}
> >
<div class="cursor-pointer uppercase flex-col-center"> {getMonthName(month)}
<div class="flex-center">{getMonthName(month)}</div>
</div>
</th> </th>
{:else} {:else}
{@const day = getDay(new Date(startDate), value)} {@const day = getDay(new Date(startDate), value)}
<th class:today={areDatesEqual(todayDate, day)} class:weekend={isWeekend(day)}> <th
<div class="cursor-pointer uppercase flex-col-center"> class:today={areDatesEqual(todayDate, day)}
<div class="flex-center">{getWeekDayName(day, 'short')}</div> class:weekend={isWeekend(day)}
<div class="flex-center">{day.getDate()}</div> on:mousemove={() => {
</div> hoveredIndex = i
}}
on:mouseleave={() => {
hoveredIndex = -1
}}
>
{getWeekDayName(day, 'short')}
<span>{day.getDate()}</span>
</th> </th>
{/if} {/if}
{/each} {/each}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{#each departmentStaff as employee} {#each departmentStaff as employee, row}
<tr> <tr>
<td> <td>
<EmployeePresenter value={employee} /> <EmployeePresenter value={employee} />
</td> </td>
{#each values as value} {#each values as value, i}
{#if mode === CalendarMode.Year} {#if mode === CalendarMode.Year}
{@const month = getMonth(currentDate, value)} {@const month = getMonth(currentDate, value)}
{@const requests = getRequests(employee._id, month)} {@const requests = getRequests(employee._id, month)}
@ -256,6 +269,9 @@
class:today={areDatesEqual(todayDate, date)} class:today={areDatesEqual(todayDate, date)}
class:weekend={isWeekend(date)} class:weekend={isWeekend(date)}
class:cursor-pointer={editable} class:cursor-pointer={editable}
class:hovered={i === hoveredIndex}
class:firstLine={row === 0}
class:lastLine={row === departmentStaff.length - 1}
use:tooltip={tooltipValue} use:tooltip={tooltipValue}
on:click={(e) => createRequest(e, date, employee)} on:click={(e) => createRequest(e, date, employee)}
> >
@ -272,24 +288,26 @@
</table> </table>
</Scroller> </Scroller>
{:else} {:else}
<div class="flex-center h-full flex-grow fs-title"> <div class="flex-center h-full w-full flex-grow fs-title">
<Label label={hr.string.NoEmployeesInDepartment} /> <Label label={hr.string.NoEmployeesInDepartment} />
</div> </div>
{/if} {/if}
<style lang="scss"> <style lang="scss">
table { table {
border-collapse: collapse;
table-layout: fixed;
width: auto;
position: relative; position: relative;
width: 100%;
td, td,
th { th {
width: auto; width: auto;
min-width: 1rem; width: 2rem;
min-width: 1.5rem;
border: none;
&.fixed { &.fixed {
width: 5rem; width: 5rem;
padding: 0 0.125rem;
hyphens: auto;
} }
&:first-child { &:first-child {
width: 15rem; width: 15rem;
@ -297,13 +315,25 @@
} }
} }
th { th {
padding: 0.5rem; flex-shrink: 0;
padding: 0;
height: 2.5rem; height: 2.5rem;
min-height: 2.5rem;
max-height: 2.5rem;
text-transform: uppercase;
font-weight: 500; font-weight: 500;
font-size: 0.75rem; font-size: 0.75rem;
line-height: 105%;
color: var(--dark-color); color: var(--dark-color);
box-shadow: inset 0 -1px 0 0 var(--divider-color); box-shadow: inset 0 -1px 0 0 var(--divider-color);
user-select: none; user-select: none;
cursor: pointer;
span {
display: block;
font-weight: 600;
font-size: 1rem;
}
&.today { &.today {
color: var(--caption-color); color: var(--caption-color);
} }
@ -313,7 +343,7 @@
} }
td { td {
height: 3.5rem; height: 3.5rem;
border: 1px solid var(--divider-color); border: none;
color: var(--caption-color); color: var(--caption-color);
&.today { &.today {
background-color: var(--theme-bg-accent-hover); background-color: var(--theme-bg-accent-hover);
@ -322,5 +352,29 @@
background-color: var(--theme-bg-accent-color); background-color: var(--theme-bg-accent-color);
} }
} }
td:not(:last-child) {
border-right: 1px solid var(--divider-color);
}
tr:not(.scroller-thead__tr) {
border-bottom: 1px solid var(--divider-color);
}
tr.scroller-thead__tr:not(:last-child) {
border-right: 1px solid var(--divider-color);
}
.hovered {
position: relative;
&::after {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: var(--caption-color);
opacity: 0.15;
}
}
} }
</style> </style>