beyond-rails 0.0.252 → 0.0.257
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/js/components/LineChart.js +1 -0
- data/src/js/components/TagInput.js +32 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 878355b9e7a2f59f8ab506c681088d7eae160f0f73440a4352a64da64e44f484
|
4
|
+
data.tar.gz: effed2b5389dc1e2859f99f86dc900ced79aa347cc0db2c9e126d0313dba5a6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea0dc3ec729df8ac0bca7d89828dd89fd932da5d809376503eb59f115c8113f89d165e22aa38c71bbcbf97c36bcbb3f088a38c3fee1d77eea9090ae68964875f
|
7
|
+
data.tar.gz: f48ff5af5ca71be4b4a2409581514142bcaadb0fb8135f54c8080f9f0cd66041dcace5e33ce181980369d29be35570279b53e59e0dbf171c5e1cde3b5cb40501
|
@@ -82,15 +82,23 @@ export default class TagInput {
|
|
82
82
|
}
|
83
83
|
const { elem } = tag
|
84
84
|
const { timeout } = options
|
85
|
-
|
85
|
+
|
86
|
+
if (this.timer) {
|
87
|
+
clearTimeout(this.timer)
|
88
|
+
this.timer = null
|
89
|
+
}
|
90
|
+
else {
|
91
|
+
this.oldAttrs = rows.map(row => elem.getAttribute(row.name))
|
92
|
+
}
|
86
93
|
|
87
94
|
rows.forEach(row => {
|
88
95
|
elem.setAttribute(row.name, row.value)
|
89
96
|
})
|
90
97
|
|
91
98
|
if (timeout) {
|
92
|
-
setTimeout(() => {
|
99
|
+
this.timer = setTimeout(() => {
|
93
100
|
if (document.body.contains(elem)) {
|
101
|
+
const { oldAttrs } = this
|
94
102
|
rows.forEach((row, i) => {
|
95
103
|
elem.setAttribute(row.name, oldAttrs[i])
|
96
104
|
})
|
@@ -99,8 +107,9 @@ export default class TagInput {
|
|
99
107
|
}
|
100
108
|
}
|
101
109
|
|
102
|
-
|
103
|
-
|
110
|
+
getTag(inputValue, options = {}) {
|
111
|
+
|
112
|
+
const classname = options.classname ? ` ${options.classname}` : ''
|
104
113
|
const tag = document.createElement('div')
|
105
114
|
|
106
115
|
tag.className = 'tag' + classname
|
@@ -119,10 +128,25 @@ export default class TagInput {
|
|
119
128
|
}
|
120
129
|
btn.addEventListener('click', handleBtnClick)
|
121
130
|
tag.appendChild(btn)
|
122
|
-
|
123
131
|
this.id += 1
|
124
|
-
|
125
|
-
this.
|
132
|
+
|
133
|
+
return { id: this.id, elem: tag, remove: handleBtnClick, options }
|
134
|
+
}
|
135
|
+
|
136
|
+
setTags(rows) {
|
137
|
+
const { dom, inputDiv } = this
|
138
|
+
const tags = rows.map(row => this.getTag(row.text, row))
|
139
|
+
tags.forEach(tag => {
|
140
|
+
dom.insertBefore(tag.elem, inputDiv)
|
141
|
+
})
|
142
|
+
this.tags = tags
|
143
|
+
}
|
144
|
+
|
145
|
+
addTag(inputValue, options = {}) {
|
146
|
+
const tag = this.getTag(inputValue, options)
|
147
|
+
this.tags.push(tag)
|
148
|
+
this.dom.insertBefore(tag.elem, this.inputDiv)
|
149
|
+
this.change(this.tags.slice())
|
126
150
|
}
|
127
151
|
|
128
152
|
async addTagIfNeeded() {
|
@@ -132,12 +156,9 @@ export default class TagInput {
|
|
132
156
|
if (! res.isTag) {
|
133
157
|
return this.shake()
|
134
158
|
}
|
135
|
-
this.addTag(inputValue, res)
|
136
|
-
|
137
159
|
input.value = ''
|
138
160
|
suggestInput.value = ''
|
139
|
-
|
140
|
-
this.change(this.tags.slice())
|
161
|
+
this.addTag(inputValue, res)
|
141
162
|
}
|
142
163
|
|
143
164
|
removeTagIfNeeded() {
|