beyond-rails 0.0.261 → 0.0.266

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b12342b2961fe3455aa91cb6da5b19c7f6d68dd2c5f9559e7ba6f1be32710711
4
- data.tar.gz: '085f490c627a182572e411666a67f4a29e9bb0ff3fb869b42095cb7348bd4f9f'
3
+ metadata.gz: 805f3abdc89e3ba6a80306075b91a7a3a0f75760a97755d07ca5a40ecce2326d
4
+ data.tar.gz: 9b0c72b2864035924f833226877d10c38f18e0e43d01de5f55115ebcf7f1f3fb
5
5
  SHA512:
6
- metadata.gz: c069481c3a41f361b5cf291782ea0321098a2ea63218a05359ea085ebf7d501dd6c127231d0531ce5535f3ab9dc160bc3511318de4e788b6ae885f4f4fc91782
7
- data.tar.gz: 19b8018a6b008501250fc50132c9a5f4b83feb83d1f633e9bf75e3be5946f76cc59f94e3f08f37c79894a23116fe1912493bd715a5188eac1549f0e002ffb002
6
+ metadata.gz: 7219f2a16076bed1de20e2a149a92f92e595ec8a25427d36eab1fbb78ae5cf9036195017524d8a3c73e93a87bf4a876e876c9cbe933bc9283708fa2a23825a39
7
+ data.tar.gz: b7aa777f115fbd0c822e5fe8cf0994ff09d7a4af90b4e7bbed0adaf43bd93b3cb192ed033159b09b1b7b03ffe6d86d283b0373150c07198b97aa7065fb29d08b
@@ -58,6 +58,7 @@ export default class Modal {
58
58
  show(html) {
59
59
 
60
60
  if (this.isVisible && html) {
61
+ this.modal.style.display = 'block'
61
62
  this.replace(html)
62
63
  return this.triggerShowEventIfNeeded()
63
64
  }
@@ -107,6 +107,7 @@ export default class SearchDropdown {
107
107
  menu.dataset.place = this.place
108
108
  menu.dataset.align = this.align
109
109
  this.isMenuVisible = false
110
+ this.lastKeyword = null
110
111
  }
111
112
 
112
113
  showMenu() {
@@ -68,11 +68,11 @@ export default class TagInput {
68
68
  return nextWidth
69
69
  }
70
70
 
71
- shake() {
71
+ shake(duration = 500) {
72
72
  this.dom.classList.add('shake')
73
73
  setTimeout(() => {
74
74
  this.dom.classList.remove('shake')
75
- }, 500)
75
+ }, duration)
76
76
  }
77
77
 
78
78
  setTagAttrs(id, rows = [], options = {}) {
@@ -107,47 +107,63 @@ export default class TagInput {
107
107
  }
108
108
  }
109
109
 
110
- getTag(inputValue, options = {}) {
110
+ getTag(row) {
111
111
 
112
- const classname = options.classname ? ` ${options.classname}` : ''
112
+ this.id += 1
113
+
114
+ const id = this.id
115
+ const classname = row.classname ? ` ${row.classname}` : ''
113
116
  const tag = document.createElement('div')
114
117
 
115
118
  tag.className = 'tag' + classname
116
- tag.textContent = inputValue
119
+ tag.textContent = row.text
117
120
 
118
121
  const btn = document.createElement('button')
119
122
  btn.type = 'button'
120
123
 
121
124
  // https://wesbos.com/times-html-entity-close-button
122
125
  btn.textContent = '×'
123
- const handleBtnClick = () => {
126
+ const handleBtnClick = event => {
124
127
  this.tags = this.tags.filter(row => row.elem !== tag)
125
128
  btn.removeEventListener('click', handleBtnClick)
126
129
  tag.remove()
127
- this.change(this.tags.slice())
130
+
131
+ if (event) {
132
+ this.change({
133
+ type: 'remove',
134
+ removedId: id,
135
+ tags: this.tags.slice()
136
+ })
137
+ }
128
138
  }
129
139
  btn.addEventListener('click', handleBtnClick)
130
140
  tag.appendChild(btn)
131
- this.id += 1
132
141
 
133
- return { id: this.id, elem: tag, remove: handleBtnClick, options }
142
+ return { id, elem: tag, remove: handleBtnClick, ...row }
134
143
  }
135
144
 
136
145
  setTags(rows) {
146
+ this.tags.forEach(tag => tag.remove())
137
147
  const { dom, inputDiv } = this
138
- const tags = rows.map(row => this.getTag(row.text, row))
148
+ const tags = rows.map(row => this.getTag(row))
139
149
  tags.forEach(tag => {
140
150
  dom.insertBefore(tag.elem, inputDiv)
141
151
  })
142
152
  this.tags = tags
143
- this.change(this.tags.slice())
153
+ this.change({
154
+ type: 'set',
155
+ tags: this.tags.slice()
156
+ })
144
157
  }
145
158
 
146
- addTag(inputValue, options = {}) {
147
- const tag = this.getTag(inputValue, options)
159
+ addTag(row, type = 'add') {
160
+ const tag = this.getTag(row)
148
161
  this.tags.push(tag)
149
162
  this.dom.insertBefore(tag.elem, this.inputDiv)
150
- this.change(this.tags.slice())
163
+ this.change({
164
+ type,
165
+ tags: this.tags.slice()
166
+ })
151
167
  }
152
168
 
153
169
  async addTagIfNeeded() {
@@ -159,7 +175,9 @@ export default class TagInput {
159
175
  }
160
176
  input.value = ''
161
177
  suggestInput.value = ''
162
- this.addTag(inputValue, res)
178
+
179
+ const row = Object.assign({}, res, { text: inputValue })
180
+ this.addTag(row, 'input')
163
181
  }
164
182
 
165
183
  removeTagIfNeeded() {
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.261
4
+ version: 0.0.266
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-30 00:00:00.000000000 Z
12
+ date: 2020-12-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc