Schedule tooltip fix (#2193)

Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com>
This commit is contained in:
Denis Bykhov 2022-07-02 21:36:43 +06:00 committed by GitHub
parent 36f900e2a4
commit 808ea852a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 24 deletions

View File

@ -92,7 +92,6 @@
items={types.map((p) => { items={types.map((p) => {
return { id: p._id, label: p.label } return { id: p._id, label: p.label }
})} })}
placeholder={hr.string.RequestType}
label={hr.string.RequestType} label={hr.string.RequestType}
on:selected={(e) => typeSelected(e.detail)} on:selected={(e) => typeSelected(e.detail)}
/> />

View File

@ -157,8 +157,7 @@
: new Date(date).setDate(date.getDate() + 1) : new Date(date).setDate(date.getDate() + 1)
} }
function getTooltip (employee: Staff, date: Date): LabelAndProps | undefined { function getTooltip (requests: Request[], employee: Staff, date: Date): LabelAndProps | undefined {
const requests = getRequests(employee._id, date)
if (requests.length === 0) return if (requests.length === 0) return
const endDate = getEndDate(date) const endDate = getEndDate(date)
return { return {
@ -234,31 +233,37 @@
{#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)}
<td {@const tooltipValue = getTooltip(requests, employee, month)}
class:today={month.getFullYear() === todayDate.getFullYear() && {#key tooltipValue}
month.getMonth() === todayDate.getMonth()} <td
class="fixed" class:today={month.getFullYear() === todayDate.getFullYear() &&
use:tooltip={getTooltip(employee, month)} month.getMonth() === todayDate.getMonth()}
> class="fixed"
<div class="flex-center"> use:tooltip={tooltipValue}
{getTotal(requests)} >
</div> <div class="flex-center">
</td> {getTotal(requests)}
</div>
</td>
{/key}
{:else} {:else}
{@const date = getDay(new Date(startDate), value)} {@const date = getDay(new Date(startDate), value)}
{@const requests = getRequests(employee._id, date)} {@const requests = getRequests(employee._id, date)}
{@const editable = isEditable(employee)} {@const editable = isEditable(employee)}
<td {@const tooltipValue = getTooltip(requests, employee, date)}
class:today={areDatesEqual(todayDate, date)} {#key [tooltipValue, editable]}
class:weekend={isWeekend(date)} <td
class:cursor-pointer={editable} class:today={areDatesEqual(todayDate, date)}
use:tooltip={getTooltip(employee, date)} class:weekend={isWeekend(date)}
on:click={(e) => createRequest(e, date, employee)} class:cursor-pointer={editable}
> use:tooltip={tooltipValue}
{#if requests.length} on:click={(e) => createRequest(e, date, employee)}
<ScheduleRequests {requests} {date} {editable} /> >
{/if} {#if requests.length}
</td> <ScheduleRequests {requests} {date} {editable} />
{/if}
</td>
{/key}
{/if} {/if}
{/each} {/each}
</tr> </tr>