Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Andrey Shilov
Ngx Bootstrap
Commits
b17926bf
Commit
b17926bf
authored
6 years ago
by
Dmitriy Danilov
Committed by
Dmitriy Shekhovtsov
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
feat(datepicker): allow to select dates from other months (#4828)
closes #4485 closes #3746
parent
a5512770
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
demo/src/app/components/+datepicker/datepicker-section.list.ts
+9
-1
...src/app/components/+datepicker/datepicker-section.list.ts
demo/src/app/components/+datepicker/demos/index.ts
+2
-0
demo/src/app/components/+datepicker/demos/index.ts
demo/src/app/components/+datepicker/demos/select-dates-from-other-months/select-dates-from-other-months.html
+9
-0
...tes-from-other-months/select-dates-from-other-months.html
demo/src/app/components/+datepicker/demos/select-dates-from-other-months/select-dates-from-other-months.ts
+7
-0
...dates-from-other-months/select-dates-from-other-months.ts
demo/src/ng-api-doc.ts
+6
-0
demo/src/ng-api-doc.ts
src/chronos/i18n/pl.ts
+7
-0
src/chronos/i18n/pl.ts
src/chronos/test/locale/pl.spec.ts
+7
-0
src/chronos/test/locale/pl.spec.ts
src/datepicker/base/bs-datepicker-container.ts
+1
-0
src/datepicker/base/bs-datepicker-container.ts
src/datepicker/bs-datepicker.config.ts
+5
-0
src/datepicker/bs-datepicker.config.ts
src/datepicker/bs-datepicker.scss
+8
-0
src/datepicker/bs-datepicker.scss
src/datepicker/models/index.ts
+1
-0
src/datepicker/models/index.ts
src/datepicker/reducer/bs-datepicker.state.ts
+1
-0
src/datepicker/reducer/bs-datepicker.state.ts
src/datepicker/themes/bs/bs-datepicker-container.component.ts
+5
-1
...datepicker/themes/bs/bs-datepicker-container.component.ts
src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts
+1
-0
...picker/themes/bs/bs-datepicker-day-decorator.directive.ts
src/datepicker/themes/bs/bs-daterangepicker-container.component.ts
+4
-1
...icker/themes/bs/bs-daterangepicker-container.component.ts
src/datepicker/themes/bs/bs-days-calendar-view.component.ts
+7
-0
src/datepicker/themes/bs/bs-days-calendar-view.component.ts
with
80 additions
and
3 deletions
+80
-3
demo/src/app/components/+datepicker/datepicker-section.list.ts
View file @
b17926bf
...
...
@@ -19,7 +19,7 @@ import { DemoDatePickerVisibilityEventsComponent } from './demos/visibility-even
import
{
DemoDatepickerValueChangeEventComponent
}
from
'
./demos/value-change-event/value-change-event
'
;
import
{
DemoDatepickerTriggersCustomComponent
}
from
'
./demos/triggers-custom/triggers-custom
'
;
import
{
DemoDatepickerHideOnScrollComponent
}
from
'
./demos/hide-on-scroll/hide-on-scroll
'
;
import
{
DemoDatePickerSelectDatesFromOtherMonthsComponent
}
from
'
./demos/select-dates-from-other-months/select-dates-from-other-months
'
;
import
{
ContentSection
}
from
'
../../docs/models/content-section.model
'
;
import
{
DemoTopSectionComponent
}
from
'
../../docs/demo-section-components/demo-top-section/index
'
;
import
{
ExamplesComponent
}
from
'
../../docs/demo-section-components/demo-examples-section/index
'
;
...
...
@@ -232,6 +232,14 @@ export const demoComponentContent: ContentSection[] = [
description
:
`<p>You can configure the datepicker via its <code>bsConfig</code> option</p>`
,
outlet
:
DemoDatePickerConfigObjectComponent
},
{
title
:
'
Select dates from other month
'
,
anchor
:
'
select-dates-from-other-month
'
,
component
:
require
(
'
!!raw-loader?lang=typescript!./demos/select-dates-from-other-months/select-dates-from-other-months.ts
'
),
html
:
require
(
'
!!raw-loader?lang=markup!./demos/select-dates-from-other-months/select-dates-from-other-months.html
'
),
description
:
`<p>You can enable dates from other months via <code>selectFromOtherMonth</code> option in <code>bsConfig</code></p>`
,
outlet
:
DemoDatePickerSelectDatesFromOtherMonthsComponent
},
{
title
:
'
Outside click
'
,
anchor
:
'
outside-click
'
,
...
...
This diff is collapsed.
Click to expand it.
demo/src/app/components/+datepicker/demos/index.ts
View file @
b17926bf
...
...
@@ -15,6 +15,7 @@ import { DemoDatepickerConfigMethodComponent } from './config-method/config-meth
import
{
DemoDatePickerVisibilityEventsComponent
}
from
'
./visibility-events/visibility-events
'
;
import
{
DemoDatepickerValueChangeEventComponent
}
from
'
./value-change-event/value-change-event
'
;
import
{
DemoDatePickerConfigObjectComponent
}
from
'
./config-object/config-object
'
;
import
{
DemoDatePickerSelectDatesFromOtherMonthsComponent
}
from
'
./select-dates-from-other-months/select-dates-from-other-months
'
;
import
{
DemoDatepickerOutsideClickComponent
}
from
'
./outside-click/outside-click
'
;
import
{
DemoDatepickerByIsOpenPropComponent
}
from
'
./trigger-by-isopen-property/trigger-by-isopen-property
'
;
import
{
DemoDatepickerDateInitialStateComponent
}
from
'
./date-initial-state/date-initial-state
'
;
...
...
@@ -40,6 +41,7 @@ export const DEMO_COMPONENTS = [
DemoDatepickerPlacementComponent
,
DemoDatepickerValueChangeEventComponent
,
DemoDatePickerConfigObjectComponent
,
DemoDatePickerSelectDatesFromOtherMonthsComponent
,
DemoDatepickerOutsideClickComponent
,
DemoDatepickerByIsOpenPropComponent
,
DemoDatepickerDateInitialStateComponent
,
...
...
This diff is collapsed.
Click to expand it.
demo/src/app/components/+datepicker/demos/select-dates-from-other-months/select-dates-from-other-months.html
0 → 100644
View file @
b17926bf
<div
class=
"row"
>
<div
class=
"col-xs-12 col-12 col-md-4 form-group"
>
<input
class=
"form-control"
placeholder=
"Datepicker"
bsDatepicker
[bsConfig]=
"{ dateInputFormat: 'DD-MM-YYYY', selectFromOtherMonth: true}"
>
</div>
</div>
This diff is collapsed.
Click to expand it.
demo/src/app/components/+datepicker/demos/select-dates-from-other-months/select-dates-from-other-months.ts
0 → 100644
View file @
b17926bf
import
{
Component
}
from
'
@angular/core
'
;
@
Component
({
selector
:
'
demo-datepicker-select-dates-from-other-months
'
,
templateUrl
:
'
./select-dates-from-other-months.html
'
})
export
class
DemoDatePickerSelectDatesFromOtherMonthsComponent
{}
This diff is collapsed.
Click to expand it.
demo/src/ng-api-doc.ts
View file @
b17926bf
...
...
@@ -816,6 +816,12 @@ export const ngdoc: any = {
"
defaultValue
"
:
"
true
"
,
"
type
"
:
"
boolean
"
,
"
description
"
:
"
<p>Allows to hide week numbers in datepicker</p>
\n
"
},
{
"
name
"
:
"
selectFromOtherMonth
"
,
"
defaultValue
"
:
"
false
"
,
"
type
"
:
"
boolean
"
,
"
description
"
:
"
<p>Allows to use dates from previous/future month as active</p>
\n
"
}
]
},
...
...
This diff is collapsed.
Click to expand it.
src/chronos/i18n/pl.ts
View file @
b17926bf
...
...
@@ -80,6 +80,9 @@ export const plLocale: LocaleData = {
case
3
:
return
'
[W środę o] LT
'
;
case
5
:
return
'
[W piątek o] LT
'
;
case
6
:
return
'
[W sobotę o] LT
'
;
...
...
@@ -94,6 +97,10 @@ export const plLocale: LocaleData = {
return
'
[W zeszłą niedzielę o] LT
'
;
case
3
:
return
'
[W zeszłą środę o] LT
'
;
case
4
:
return
'
[W zeszłą czwartek o] LT
'
;
case
5
:
return
'
[W zeszłą piątek o] LT
'
;
case
6
:
return
'
[W zeszłą sobotę o] LT
'
;
default
:
...
...
This diff is collapsed.
Click to expand it.
src/chronos/test/locale/pl.spec.ts
View file @
b17926bf
...
...
@@ -228,6 +228,9 @@ describe('locale: pl', () => {
case
3
:
return
'
[W środę o] LT
'
;
case
5
:
return
'
[W piątek o] LT
'
;
case
6
:
return
'
[W sobotę o] LT
'
;
...
...
@@ -257,6 +260,10 @@ describe('locale: pl', () => {
return
'
[W zeszłą niedzielę o] LT
'
;
case
3
:
return
'
[W zeszłą środę o] LT
'
;
case
4
:
return
'
[W zeszłą czwartek o] LT
'
;
case
5
:
return
'
[W zeszłą piątek o] LT
'
;
case
6
:
return
'
[W zeszłą sobotę o] LT
'
;
default
:
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/base/bs-datepicker-container.ts
View file @
b17926bf
...
...
@@ -17,6 +17,7 @@ import {
export
abstract
class
BsDatepickerAbstractComponent
{
containerClass
:
string
;
isOtherMonthsActive
:
boolean
;
_effects
:
BsDatepickerEffects
;
_customRangesFish
:
BsCustomDates
[]
=
[];
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/bs-datepicker.config.ts
View file @
b17926bf
...
...
@@ -22,6 +22,11 @@ export class BsDatepickerConfig implements DatepickerRenderOptions {
*/
maxDate
?:
Date
;
/**
* Makes dates from other months active
*/
selectFromOtherMonth
?:
boolean
;
/**
* Defaut mode for all date pickers
*/
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/bs-datepicker.scss
View file @
b17926bf
...
...
@@ -163,6 +163,13 @@
transition
:
0s
;
}
&
.is-active-other-month
:not
(
.disabled
)
:not
(
.selected
)
span
,
span
.is-active-other-month
:not
(
.disabled
)
:not
(
.selected
)
{
background-color
:
$highlighted
;
transition
:
0s
;
cursor
:
pointer
!
important
;
}
span
.disabled
,
&
.disabled
span
{
color
:
$font-color-02
;
...
...
@@ -432,6 +439,7 @@
/* .is-other-month */
.is-other-month
{
color
:
rgba
(
0
,
0
,
0
,
0
.25
);
cursor
:
default
!
important
;
}
/* .bs-datepicker-buttons */
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/models/index.ts
View file @
b17926bf
...
...
@@ -23,6 +23,7 @@ export interface CalendarCellViewModel {
/** *************** */
// days matrix: day cell view model
export
interface
DayViewModel
extends
CalendarCellViewModel
{
isOtherMonthHovered
?:
boolean
;
isOtherMonth
?:
boolean
;
isInRange
?:
boolean
;
isSelectionStart
?:
boolean
;
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/reducer/bs-datepicker.state.ts
View file @
b17926bf
...
...
@@ -55,6 +55,7 @@ export class BsDatepickerState
// DatepickerRenderOptions
showWeekNumbers
?:
boolean
;
displayMonths
?:
number
;
selectFromOtherMonth
?:
boolean
;
// DatepickerFormatOptions
locale
:
string
;
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/themes/bs/bs-datepicker-container.component.ts
View file @
b17926bf
...
...
@@ -38,6 +38,7 @@ export class BsDatepickerContainerComponent extends BsDatepickerAbstractComponen
}
ngOnInit
():
void
{
this
.
isOtherMonthsActive
=
this
.
_config
.
selectFromOtherMonth
;
this
.
containerClass
=
this
.
_config
.
containerClass
;
this
.
_effects
.
init
(
this
.
_store
)
...
...
@@ -61,9 +62,12 @@ export class BsDatepickerContainerComponent extends BsDatepickerAbstractComponen
}
daySelectHandler
(
day
:
DayViewModel
):
void
{
if
(
day
.
isOtherMonth
||
day
.
isDisabled
)
{
const
isDisabled
=
this
.
isOtherMonthsActive
?
day
.
isDisabled
:
(
day
.
isOtherMonth
||
day
.
isDisabled
);
if
(
isDisabled
)
{
return
;
}
this
.
_store
.
dispatch
(
this
.
_actions
.
select
(
day
.
date
));
}
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/themes/bs/bs-datepicker-day-decorator.directive.ts
View file @
b17926bf
...
...
@@ -8,6 +8,7 @@ import { DayViewModel } from '../../models';
'
[class.disabled]
'
:
'
day.isDisabled
'
,
'
[class.is-highlighted]
'
:
'
day.isHovered
'
,
'
[class.is-other-month]
'
:
'
day.isOtherMonth
'
,
'
[class.is-active-other-month]
'
:
'
day.isOtherMonthHovered
'
,
'
[class.in-range]
'
:
'
day.isInRange
'
,
'
[class.select-start]
'
:
'
day.isSelectionStart
'
,
'
[class.select-end]
'
:
'
day.isSelectionEnd
'
,
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/themes/bs/bs-daterangepicker-container.component.ts
View file @
b17926bf
...
...
@@ -40,6 +40,7 @@ export class BsDaterangepickerContainerComponent extends BsDatepickerAbstractCom
ngOnInit
():
void
{
this
.
containerClass
=
this
.
_config
.
containerClass
;
this
.
isOtherMonthsActive
=
this
.
_config
.
selectFromOtherMonth
;
this
.
_effects
.
init
(
this
.
_store
)
// intial state options
...
...
@@ -61,7 +62,9 @@ export class BsDaterangepickerContainerComponent extends BsDatepickerAbstractCom
}
daySelectHandler
(
day
:
DayViewModel
):
void
{
if
(
day
.
isOtherMonth
||
day
.
isDisabled
)
{
const
isDisabled
=
this
.
isOtherMonthsActive
?
day
.
isDisabled
:
(
day
.
isOtherMonth
||
day
.
isDisabled
);
if
(
isDisabled
)
{
return
;
}
...
...
This diff is collapsed.
Click to expand it.
src/datepicker/themes/bs/bs-days-calendar-view.component.ts
View file @
b17926bf
...
...
@@ -13,6 +13,7 @@ import {
DaysCalendarViewModel
,
DayViewModel
}
from
'
../../models
'
;
import
{
BsDatepickerConfig
}
from
'
../../bs-datepicker.config
'
;
@
Component
({
selector
:
'
bs-days-calendar-view
'
,
...
...
@@ -65,6 +66,8 @@ export class BsDaysCalendarViewComponent {
@
Output
()
onSelect
=
new
EventEmitter
<
DayViewModel
>
();
@
Output
()
onHover
=
new
EventEmitter
<
CellHoverEvent
>
();
constructor
(
private
_config
:
BsDatepickerConfig
)
{
}
navigateTo
(
event
:
BsNavigationDirection
):
void
{
const
step
=
BsNavigationDirection
.
DOWN
===
event
?
-
1
:
1
;
this
.
onNavigate
.
emit
({
step
:
{
month
:
step
}
});
...
...
@@ -79,6 +82,10 @@ export class BsDaysCalendarViewComponent {
}
hoverDay
(
cell
:
DayViewModel
,
isHovered
:
boolean
):
void
{
if
(
this
.
_config
.
selectFromOtherMonth
&&
cell
.
isOtherMonth
)
{
cell
.
isOtherMonthHovered
=
isHovered
;
}
this
.
onHover
.
emit
({
cell
,
isHovered
});
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help