activeadmin-regex-input 0.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a3e4d209af6005d2c6edb98712b2e4e6ae246f1a
4
+ data.tar.gz: 511ae5bc609c95a14b8305898d7812423d87ed0d
5
+ SHA512:
6
+ metadata.gz: 796a90c0a99c6e4199e4c2518ba9abf918b342a3c8ad68f6435fdc66c798ae769e6c47524c3c61114512cea8bc1844c8fca789ec76a1125ec2db7cfb363114bb
7
+ data.tar.gz: 90d7330afc0ae67b749415d5644d3ab437c5ba47f6ac52600d2f9548c04fc15af98a7430e54142c211f681cc6060fa59e2de738def525e06e6216b97e17bb5b4
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,155 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ activeadmin-regex-input (0.0.0)
5
+ activeadmin
6
+ jquery-rails
7
+ rails-assets-webui-popover
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionpack (5.1.5)
13
+ actionview (= 5.1.5)
14
+ activesupport (= 5.1.5)
15
+ rack (~> 2.0)
16
+ rack-test (>= 0.6.3)
17
+ rails-dom-testing (~> 2.0)
18
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
19
+ actionview (5.1.5)
20
+ activesupport (= 5.1.5)
21
+ builder (~> 3.1)
22
+ erubi (~> 1.4)
23
+ rails-dom-testing (~> 2.0)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
25
+ activeadmin (1.2.1)
26
+ arbre (>= 1.1.1)
27
+ coffee-rails
28
+ formtastic (~> 3.1)
29
+ formtastic_i18n
30
+ inherited_resources (~> 1.7)
31
+ jquery-rails (>= 4.2.0)
32
+ kaminari (>= 0.15, < 2.0)
33
+ railties (>= 4.2, < 5.2)
34
+ ransack (~> 1.3)
35
+ sass (~> 3.1)
36
+ sprockets (< 4.1)
37
+ activemodel (5.1.5)
38
+ activesupport (= 5.1.5)
39
+ activerecord (5.1.5)
40
+ activemodel (= 5.1.5)
41
+ activesupport (= 5.1.5)
42
+ arel (~> 8.0)
43
+ activesupport (5.1.5)
44
+ concurrent-ruby (~> 1.0, >= 1.0.2)
45
+ i18n (~> 0.7)
46
+ minitest (~> 5.1)
47
+ tzinfo (~> 1.1)
48
+ arbre (1.1.1)
49
+ activesupport (>= 3.0.0)
50
+ arel (8.0.0)
51
+ builder (3.2.3)
52
+ coffee-rails (4.2.2)
53
+ coffee-script (>= 2.2.0)
54
+ railties (>= 4.0.0)
55
+ coffee-script (2.4.1)
56
+ coffee-script-source
57
+ execjs
58
+ coffee-script-source (1.12.2)
59
+ concurrent-ruby (1.0.5)
60
+ crass (1.0.3)
61
+ erubi (1.7.1)
62
+ execjs (2.7.0)
63
+ ffi (1.9.23)
64
+ formtastic (3.1.5)
65
+ actionpack (>= 3.2.13)
66
+ formtastic_i18n (0.6.0)
67
+ has_scope (0.7.1)
68
+ actionpack (>= 4.1, < 5.2)
69
+ activesupport (>= 4.1, < 5.2)
70
+ i18n (0.9.5)
71
+ concurrent-ruby (~> 1.0)
72
+ inherited_resources (1.8.0)
73
+ actionpack (>= 4.2, <= 5.2)
74
+ has_scope (~> 0.6)
75
+ railties (>= 4.2, <= 5.2)
76
+ responders
77
+ jquery-rails (4.3.1)
78
+ rails-dom-testing (>= 1, < 3)
79
+ railties (>= 4.2.0)
80
+ thor (>= 0.14, < 2.0)
81
+ kaminari (1.1.1)
82
+ activesupport (>= 4.1.0)
83
+ kaminari-actionview (= 1.1.1)
84
+ kaminari-activerecord (= 1.1.1)
85
+ kaminari-core (= 1.1.1)
86
+ kaminari-actionview (1.1.1)
87
+ actionview
88
+ kaminari-core (= 1.1.1)
89
+ kaminari-activerecord (1.1.1)
90
+ activerecord
91
+ kaminari-core (= 1.1.1)
92
+ kaminari-core (1.1.1)
93
+ loofah (2.2.0)
94
+ crass (~> 1.0.2)
95
+ nokogiri (>= 1.5.9)
96
+ method_source (0.9.0)
97
+ mini_portile2 (2.3.0)
98
+ minitest (5.11.3)
99
+ nokogiri (1.8.2)
100
+ mini_portile2 (~> 2.3.0)
101
+ polyamorous (1.3.3)
102
+ activerecord (>= 3.0)
103
+ rack (2.0.4)
104
+ rack-test (0.8.3)
105
+ rack (>= 1.0, < 3)
106
+ rails-assets-jquery (3.3.1)
107
+ rails-assets-webui-popover (2.1.15)
108
+ rails-assets-jquery (>= 1.7.0)
109
+ rails-dom-testing (2.0.3)
110
+ activesupport (>= 4.2.0)
111
+ nokogiri (>= 1.6)
112
+ rails-html-sanitizer (1.0.3)
113
+ loofah (~> 2.0)
114
+ railties (5.1.5)
115
+ actionpack (= 5.1.5)
116
+ activesupport (= 5.1.5)
117
+ method_source
118
+ rake (>= 0.8.7)
119
+ thor (>= 0.18.1, < 2.0)
120
+ rake (12.3.0)
121
+ ransack (1.8.7)
122
+ actionpack (>= 3.0)
123
+ activerecord (>= 3.0)
124
+ activesupport (>= 3.0)
125
+ i18n
126
+ polyamorous (~> 1.3.2)
127
+ rb-fsevent (0.10.3)
128
+ rb-inotify (0.9.10)
129
+ ffi (>= 0.5.0, < 2)
130
+ responders (2.4.0)
131
+ actionpack (>= 4.2.0, < 5.3)
132
+ railties (>= 4.2.0, < 5.3)
133
+ sass (3.5.5)
134
+ sass-listen (~> 4.0.0)
135
+ sass-listen (4.0.0)
136
+ rb-fsevent (~> 0.9, >= 0.9.4)
137
+ rb-inotify (~> 0.9, >= 0.9.7)
138
+ sprockets (3.7.1)
139
+ concurrent-ruby (~> 1.0)
140
+ rack (> 1, < 3)
141
+ thor (0.20.0)
142
+ thread_safe (0.3.6)
143
+ tzinfo (1.2.5)
144
+ thread_safe (~> 0.1)
145
+
146
+ PLATFORMS
147
+ ruby
148
+
149
+ DEPENDENCIES
150
+ activeadmin-regex-input!
151
+ bundler (~> 1.5)
152
+ rake
153
+
154
+ BUNDLED WITH
155
+ 1.16.1
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # FORMTASTIC REGEX INPUT
2
+
3
+ ## Description
4
+
5
+ A simple input with checking at client if input match predefined regex
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ lib = File.expand_path('../lib', __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'activeadmin/regex-input/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'activeadmin-regex-input'
7
+ s.version = '0.0.0'
8
+ s.date = '2018-03-12'
9
+ s.summary = "Formtastic Regex Input"
10
+ s.description = "A simple input for activeadmin with client check if input matches predefined regex."
11
+ s.authors = ["Canh Nguyen"]
12
+ s.email = 'xuancanh.1994@gmail.com'
13
+ s.files = `git ls-files -z`.split("\x0")
14
+ s.homepage =
15
+ 'http://rubygems.org/gems/hola'
16
+ s.license = 'MIT'
17
+ s.require_paths = ['lib']
18
+
19
+ s.add_development_dependency "bundler", "~> 1.5"
20
+ s.add_development_dependency "rake"
21
+
22
+ s.add_runtime_dependency 'activeadmin'
23
+ s.add_runtime_dependency 'jquery-rails'
24
+ s.add_runtime_dependency 'rails-assets-webui-popover'
25
+ end
@@ -0,0 +1,54 @@
1
+ //= require webui-popover
2
+
3
+ // https://css-tricks.com/snippets/javascript/get-url-variables/
4
+ // Get url query params
5
+ function getQueryVariable(key)
6
+ {
7
+ const query = decodeURI(window.location.search.substring(1));
8
+ let vars = query.split("&");
9
+ for (let i = 0; i < vars.length; i++) {
10
+ var pair = vars[i].split("=");
11
+ if(pair[0] === key){
12
+ // Replace + in url with space, might make the previous data became wrong
13
+ return decodeURIComponent(pair[1].replace('+', ' '));
14
+ }
15
+ }
16
+ return null;
17
+ }
18
+
19
+ // Init all reqex input
20
+ function initRegexInputs(inputs) {
21
+ for (let item of inputs) {
22
+ let input = $(item);
23
+ const regex = new RegExp(input.data('regex'));
24
+ const example = input.data('example');
25
+
26
+ // Reassign input value with query param from url
27
+ const value = getQueryVariable(input.attr('name'));
28
+ if (value) {
29
+ input.val(value);
30
+ }
31
+ // Create popover
32
+ input.webuiPopover({
33
+ title: 'Wrong input format',
34
+ content: `Example: ${example}`,
35
+ trigger: 'manual'
36
+ });
37
+
38
+ // Show popover and change color if current input doesn't match regex
39
+ input.on('keyup', event => {
40
+ console.log(input.val());
41
+ if (!regex.test(input.val())) {
42
+ input.css('border-color', 'red');
43
+ input.webuiPopover('show');
44
+ } else {
45
+ input.webuiPopover('hide');
46
+ input.css('border-color', '#c9d0d6');
47
+ }
48
+ });
49
+ }
50
+ }
51
+
52
+ $(document).ready(() => {
53
+ initRegexInputs($('.regex-input'));
54
+ });
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require webui-popover
3
+ */
@@ -0,0 +1,2 @@
1
+ require 'activeadmin/regex-input/engine'
2
+ require 'formtastic/regex-input'
@@ -0,0 +1,10 @@
1
+ require 'active_admin'
2
+
3
+ module ActiveAdmin
4
+ module RegexInput
5
+ class Engine < ::Rails::Engine
6
+ engine_name 'activeadmin_regex_input'
7
+
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveAdmin
2
+ module RegexInput
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ module Formtastic
2
+ module Inputs
3
+
4
+ class RegexInput < Formtastic::Inputs::StringInput
5
+ def input_html_options
6
+
7
+ {
8
+ class: 'regex-input',
9
+ data: {
10
+ regex: options[:regex],
11
+ example: options[:example]
12
+ },
13
+ placeholder_text: options[:example]
14
+ }
15
+ end
16
+
17
+ # Overwrite default li tag
18
+ def input_wrapping(&block)
19
+ template.content_tag(:div,
20
+ [template.capture(&block), error_html, hint_html].join("\n").html_safe,
21
+ wrapper_html_options
22
+ )
23
+ end
24
+
25
+ # Overwrite wrapper html by the active admin class
26
+ def wrapper_html_options
27
+ super.merge(:class => 'filter_form_field filter_string')
28
+ end
29
+ end
30
+
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: activeadmin-regex-input
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Canh Nguyen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-03-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activeadmin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails-assets-webui-popover
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A simple input for activeadmin with client check if input matches predefined
84
+ regex.
85
+ email: xuancanh.1994@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - README.md
94
+ - Rakefile
95
+ - activeadmin-regex-input.gemspec
96
+ - app/assets/javascript/active_admin/regex_input.js
97
+ - app/assets/stylesheets/active_admin/_regex_input.scss
98
+ - lib/activeadmin-regex-input.rb
99
+ - lib/activeadmin/regex-input/engine.rb
100
+ - lib/activeadmin/regex-input/version.rb
101
+ - lib/formtastic/regex-input.rb
102
+ homepage: http://rubygems.org/gems/hola
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.5.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Formtastic Regex Input
126
+ test_files: []