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

Scheduling conflicts #18

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Scheduling conflicts #18

wants to merge 6 commits into from

Conversation

bessyhuang
Copy link

No description provided.

@bessyhuang bessyhuang linked an issue May 6, 2024 that may be closed by this pull request
Copy link

@rileychh rileychh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

記得要用 ESLint 檢查過程式碼再提交,這樣其他開發者才不會在未來執行 ESLint 時不小心動到這裡喔!

功能沒有問題,但是按鈕的顏色對比(灰底白字)太低了,有些人可能會看不清楚。試試看調整背景顏色。

除了顏色對比,有沒有辦法為按鈕加上一些敘述來明定用意呢?一個辦法是利用 title 屬性

Comment on lines 3 to 6
<template v-if="!isFilterCollection">
<button :class="{fab: true, CalendarMultipleCheck: true, active: active}" @click="checkMySchedule">
<icon-mdi-calendar-multiple-check></icon-mdi-calendar-multiple-check>
</button>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<template v-if="!isFilterCollection">
<button :class="{fab: true, CalendarMultipleCheck: true, active: active}" @click="checkMySchedule">
<icon-mdi-calendar-multiple-check></icon-mdi-calendar-multiple-check>
</button>
<button class="fab CalendarMultipleCheck" :class="{ active }" @click="checkMySchedule">
<icon-mdi-calendar-multiple-check />
</button>
<template v-if="!isFilterCollection">
  • 沒有條件的 class 可以不用寫在 v-bind 裡面
  • icon 元件因為沒有內容,可以寫成 self-closing
  • 如果這個按鈕不受 v-if 的條件影響,直接放在 <article> 底下就可以了

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

319f36a 用 ESLint 跑過了,也為按鈕新增文字提示(title 屬性)、調整背景顏色。

src/components/Session/SessionFilter.vue Outdated Show resolved Hide resolved
src/components/Session/SessionFilter.vue Outdated Show resolved Hide resolved
@@ -105,6 +111,36 @@ export default defineComponent({
router.back()
}

const checkMySchedule = () => {
const events: any[] = [];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

考慮為 events 定義型別。從下面的 push,看起來他的型別是

interface SessionTimeSpan {
  startTime: Date;
  endTime: Date;
}

Comment on lines 122 to 133
for (let i = 0; i < events.length - 1; i++) {
for (let j = i + 1; j < events.length; j++) {
const eventA = events[i];
const eventB = events[j];
if (
(eventA["endTime"] > eventB["startTime"] && eventA["startTime"] < eventB["endTime"]) ||
(eventB["endTime"] > eventA["startTime"] && eventB["startTime"] < eventA["endTime"])
) {
isConflict = true;
}
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (let i = 0; i < events.length - 1; i++) {
for (let j = i + 1; j < events.length; j++) {
const eventA = events[i];
const eventB = events[j];
if (
(eventA["endTime"] > eventB["startTime"] && eventA["startTime"] < eventB["endTime"]) ||
(eventB["endTime"] > eventA["startTime"] && eventB["startTime"] < eventA["endTime"])
) {
isConflict = true;
}
}
}
comparisonLoop:
for (let i = 0; i < events.length - 1; i++) {
for (let j = i + 1; j < events.length; j++) {
const eventA = events[i];
const eventB = events[j];
if (
(eventA["endTime"] > eventB["startTime"] && eventA["startTime"] < eventB["endTime"]) ||
(eventB["endTime"] > eventA["startTime"] && eventB["startTime"] < eventA["endTime"])
) {
isConflict = true;
break comparisonLoop;
}
}
}

可以利用 labels 在發現衝突時提早離開迴圈,加快計算速度。
StackOverflow 上的說明

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原本想試試 Use label 的方法,但 ESLint 檢查會跑不過(error: Unexpected labeled statement & Unexpected label in break statement),因此就換其他方式了。

調整後結果,見 9debe0d

src/components/Session/SessionFilter.vue Outdated Show resolved Hide resolved
locales/en/session.json Outdated Show resolved Hide resolved
@bessyhuang bessyhuang requested a review from rileychh June 16, 2024 10:12
@bessyhuang bessyhuang self-assigned this Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

收藏議程時間衝突檢查
2 participants