bull-autocomplete 0.0.0 → 0.0.1
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/lib/autocomplete_ui.rb +12 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138b64dd1eda8ad9410fee940e423ba7d04d4426
|
4
|
+
data.tar.gz: 18ae716a33babeb49e8913d7e8708108faab9ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6365476c5bd8b6268e5ba291f08835c814c001f4b9a507e7c9a92b11b7cfc8ae17adf9083dea10bb40ccc81dab3c35b8f4ca56e97c55800f7aeb5b0c951e661
|
7
|
+
data.tar.gz: e92e7766abcd041528fdaf3880ce85e24f24cf452cee2e3b14fddd22b20d0a0861f403b57744164af45d896c87eeae338c39e455168cac5a86731908cfedc501
|
data/lib/autocomplete_ui.rb
CHANGED
@@ -3,10 +3,9 @@ require 'reactive-ruby'
|
|
3
3
|
class AutocompleteInput < React::Component::Base
|
4
4
|
|
5
5
|
param :value
|
6
|
-
param :
|
6
|
+
param :on_change
|
7
7
|
param :ref_
|
8
8
|
param :name
|
9
|
-
#param :set_validation
|
10
9
|
|
11
10
|
before_mount do
|
12
11
|
state.options! []
|
@@ -22,21 +21,15 @@ class AutocompleteInput < React::Component::Base
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def render
|
25
|
-
|
24
|
+
span(class: 'autocomplete-box') do
|
26
25
|
input(type: :text, value: params.value).on(:change) do |event|
|
27
|
-
params.
|
28
|
-
#if state.options.include? event.target.value
|
29
|
-
# params.set_validation.call true
|
30
|
-
#else
|
31
|
-
# params.set_validation.call false
|
32
|
-
#end
|
26
|
+
params.on_change.call event.target.value
|
33
27
|
$controller.rpc('get_' + params.ref_, event.target.value).then do |result|
|
34
28
|
state.options! result.map {|x| x[params.name]}
|
35
29
|
end
|
36
30
|
end.on(:keyDown) do |event|
|
37
31
|
if event.key_code == 13
|
38
|
-
params.
|
39
|
-
#params.set_validation.call true
|
32
|
+
params.on_change.call state.options[state.index]
|
40
33
|
state.options! []
|
41
34
|
elsif event.key_code == 40
|
42
35
|
state.index! (state.index + 1) % state.options.length if state.options.length != 0
|
@@ -46,11 +39,15 @@ class AutocompleteInput < React::Component::Base
|
|
46
39
|
end
|
47
40
|
div(class: 'autocomplete-popover') do
|
48
41
|
state.options.each_with_index do |v, i|
|
49
|
-
|
50
|
-
|
51
|
-
|
42
|
+
m = v.match(/(.*)(#{params.value})(.*)/i)
|
43
|
+
div(class: selected(i)) do
|
44
|
+
span{m[1]}
|
45
|
+
b{m[2]}
|
46
|
+
span{m[3]}
|
47
|
+
end.on(:click) do |e|
|
48
|
+
params.on_change.call v
|
52
49
|
state.options! []
|
53
|
-
end
|
50
|
+
end if m
|
54
51
|
end
|
55
52
|
end if state.options.length > 1 || state.options[0] != params.value
|
56
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bull-autocomplete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Alarcos
|
@@ -10,7 +10,7 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Autocomplete feature for Bull
|
13
|
+
description: Autocomplete feature for Bull Framework
|
14
14
|
email: miguel.alarcos@gmail.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -19,7 +19,7 @@ files:
|
|
19
19
|
- lib/autocomplete.styl
|
20
20
|
- lib/autocomplete_ui.rb
|
21
21
|
- lib/bull-autocomplete.rb
|
22
|
-
homepage:
|
22
|
+
homepage: https://rubygems.org/gems/bull-autocomplete
|
23
23
|
licenses:
|
24
24
|
- MIT
|
25
25
|
metadata: {}
|