beyond-rails 0.0.249 → 0.0.254
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 +4 -4
- data/src/js/components/MonthMenu.js +16 -2
- data/src/js/components/Monthpicker.js +3 -1
- data/src/js/components/TagInput.js +45 -4
- data/src/js/utils/index.js +2 -0
- data/src/sass/components/_month-menu.scss +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d0d6f0e05e67226b87ac93c97923647d70c9cc574608c8729d2c70bd1d09290
|
4
|
+
data.tar.gz: 83974fc639827973d26bcfa8495c5109e8986e3d9b6c44ff720a7ffe37336da6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b816d40ecbbf71d27698d749bce5c10438f03c27a6fb18a1178ded50b863bff5148c0a60aa032965bfb2b84f8e90a362724ab0c1d8fe169a25fad2b1939c53f1
|
7
|
+
data.tar.gz: ac85421f8c566066a552bb2c16ca134ec271aee0fa8911557c13745c28173870527d035b12538c957b0cc789d13ba6e893ad44e462789e818d7f35d6b44ebf4c
|
@@ -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
|
-
|
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
|
}
|
@@ -14,6 +14,7 @@ export default class TagInput {
|
|
14
14
|
this.change = options.change || noop
|
15
15
|
this.isComposing = false
|
16
16
|
this.raf = raf
|
17
|
+
this.id = 0
|
17
18
|
this.tags = []
|
18
19
|
this.init()
|
19
20
|
}
|
@@ -74,8 +75,33 @@ export default class TagInput {
|
|
74
75
|
}, 500)
|
75
76
|
}
|
76
77
|
|
77
|
-
|
78
|
-
const
|
78
|
+
setTagAttrs(id, rows = [], options = {}) {
|
79
|
+
const tag = this.tags.find(tag => tag.id === id)
|
80
|
+
if (! tag) {
|
81
|
+
return
|
82
|
+
}
|
83
|
+
const { elem } = tag
|
84
|
+
const { timeout } = options
|
85
|
+
const oldAttrs = rows.map(row => elem.getAttribute(row.name))
|
86
|
+
|
87
|
+
rows.forEach(row => {
|
88
|
+
elem.setAttribute(row.name, row.value)
|
89
|
+
})
|
90
|
+
|
91
|
+
if (timeout) {
|
92
|
+
setTimeout(() => {
|
93
|
+
if (document.body.contains(elem)) {
|
94
|
+
rows.forEach((row, i) => {
|
95
|
+
elem.setAttribute(row.name, oldAttrs[i])
|
96
|
+
})
|
97
|
+
}
|
98
|
+
}, timeout)
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
getTag(inputValue, options = {}) {
|
103
|
+
|
104
|
+
const classname = options.classname ? ` ${options.classname}` : ''
|
79
105
|
const tag = document.createElement('div')
|
80
106
|
|
81
107
|
tag.className = 'tag' + classname
|
@@ -94,9 +120,24 @@ export default class TagInput {
|
|
94
120
|
}
|
95
121
|
btn.addEventListener('click', handleBtnClick)
|
96
122
|
tag.appendChild(btn)
|
123
|
+
this.id += 1
|
124
|
+
|
125
|
+
return { id: this.id, elem: tag, remove: handleBtnClick, options }
|
126
|
+
}
|
127
|
+
|
128
|
+
setTags(rows) {
|
129
|
+
const { dom, inputDiv } = this
|
130
|
+
const tags = rows.map(row => this.getTag(row.text, row))
|
131
|
+
tags.forEach(tag => {
|
132
|
+
dom.insertBefore(tag.elem, inputDiv)
|
133
|
+
})
|
134
|
+
this.tags = tags
|
135
|
+
}
|
97
136
|
|
98
|
-
|
99
|
-
this.
|
137
|
+
addTag(inputValue, options = {}) {
|
138
|
+
const tag = this.getTag(inputValue, options)
|
139
|
+
this.tags.push(tag)
|
140
|
+
this.dom.insertBefore(tag.elem, this.inputDiv)
|
100
141
|
}
|
101
142
|
|
102
143
|
async addTagIfNeeded() {
|
data/src/js/utils/index.js
CHANGED
@@ -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
|
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.
|
4
|
+
version: 0.0.254
|
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-
|
12
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sassc
|