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)}
{@const tooltipValue = getTooltip(requests, employee, month)}
{#key tooltipValue}
<td <td
class:today={month.getFullYear() === todayDate.getFullYear() && class:today={month.getFullYear() === todayDate.getFullYear() &&
month.getMonth() === todayDate.getMonth()} month.getMonth() === todayDate.getMonth()}
class="fixed" class="fixed"
use:tooltip={getTooltip(employee, month)} use:tooltip={tooltipValue}
> >
<div class="flex-center"> <div class="flex-center">
{getTotal(requests)} {getTotal(requests)}
</div> </div>
</td> </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)}
{@const tooltipValue = getTooltip(requests, employee, date)}
{#key [tooltipValue, editable]}
<td <td
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}
use:tooltip={getTooltip(employee, date)} use:tooltip={tooltipValue}
on:click={(e) => createRequest(e, date, employee)} on:click={(e) => createRequest(e, date, employee)}
> >
{#if requests.length} {#if requests.length}
<ScheduleRequests {requests} {date} {editable} /> <ScheduleRequests {requests} {date} {editable} />
{/if} {/if}
</td> </td>
{/key}
{/if} {/if}
{/each} {/each}
</tr> </tr>