beyond-rails 0.0.249 → 0.0.250

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4de5e8066708052ae0127154f45e41b6c1f8f74eb59f0c039048ec2270ab941a
4
- data.tar.gz: e9d03bcb15b1d4a2db1ea8dcc98a9be59c17baf3f2dff8f2319b99e7a773f99d
3
+ metadata.gz: 322787a4c8946f84a187c1d8a6f61ae484e197a5295c872f63aa5cbc7ed43f91
4
+ data.tar.gz: 64d4fd67dd0c18f3441e3bc09d5d57c4ccb518e2368c5318a7654a025c97a7e9
5
5
  SHA512:
6
- metadata.gz: f7fcbc4fcdb20f8b688af68d5954682fdce85f11dba8e16bdbb32239bcdd616dc3f46c8eb0f5528af76ac54cce57371d6c8ddd440bc7100a24a5bcb6c697daaa
7
- data.tar.gz: 95149742916a14ce5ab3a0d02f70ce0e3e0d8ec18b87cf284f39d469f01ec7a7779005d90d11262bcb5f32c600d33fde5a363d9c823d182f1cbfc653cd986ec8
6
+ metadata.gz: 787409b5d76b822cc1cb20494c71892c48a4277edc0de48f70ccaba4180ccb473f4c88d09cb988015cf3355c9a0e3f48e48f09a439edeb76f5266c104e6f7e11
7
+ data.tar.gz: db95d7c2437ddebab2e7da69ce48c88fc612b4fc72784ec83cc800ed138339fff8db27a54cc7b8743d2c3175066748b6c069b41832d063dd30bb0feec98a1b3d
@@ -6,6 +6,7 @@ import {
6
6
  chunk,
7
7
  format,
8
8
  range,
9
+ isFuture,
9
10
  setYear,
10
11
  setMonth,
11
12
  getYear,
@@ -27,6 +28,7 @@ export default class MonthMenu {
27
28
  this.options = options
28
29
  this.tz = options.tz || DEFAULT_TIMEZONE
29
30
  this.locale = options.locale || DEFAULT_LOCALE
31
+ this.noFuture = options.noFuture || true
30
32
  this.change = options.change || noop
31
33
  this.isVisible = false
32
34
  this.loopIndex = 0
@@ -39,7 +41,7 @@ export default class MonthMenu {
39
41
  }
40
42
 
41
43
  renderTableContent() {
42
- const { date, menuDate, locale } = this
44
+ const { date, menuDate, locale, noFuture } = this
43
45
 
44
46
  const currentYear = date ? getYear(date) : null
45
47
  const currentMonth = date ? getMonth(date) : null
@@ -52,7 +54,15 @@ export default class MonthMenu {
52
54
 
53
55
  const isCurrentMonth = (currentYear === getYear(d)) && (currentMonth === getMonth(d))
54
56
 
55
- const classname = isCurrentMonth ? 'cell selected-ex' : 'cell'
57
+ let classname = 'cell'
58
+
59
+ if (isCurrentMonth) {
60
+ classname = 'cell selected-ex'
61
+ }
62
+ else if (noFuture && isFuture(d)) {
63
+ classname = 'cell js-disabled'
64
+ }
65
+
56
66
  return `<td class="${classname}" data-month-td="${month}">${text}</td>`
57
67
  }).join('')
58
68
  return `<tr>${tds}</tr>`
@@ -201,6 +211,10 @@ export default class MonthMenu {
201
211
  const year = getYear(this.menuDate)
202
212
  const month = parseInt(target.dataset.monthTd, 10)
203
213
 
214
+ if (target.classList.contains('js-disabled')) {
215
+ return
216
+ }
217
+
204
218
  if (! this.date) {
205
219
  this.date = new Date(this.menuDate.getTime())
206
220
  }
@@ -15,6 +15,7 @@ export default class Monthpicker {
15
15
 
16
16
  this.options = options
17
17
  this.backdropMode = options.backdropMode || 'auto'
18
+ this.noFuture = options.noFuture || true
18
19
  this.change = options.change || noop
19
20
  this.init()
20
21
  }
@@ -32,7 +33,8 @@ export default class Monthpicker {
32
33
  this.monthInput.setDate(date)
33
34
  this.monthInput.clearStatus()
34
35
  this.monthMenu.hide()
35
- }
36
+ },
37
+ noFuture: this.noFuture
36
38
  })
37
39
  this.addEvents()
38
40
  }
@@ -29,6 +29,7 @@ import startOfDay from 'date-fns/startOfDay'
29
29
  import startOfMonth from 'date-fns/startOfMonth'
30
30
  import subMonths from 'date-fns/subMonths'
31
31
  import toDate from 'date-fns/toDate'
32
+ import isFuture from 'date-fns/isFuture'
32
33
  import { format } from 'date-fns-tz'
33
34
 
34
35
  // lodash
@@ -75,6 +76,7 @@ export {
75
76
  startOfMonth,
76
77
  subMonths,
77
78
  toDate,
79
+ isFuture,
78
80
  format,
79
81
 
80
82
  // lodash
@@ -60,6 +60,10 @@
60
60
  color: #fff;
61
61
  border-color: #6c8eef;
62
62
  }
63
+ &.cell.js-disabled {
64
+ opacity: .4;
65
+ cursor: not-allowed;
66
+ }
63
67
  &.cell.selected-ex {
64
68
  background-color: #5469d4;
65
69
  color: #fff;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.249
4
+ version: 0.0.250
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmsheng
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-17 00:00:00.000000000 Z
12
+ date: 2020-11-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc