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

fix(comp:date-picker): disabledDate error on year and month panel #1514

Merged
merged 1 commit into from
Mar 27, 2023

Conversation

sallerli1
Copy link
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our guidelines
  • Tests for the changes have been added/updated or not needed
  • Docs and demo have been added/updated or not needed

What is the current behavior?

disabledDate 禁用一个月中的部分日期,整个月或者年都被禁用

What is the new behavior?

重构 disabledDate 算法,计算月、年、季度时,应当考虑中间所有日期的禁用情况

Other information

}
for (let num = 21; num <= 29; num++) {
expect(findCell(wrapper, `${num}`)?.classes()).not.toContain('ix-date-panel-cell-disabled')
}
})

test('month type disabledDate work', async () => {
Copy link

Choose a reason for hiding this comment

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

with a code review

The code looks good, the author has done a great job to make the code readable and understandable. However, one improvement suggestion would be to DRY up the code by using a loop in order to test that a range of dates are disabled/enabled. This could be done using a for loop for example, which would iterate over the range of dates and check each date to see if it is enabled or disabled. This would make the code more efficient and readable. Additionally, it would be wise to check the time complexity of the code to ensure that it is running as efficiently as possible.

Overall, the code looks like it is working properly and is easy to read.

@@ -93,7 +94,7 @@ export default defineComponent({
)
})
const isInRange = computed(() => {
const compareType = dayTypes.includes(activeType.value) ? 'date' : activeType.value
const compareType = getPanelCellType(activeType.value)
const cellDateValue = dateConfig.startOf(cellDate.value, compareType).valueOf()

return (
Copy link

Choose a reason for hiding this comment

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

with a brief code review:

  1. The code looks well formatted and organized, which is good.
  2. There are no obvious bugs in the code.
  3. The import statement for the getPanelCellDisabled and getPanelCellType functions should be moved to the top of the file so it is easier to find.
  4. The isDisabled computed property can be simplified by removing the check for !disabledDate and returning the result of getPanelCellDisabled right away.
  5. The isCurrent computed property should also use getPanelCellType instead of checking the dayTypes array.
  6. The compareType variable should also use getPanelCellType instead of checking the dayTypes array.
  7. The labelFormat object could be replaced with an array of objects with the type and format values, this would make it easier to read and maintain.

@idux-bot
Copy link

idux-bot bot commented Mar 27, 2023

This preview will be available after the AzureCI is passed.

}

return true
}
Copy link

Choose a reason for hiding this comment

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

with a brief code review:
First, the code should be properly indented and spaced for readability.
Second, the code should check for potential errors such as null values or out of bounds errors.
Third, the code should make use of descriptive variable names, commenting and logging to make it easier to understand.
Fourth, the code should be tested to make sure it is performing as expected.
Finally, the code should be optimized for performance. This can include refactoring the code to make it more efficient and using data structures (such as hash tables) to improve lookup time.

@codecov
Copy link

codecov bot commented Mar 27, 2023

Codecov Report

Merging #1514 (d95f16b) into main (703122f) will increase coverage by 0.03%.
The diff coverage is 100.00%.

❗ Current head d95f16b differs from pull request most recent head 23deeaf. Consider uploading reports for the commit 23deeaf to get more accurate results

@@            Coverage Diff             @@
##             main    #1514      +/-   ##
==========================================
+ Coverage   92.75%   92.78%   +0.03%     
==========================================
  Files         331      332       +1     
  Lines       30801    30879      +78     
  Branches     3533     3555      +22     
==========================================
+ Hits        28568    28651      +83     
+ Misses       2233     2228       -5     
Impacted Files Coverage Δ
...ckages/components/_private/date-panel/src/utils.ts 100.00% <100.00%> (ø)
...ages/components/_private/selector/src/Selector.tsx 91.15% <100.00%> (+0.06%) ⬆️
packages/components/_private/selector/src/token.ts 100.00% <100.00%> (ø)
packages/components/button/src/Button.tsx 95.37% <100.00%> (ø)
packages/components/timeline/src/TimelineItem.tsx 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@danranVm danranVm merged commit 06c546c into IDuxFE:main Mar 27, 2023
@sallerli1 sallerli1 deleted the fix-date-panel-disabled-date branch July 4, 2024 09:27
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