Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable resize of weekday event slot #222

Merged
merged 5 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion development/data/seeded-events.ts

Large diffs are not rendered by default.

58 changes: 24 additions & 34 deletions src/components/week/DayEvent.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<div
v-if="!isCustomEvent"
class="calendar-week__event is-event"
:class="{
'is-editable': isEditable,
Expand All @@ -9,8 +8,6 @@
:style="{
...requiredStyles,
border: getBorderRule,
color: eventColor,
backgroundColor: eventBackgroundColor,
}"
:data-ref="'event-' + event.id"
@click="handleClickOnEvent"
Expand All @@ -19,13 +16,16 @@
@mousedown="initDrag"
@touchstart="initDrag"
>
<div class="calendar-week__event-info-wrapper">
<div
v-if="showResizeElements"
class="calendar-week__event-resize calendar-week__event-resize-up"
@mousedown="resizeEvent('up')"
/>

<div
v-if="!isCustomEvent"
class="calendar-week__event-info-wrapper"
:style="{
color: eventColor,
width: '100%',
height: '100%',
backgroundColor: eventBackgroundColor,
}"
>
<div class="calendar-week__event-row is-title">
{{ event.title }}
</div>
Expand Down Expand Up @@ -94,35 +94,25 @@
')',
}"
/>

<div
v-if="showResizeElements"
class="calendar-week__event-resize calendar-week__event-resize-down"
@mousedown="resizeEvent('down')"
/>
</div>
</div>

<div
v-else
:style="{
...requiredStyles,
border: getBorderRule,
color: eventColor,
}"
class="calendar-week__event is-event"
:class="{
'is-editable': isEditable,
'has-disabled-dnd': hasDisabledDragAndDrop,
}"
@click="handleClickOnEvent"
@mousedown="initDrag"
@touchstart="initDrag"
>
<slot
v-else
name="weekDayEvent"
:event-data="event"
/>

<div
v-if="showResizeElements"
class="calendar-week__event-resize calendar-week__event-resize-up"
@mousedown="resizeEvent('up')"
/>

<div
v-if="showResizeElements"
class="calendar-week__event-resize calendar-week__event-resize-down"
@mousedown="resizeEvent('down')"
/>
</div>
</template>

Expand Down Expand Up @@ -651,6 +641,7 @@ export default defineComponent({
cursor: pointer;
box-sizing: content-box;
user-select: none;
overflow: hidden;

&.is-editable {
cursor: grab;
Expand All @@ -677,7 +668,6 @@ export default defineComponent({
font-size: var(--qalendar-font-xs);
height: 100%;
box-sizing: border-box;
overflow: hidden;
user-select: none;
}

Expand Down
22 changes: 13 additions & 9 deletions tests/unit/components/week/DayEvent.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {mount} from "@vue/test-utils";
import {mount, VueWrapper} from "@vue/test-utils";
import DayEvent from "../../../../src/components/week/DayEvent.vue";
import {describe, expect, test, it, vi } from "vitest";
import Time, {TimeBuilder, WEEK_START_DAY} from "../../../../src/helpers/Time";
Expand Down Expand Up @@ -38,6 +38,10 @@ function getEventElement(wrapper: any) {
return wrapper.find(EVENT_ELEMENT_SELECTOR);
}

function getInfoElement(wrapper: VueWrapper) {
return wrapper.find(".calendar-week__event-info-wrapper");
}

describe("DayEvent.vue", () => {
it("should display the title of av event", () => {
const event = new EventBuilder({ start: "2022-05-20 09:00", end: "2022-05-20 10:00" })
Expand Down Expand Up @@ -163,14 +167,14 @@ describe("DayEvent.vue", () => {
},
});

const eventElement = getEventElement(wrapper);
const infoElement = getInfoElement(wrapper);

wrapper.vm.setColors();
await nextTick();
expect(eventElement.attributes().style).toContain(
expect(infoElement.attributes().style).toContain(
"background-color: rgb(255, 64, 129)"
); // The pink BG
expect(eventElement.attributes().style).toContain(
expect(infoElement.attributes().style).toContain(
"color: rgb(255, 255, 255)"
); // The white text
});
Expand All @@ -191,14 +195,14 @@ describe("DayEvent.vue", () => {
},
});

const eventElement = getEventElement(wrapper)
const infoElement = getInfoElement(wrapper);

wrapper.vm.setColors();
await nextTick();
expect(eventElement.attributes().style).toContain(
expect(infoElement.attributes().style).toContain(
`background-color: ${EVENT_COLORS[expectedColor]}`
); // The green BG
expect(eventElement.attributes().style).toContain(
expect(infoElement.attributes().style).toContain(
"color: rgb(255, 255, 255)"
); // The white text
})
Expand All @@ -216,10 +220,10 @@ describe("DayEvent.vue", () => {
}
});

const eventElement = getEventElement(wrapper)
const infoElement = getInfoElement(wrapper);
wrapper.vm.setColors();
await nextTick();
expect(eventElement.attributes().style).toContain(
expect(infoElement.attributes().style).toContain(
`background-color: ${EVENT_COLORS.blue}`
)
})
Expand Down