Skip to content

feat(ui5-datepicker): implementing min and max date limits #1040

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

Merged
merged 62 commits into from
Jan 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
767525a
feat: implement create control script
tsanislavgatev Aug 26, 2019
2f2ba11
fix: create control script pr notes fix
tsanislavgatev Aug 26, 2019
f722bb6
add console error on empty string for a name of component
tsanislavgatev Aug 28, 2019
1357c13
solve conflict
tsanislavgatev Aug 28, 2019
849e594
master update
tsanislavgatev Aug 28, 2019
bd9bf48
removed hungarian notation
tsanislavgatev Aug 28, 2019
4b82ba5
removed old component creation snippet file
tsanislavgatev Aug 28, 2019
f77bfb6
feat(ui5-tabcontainer): acc update
tsanislavgatev Aug 30, 2019
8d26917
merge conflict solve
tsanislavgatev Aug 30, 2019
a9235f7
merge conflict tags solve
tsanislavgatev Aug 30, 2019
fdd2118
feat(ui5-tabcontainer): update ACC of header and content
tsanislavgatev Aug 30, 2019
af2422c
feat(ui5-tabcontainer): update ACC of header and content
tsanislavgatev Aug 30, 2019
23be11a
Merge branch 'master' of https://github.com/tsanislavgatev/ui5-webcom…
tsanislavgatev Aug 30, 2019
4850ce6
Merge branch 'master' of https://github.com/tsanislavgatev/ui5-webcom…
tsanislavgatev Aug 30, 2019
3c71085
Merge branch 'master' of https://github.com/tsanislavgatev/ui5-webcom…
tsanislavgatev Aug 30, 2019
067dbaa
feat:(ui5-datepicker): update ACC of the component and input included
tsanislavgatev Sep 3, 2019
9d4f2db
Merge remote-tracking branch 'upstream/master'
tsanislavgatev Sep 3, 2019
874d752
Updating with comments from PR
tsanislavgatev Sep 3, 2019
6d1dc16
Update with notes from PR
tsanislavgatev Sep 4, 2019
5ed53a2
Improve of get methods for acc in input
tsanislavgatev Sep 5, 2019
70b5104
update with comments from pr
tsanislavgatev Sep 5, 2019
d6598da
changing the place of input parent information
tsanislavgatev Sep 10, 2019
0c842f7
update escaping information repeating
tsanislavgatev Sep 10, 2019
9f686aa
merge commit
tsanislavgatev Oct 28, 2019
cf56bf0
merge commit
tsanislavgatev Oct 28, 2019
4e329fa
fix(ui5-daypicker): Separating datepicker click handling to mousedown…
tsanislavgatev Oct 28, 2019
49a4436
On press between date cells the pop up no longer closes
tsanislavgatev Oct 28, 2019
44ecfa7
Merge remote-tracking branch 'upstream/master'
tsanislavgatev Dec 5, 2019
a35e96b
feat(ui5-datepicker): implementing min and max date limits
tsanislavgatev Dec 6, 2019
71643ec
Keyboard handling implemented for Month and Year pickers + minor refa…
tsanislavgatev Dec 9, 2019
ef9de3b
Tests added
tsanislavgatev Dec 10, 2019
6d21aa2
Added styles of disabled cells
tsanislavgatev Dec 11, 2019
2b090cd
Lint fixes
tsanislavgatev Dec 11, 2019
dfd95a0
Swapped test page elements
tsanislavgatev Dec 12, 2019
127ca14
Added sample in playground
tsanislavgatev Dec 13, 2019
4967eeb
Merge remote-tracking branch 'upstream/master'
tsanislavgatev Jan 7, 2020
6f91086
update branch
tsanislavgatev Jan 7, 2020
96c4dd7
check if out of range in daypicker added
tsanislavgatev Jan 15, 2020
e35150d
Merge remote-tracking branch 'upstream/master'
tsanislavgatev Jan 15, 2020
4614239
Merge remote-tracking branch 'upstream/master'
tsanislavgatev Jan 23, 2020
4fe4ad7
Merge branch 'master' of https://github.com/tsanislavgatev/ui5-webcom…
tsanislavgatev Jan 23, 2020
54bc4c9
focus on today out of valid range
tsanislavgatev Jan 23, 2020
74b1bc2
feat(ui5-avatar): add initials, imageFitType and bg-color (#1151)
ivoplashkov Jan 23, 2020
9426ac1
refactor(ui5-popover): init private popovers in static area (#1129)
fifoosid Jan 23, 2020
3b2204a
feat(ui5-datepicker): implementing min and max date limits
tsanislavgatev Dec 6, 2019
e34dbaa
Keyboard handling implemented for Month and Year pickers + minor refa…
tsanislavgatev Dec 9, 2019
9cf284e
Lint fixes
tsanislavgatev Dec 11, 2019
9100d5b
check if out of range in daypicker added
tsanislavgatev Jan 15, 2020
bae1018
marge master and fix item navigation
ilhan007 Jan 26, 2020
88f9532
Merge branch 'master' into datepicker-min-max-date-implementation
ilhan007 Jan 26, 2020
910d20e
change the date handling for min and max date
tsanislavgatev Jan 27, 2020
3b2f4a9
Merge
tsanislavgatev Jan 27, 2020
37aec24
navigation fixes
tsanislavgatev Jan 27, 2020
4c73f9a
Added test and fixing date using methods
tsanislavgatev Jan 27, 2020
796f078
min and max checks for years and months fixed with calendar date
tsanislavgatev Jan 28, 2020
8be37a5
item navigation now working
tsanislavgatev Jan 28, 2020
a637ede
changed input value state update
tsanislavgatev Jan 29, 2020
a86ddf5
fixed perfomanse issue
tsanislavgatev Jan 30, 2020
c953dc8
Arrow buttons are now disabled when first or last page
tsanislavgatev Jan 30, 2020
1be5fe5
samples fix and lint fixes
tsanislavgatev Jan 30, 2020
bbbba2b
added since tags
tsanislavgatev Jan 31, 2020
7d91f12
fixed comments
tsanislavgatev Jan 31, 2020
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
2 changes: 1 addition & 1 deletion packages/base/src/dates/CalendarDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class CalendarDate {
function isValidDate(date) {
return date && Object.prototype.toString.call(date) === "[object Date]" && !isNaN(date); // eslint-disable-line
}
if (!isValidDate()) {
if (!isValidDate(oJSDate)) {
throw new Error(`Date parameter must be a JavaScript Date object: [${oJSDate}].`);
}
return new CalendarDate(oJSDate.getFullYear(), oJSDate.getMonth(), oJSDate.getDate(), sCalendarType);
Expand Down
92 changes: 66 additions & 26 deletions packages/base/src/delegate/ItemNavigation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import RenderScheduler from "../RenderScheduler.js";
import {
isDown,
isUp,
Expand Down Expand Up @@ -47,37 +48,19 @@ class ItemNavigation extends EventProvider {
return this.verticalNavigationOn;
}

_onKeyPress(event) {
const items = this._getItems();
if (this.currentIndex >= items.length) {
if (this.behavior !== ItemNavigationBehavior.Cyclic) {
if (this.behavior === ItemNavigationBehavior.Paging) {
this.currentIndex = this.currentIndex - items.length;
} else {
this.currentIndex = items.length - 1;
}
this.fireEvent(ItemNavigation.BORDER_REACH, { start: false, end: true, offset: this.currentIndex });
} else {
this.currentIndex = this.currentIndex - items.length;
}
async _onKeyPress(event) {
if (this.currentIndex >= this._getItems().length) {
this.onOverflowBottomEdge();
} else if (this.currentIndex < 0) {
if (this.behavior !== ItemNavigationBehavior.Cyclic) {
if (this.behavior === ItemNavigationBehavior.Paging) {
this.currentIndex = items.length + this.currentIndex - this.rowSize + (this.rowSize - (this._getItems().length % this.rowSize));
} else {
this.currentIndex = 0;
}
this.fireEvent(ItemNavigation.BORDER_REACH, { start: true, end: false, offset: this.currentIndex });
} else {
this.currentIndex = items.length + this.currentIndex;
}
this.onOverflowTopEdge();
}

event.preventDefault();

await RenderScheduler.whenFinished();
Copy link
Contributor

Choose a reason for hiding this comment

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

This was meant to be "unofficial" - for the tests only. I'm fine for the moment, but we need to provide a public function for the same.
@pskelin


this.update();
this.focusCurrent();

// stops browser scrolling with up/down keys
event.preventDefault();
}

onkeydown(event) {
Expand Down Expand Up @@ -227,8 +210,65 @@ class ItemNavigation extends EventProvider {
set current(val) {
this.currentIndex = val;
}

onOverflowBottomEdge() {
const items = this._getItems();
const rowIndex = this.currentIndex - items.length;
if (this.behavior === ItemNavigationBehavior.Cyclic) {
return;
}

if (this.behavior === ItemNavigationBehavior.Paging) {
this._handleNextPage();
}

this.fireEvent(ItemNavigation.BORDER_REACH, {
start: false, end: true, offset: this.currentIndex, rowIndex,
});
}

onOverflowTopEdge() {
const items = this._getItems();
const rowIndex = this.currentIndex + this.rowSize;

if (this.behavior === ItemNavigationBehavior.Cyclic) {
this.currentIndex = items.length + this.currentIndex;
return;
}

if (this.behavior === ItemNavigationBehavior.Paging) {
this._handlePrevPage();
}

this.fireEvent(ItemNavigation.BORDER_REACH, {
start: true, end: false, offset: this.currentIndex, rowIndex,
});
}

_handleNextPage() {
this.fireEvent(ItemNavigation.PAGE_BOTTOM);
const items = this._getItems();

if (!this.hasNextPage) {
this.currentIndex = items.length - 1;
} else {
this.currentIndex = 0;
}
}

_handlePrevPage() {
this.fireEvent(ItemNavigation.PAGE_TOP);

if (!this.hasPrevPage) {
this.currentIndex = 0;
} else {
this.currentIndex = 41;
}
}
}

ItemNavigation.PAGE_TOP = "PageTop";
ItemNavigation.PAGE_BOTTOM = "PageBottom";
ItemNavigation.BORDER_REACH = "_borderReach";

export default ItemNavigation;
10 changes: 10 additions & 0 deletions packages/main/src/Calendar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
@ui5-pressNext="{{_header.onPressNext}}"
@ui5-btn1Press="{{_header.onBtn1Press}}"
@ui5-btn2Press="{{_header.onBtn2Press}}"
._isNextButtonDisabled="{{_header._isNextButtonDisabled}}"
._isPrevButtonDisabled="{{_header._isPrevButtonDisabled}}"
></ui5-calendar-header>

<div id="{{_id}}-content">
Expand All @@ -19,6 +21,8 @@
.selectedDates="{{_oMonth.selectedDates}}"
._hidden="{{_oMonth._hidden}}"
.primaryCalendarType="{{_oMonth.primaryCalendarType}}"
.minDate="{{_oMonth.minDate}}"
.maxDate="{{_oMonth.maxDate}}"
timestamp="{{_oMonth.timestamp}}"
@ui5-selectionChange="{{_oMonth.onSelectedDatesChange}}"
@ui5-navigate="{{_oMonth.onNavigate}}"
Expand All @@ -27,17 +31,23 @@
<ui5-monthpicker
id="{{_id}}-MP"
class="{{classes.monthPicker}}"
format-pattern="{{_oMonth.formatPattern}}"
._hidden="{{_monthPicker._hidden}}"
.primaryCalendarType="{{_oMonth.primaryCalendarType}}"
.minDate="{{_oMonth.minDate}}"
.maxDate="{{_oMonth.maxDate}}"
timestamp="{{_monthPicker.timestamp}}"
@ui5-selectedMonthChange="{{_monthPicker.onSelectedMonthChange}}"
></ui5-monthpicker>

<ui5-yearpicker
id="{{_id}}-YP"
class="{{classes.yearPicker}}"
format-pattern="{{_oMonth.formatPattern}}"
._hidden="{{_yearPicker._hidden}}"
.primaryCalendarType="{{_oMonth.primaryCalendarType}}"
.minDate="{{_oMonth.minDate}}"
.maxDate="{{_oMonth.maxDate}}"
timestamp="{{_yearPicker.timestamp}}"
._selectedYear="{{_yearPicker._selectedYear}}"
@ui5-selectedYearChange="{{_yearPicker.onSelectedYearChange}}"
Expand Down
Loading