redmine_crm 0.0.35 → 0.0.36
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/CHANGELOG +4 -0
- data/lib/redmine_crm/helpers/form_tag_helper.rb +74 -22
- data/lib/redmine_crm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2ae8872b72b3265c1ae6e6993a8b3e0ca78f920
|
4
|
+
data.tar.gz: c8364d112ed92618726af3ef54b16ffc23090abd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a623433baaf7d77bf346e0a04e0a0052eeee082d063d13b073b20d487208bf1ac0183d03380b18e109d7ddfbc88405f5c8afde7d05c4b3a2c65241f50ff1b67
|
7
|
+
data.tar.gz: 4004698fa8ee608d219a319142708253de3dc0770bba5d856715ffb9c49d7753c0c41320321bf8a9a6296b87a2767249727d215077487972088a58889b07389c
|
data/doc/CHANGELOG
CHANGED
@@ -1,40 +1,92 @@
|
|
1
1
|
module RedmineCrm
|
2
2
|
module FormTagHelper
|
3
|
+
# Allows include select2 into your views.
|
4
|
+
#
|
5
|
+
# ==== Examples
|
6
|
+
# select2_tag 'city_id', '<option value="1">Lisbon</option>...'
|
7
|
+
# select2_tag 'city_id', options_for_select(...)
|
8
|
+
# select2_tag 'tag_list', nil, :multiple => true, :data => [{ id: 0, text: 'deal' }, ...], :tags => true, :include_hidden => false %>
|
9
|
+
# select2_tag 'tag_list', options_for_select(...), :multiple => true, :style => 'width: 100%;', :url => '/tags', :placeholder => '+ add tag', :tags => true %>
|
10
|
+
#
|
11
|
+
# You may use select_tag options and additional options.
|
12
|
+
#
|
13
|
+
# ==== Additional options
|
14
|
+
# * <tt>:url</tt> Allows searches for remote data using the ajax.
|
15
|
+
# * <tt>:data</tt> Load dropdown options from a local array if +url+ option not set.
|
16
|
+
# * <tt>:placeholder</tt> Supports displaying a placeholder value.
|
17
|
+
# * <tt>:include_hidden</tt> Adds hidden field after select when +multiple+ option true. Default value true.
|
18
|
+
#
|
19
|
+
# <b>Note:</b> The HTML specification says when +multiple+ parameter passed to select and all options got deselected
|
20
|
+
# web browsers do not send any value to server.
|
21
|
+
#
|
22
|
+
# In case if you don't want the helper to generate this hidden field you can specify
|
23
|
+
# <tt>include_hidden: false</tt> option.
|
24
|
+
#
|
25
|
+
# Also aliased as: select2
|
26
|
+
#
|
27
|
+
# select2 'city_id', options_for_select(...)
|
28
|
+
#
|
3
29
|
def select2_tag(name, option_tags = nil, options = {})
|
4
30
|
id = sanitize_to_id(name)
|
5
|
-
url = options[:url].to_s
|
6
|
-
data = options[:data] || []
|
7
31
|
placeholder = options[:placeholder] || 'Select ...'
|
8
32
|
|
9
|
-
data_source =
|
10
|
-
if url.empty?
|
11
|
-
"data: #{data.to_json}"
|
12
|
-
else
|
13
|
-
"ajax: {
|
14
|
-
url: '#{url}',
|
15
|
-
dataType: 'json',
|
16
|
-
delay: 250,
|
17
|
-
data: function (params) {
|
18
|
-
return { q: params.term };
|
19
|
-
},
|
20
|
-
processResults: function (data, params) {
|
21
|
-
return { results: data };
|
22
|
-
},
|
23
|
-
cache: true
|
24
|
-
}"
|
25
|
-
end
|
26
|
-
|
27
33
|
content_for(:header_tags) { select2_assets }
|
28
34
|
result = select_tag(name, option_tags, options)
|
35
|
+
if options[:multiple] && options.fetch(:include_hidden, true)
|
36
|
+
result << hidden_field_tag("#{name}[]", '')
|
37
|
+
end
|
38
|
+
|
29
39
|
result << javascript_tag(<<-JS)
|
30
40
|
$(function () {
|
31
41
|
$('select#' + '#{id}').select2({
|
32
|
-
#{
|
33
|
-
|
42
|
+
#{select2_data_source_options(options)},
|
43
|
+
#{select2_tags_options(options)},
|
34
44
|
placeholder: '#{placeholder}'
|
35
45
|
});
|
36
46
|
});
|
37
47
|
JS
|
38
48
|
end
|
49
|
+
|
50
|
+
alias select2 select2_tag
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def select2_data_source_options(options = {})
|
55
|
+
if options[:url].to_s.empty?
|
56
|
+
"data: #{options.fetch(:data, []).to_json}"
|
57
|
+
else
|
58
|
+
"ajax: {
|
59
|
+
url: '#{options[:url]}',
|
60
|
+
dataType: 'json',
|
61
|
+
delay: 250,
|
62
|
+
data: function (params) {
|
63
|
+
return { q: params.term };
|
64
|
+
},
|
65
|
+
processResults: function (data, params) {
|
66
|
+
return { results: data };
|
67
|
+
},
|
68
|
+
cache: true
|
69
|
+
}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def select2_tags_options(options = {})
|
74
|
+
if options.fetch(:tags, false)
|
75
|
+
"tags: true,
|
76
|
+
tokenSeparators: [','],
|
77
|
+
createTag: function (params) {
|
78
|
+
var term = $.trim(params.term);
|
79
|
+
if (term === '' || term.indexOf(',') > -1) {
|
80
|
+
return null; // Return null to disable tag creation
|
81
|
+
}
|
82
|
+
return {
|
83
|
+
id: term,
|
84
|
+
text: term
|
85
|
+
}
|
86
|
+
}"
|
87
|
+
else
|
88
|
+
'tags: false'
|
89
|
+
end
|
90
|
+
end
|
39
91
|
end
|
40
92
|
end
|
data/lib/redmine_crm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_crm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.36
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RedmineUP
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|