admin_assistant 1.0.4 → 2.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,113 @@
1
+ /* Example tokeninput style #1: Token vertical list*/
2
+ ul.token-input-list {
3
+ overflow: hidden;
4
+ height: auto !important;
5
+ height: 1%;
6
+ width: 400px;
7
+ border: 1px solid #999;
8
+ cursor: text;
9
+ font-size: 12px;
10
+ font-family: Verdana;
11
+ z-index: 999;
12
+ margin: 0;
13
+ padding: 0;
14
+ background-color: #fff;
15
+ list-style-type: none;
16
+ clear: left;
17
+ }
18
+
19
+ ul.token-input-list li {
20
+ list-style-type: none;
21
+ }
22
+
23
+ ul.token-input-list li input {
24
+ border: 0;
25
+ width: 350px;
26
+ padding: 3px 8px;
27
+ background-color: white;
28
+ -webkit-appearance: caret;
29
+ }
30
+
31
+ li.token-input-token {
32
+ overflow: hidden;
33
+ height: auto !important;
34
+ height: 1%;
35
+ margin: 3px;
36
+ padding: 3px 5px;
37
+ background-color: #d0efa0;
38
+ color: #000;
39
+ font-weight: bold;
40
+ cursor: default;
41
+ display: block;
42
+ }
43
+
44
+ li.token-input-token p {
45
+ float: left;
46
+ padding: 0;
47
+ margin: 0;
48
+ }
49
+
50
+ li.token-input-token span {
51
+ float: right;
52
+ color: #777;
53
+ cursor: pointer;
54
+ }
55
+
56
+ li.token-input-selected-token {
57
+ background-color: #08844e;
58
+ color: #fff;
59
+ }
60
+
61
+ li.token-input-selected-token span {
62
+ color: #bbb;
63
+ }
64
+
65
+ div.token-input-dropdown {
66
+ position: absolute;
67
+ width: 400px;
68
+ background-color: #fff;
69
+ overflow: hidden;
70
+ border-left: 1px solid #ccc;
71
+ border-right: 1px solid #ccc;
72
+ border-bottom: 1px solid #ccc;
73
+ cursor: default;
74
+ font-size: 12px;
75
+ font-family: Verdana;
76
+ z-index: 1;
77
+ }
78
+
79
+ div.token-input-dropdown p {
80
+ margin: 0;
81
+ padding: 5px;
82
+ font-weight: bold;
83
+ color: #777;
84
+ }
85
+
86
+ div.token-input-dropdown ul {
87
+ margin: 0;
88
+ padding: 0;
89
+ }
90
+
91
+ div.token-input-dropdown ul li {
92
+ background-color: #fff;
93
+ padding: 3px;
94
+ list-style-type: none;
95
+ }
96
+
97
+ div.token-input-dropdown ul li.token-input-dropdown-item {
98
+ background-color: #fafafa;
99
+ }
100
+
101
+ div.token-input-dropdown ul li.token-input-dropdown-item2 {
102
+ background-color: #fff;
103
+ }
104
+
105
+ div.token-input-dropdown ul li em {
106
+ font-weight: bold;
107
+ font-style: normal;
108
+ }
109
+
110
+ div.token-input-dropdown ul li.token-input-selected-dropdown-item {
111
+ background-color: #d0efa0;
112
+ }
113
+
@@ -1,7 +1,4 @@
1
- <div class="polymorphic">
2
1
  <%
3
- hidden_field_id = "search_#{column.association_foreign_key}"
4
- hidden_type_field_id = "search_#{column.foreign_type_field}"
5
2
  associated = record.send(column.name)
6
3
  if associated
7
4
  associated_id = associated.id
@@ -10,80 +7,70 @@ else
10
7
  associated_id = nil
11
8
  associated_type = nil
12
9
  end
13
- auth_token = if protect_against_forgery?
14
- form_authenticity_token
15
- else
16
- ''
17
- end
18
- js_args = {:autocompleteTypes => [], :idTypes => [], :selectTypes => []}
19
10
  %>
11
+ <div class="polymorphic" id="polymorphic_search_<%= column.name %>">
20
12
  <%= hidden_field_tag(
21
13
  "search[#{column.association_foreign_key}]", associated_id,
22
14
  :id => "search_#{column.association_foreign_key}"
23
15
  ) %>
24
16
  <%= hidden_field_tag(
25
17
  "search[#{column.foreign_type_field}]", associated_type,
26
- :id => hidden_type_field_id
18
+ :id => "search_#{column.foreign_type_field}"
27
19
  ) %>
20
+ <% polymorphic_types.each do |polymorphic_type| %>
28
21
  <%
29
- polymorphic_types.each do |polymorphic_type|
30
- name = polymorphic_type.name.underscore.downcase
22
+ name = polymorphic_type.name.underscore
31
23
  association_target = AdminAssistant::AssociationTarget.new polymorphic_type
32
24
  %>
33
- <div class="polymorphic_type">
34
- <% if association_target.default_name_method %>
35
- <label><%= association_target.name.capitalize %></label>
25
+ <div class="polymorphic_type" id="polymorphic_search_<%= column.name %>_<%= name %>">
26
+ <%
27
+ label = association_target.name.capitalize
28
+ label << " ID" unless association_target.default_name_method
29
+ %>
30
+ <label><%= label %></label>
36
31
  <br />
37
- <%
38
- if polymorphic_type.count > 15
39
- clear_link_id = "clear_#{column.name}_#{name}_link"
40
- text_field_id = "#{column.name}_#{name}_autocomplete_input"
41
- palette_id = "#{column.name}_#{name}_autocomplete_palette"
42
- js_args[:autocompleteTypes] << {
43
- :clearLink => clear_link_id, :name => name, :palette => palette_id,
44
- :parameters => "authenticity_token=#{auth_token}",
45
- :textField => text_field_id, :type => polymorphic_type.name,
46
- :url => "/#{controller.controller_path}/autocomplete_#{name}"
32
+ <% if association_target.default_name_method %>
33
+ <% if polymorphic_type.count > 15 %>
34
+ <%
35
+ data_fields = {
36
+ "data-behavior" => 'autocomplete',
37
+ 'data-autocomplete-url' =>
38
+ "/#{controller.controller_path}/autocomplete_#{name}",
39
+ 'data-value-type' => polymorphic_type.name
47
40
  }
48
- text_field_value = if associated.class == polymorphic_type
49
- association_target.assoc_value(associated)
41
+ if associated.class == polymorphic_type
42
+ data_fields['data-initial-id'] = associated.id
43
+ data_fields['data-initial-name'] =
44
+ association_target.assoc_value(associated)
50
45
  end
51
- %>
52
- <%= text_field_tag(text_field_id, text_field_value, :id => text_field_id) %>
53
- <div id="<%= palette_id %>" class="autocomplete_palette" style="display:none"></div>
54
- <div id="<%= clear_link_id %>" style="display:none; padding: 5px">
55
- <%= link_to_function("Clear #{name}", "") %>
56
- </div>
57
- <%
58
- else
59
- js_args[:selectTypes] << {:name => name, :type => polymorphic_type.name}
60
- option_tags = "<option value=''></option>"
61
- option_tags << options_for_select(
62
- association_target.options_for_select,
63
- (associated.id if associated.class == polymorphic_type)
64
- )
65
- %>
66
- <%= select_tag("#{column.name}_#{name}_id", option_tags) %>
67
- <%
68
- end
69
- else
70
- js_args[:idTypes] << {:name => name, :type => polymorphic_type.name}
71
- %>
72
- <label><%= association_target.name.capitalize %> ID</label>
73
- <br />
46
+ %>
47
+ <%= text_field_tag("#{column.name}_#{name}_id", nil, data_fields) %>
48
+ <% else %>
49
+ <%
50
+ option_tags = "<option value=''></option>"
51
+ option_tags << options_for_select(
52
+ association_target.options_for_select,
53
+ (associated.id if associated.class == polymorphic_type)
54
+ )
55
+ %>
56
+ <%= select_tag(
57
+ "#{column.name}_#{name}_id", option_tags,
58
+ 'data-behavior' => 'select',
59
+ 'data-value-type' => polymorphic_type.name
60
+ ) %>
61
+ <% end # if polymorphic_type.count > 15 %>
62
+ <% else # if association_target.default_name_method %>
74
63
  <%= text_field_tag(
75
64
  "#{column.name}_#{name}_id",
76
- (associated.id if associated.class == polymorphic_type)
65
+ (associated.id if associated.class == polymorphic_type),
66
+ 'data-behavior' => 'id', 'data-value-type' => polymorphic_type.name
77
67
  ) %>
78
- <%
79
- end
80
- %>
68
+ <% end %>
81
69
  </div>
82
70
  <% end %>
83
71
  <br style="clear:both" />
84
72
  </div>
85
73
  <script type="text/javascript">
86
- new AdminAssistant.PolymorphicFieldSearch(
87
- '<%= column.name %>', <%= js_args.to_json %>
88
- );
74
+ new AdminAssistant.PolymorphicFieldSearch('<%= column.name %>');
89
75
  </script>
76
+
@@ -0,0 +1,26 @@
1
+ <%
2
+ record = form.object
3
+ associated_class_name = column.associated_class.name.underscore
4
+ class_name = record.class.name.gsub(/.*::/, '').underscore.downcase
5
+ text_field_id = "#{class_name}_#{column.association_foreign_key}"
6
+ token_url =
7
+ "/#{controller.controller_path}/autocomplete_#{associated_class_name }"
8
+ token_input_options = {'crossDomain' => false, 'tokenLimit' => 1}
9
+ if current_value = record.send(column.name)
10
+ default_name_method = AdminAssistant::AssociationTarget.new(
11
+ current_value.class
12
+ ).default_name_method
13
+ token_input_options['prePopulate'] = [{
14
+ 'id' => current_value.id, 'name' => current_value.send(default_name_method)
15
+ }]
16
+ end
17
+ %>
18
+ <%= form.text_field(column.association_foreign_key) %>
19
+ <script type="text/javascript">
20
+ $(document).ready(function() {
21
+ $("#<%= text_field_id %>").tokenInput(
22
+ "<%= token_url %>", <%= token_input_options.to_json %>
23
+ );
24
+ });
25
+ </script>
26
+
@@ -4,7 +4,9 @@
4
4
  %>">
5
5
  <div class="aa_header">
6
6
  <div class="actions">
7
- <%= link_to_function('Search', 'AdminAssistant.show_search_form()') if index_view.render_search_link? %>
7
+ <% if index_view.render_search_link? %>
8
+ <%= link_to('Search', '#', :id => 'show_search_form') %>
9
+ <% end %>
8
10
  <% if index_view.render_new_link? %>
9
11
  <%= index_view.new_link %>
10
12
  <% end %>
@@ -44,7 +46,11 @@
44
46
  <% end %>
45
47
 
46
48
  <% if @index.search_requested? %>
47
- <script type="text/javascript">AdminAssistant.show_search_form();</script>
49
+ <script type="text/javascript">
50
+ $(document).ready(function() {
51
+ $('#show_search_form').click();
52
+ });
53
+ </script>
48
54
  <% end %>
49
55
 
50
56
  <% if !@index.records.empty? %>
metadata CHANGED
@@ -1,40 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: admin_assistant
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.4
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: -1876988224
5
+ prerelease: true
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ - pre1
11
+ version: 2.0.0.pre1
6
12
  platform: ruby
7
- authors:
13
+ authors:
8
14
  - Francis Hwang
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2013-02-07 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2011-05-08 00:00:00 -04:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
15
23
  name: will_paginate
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
24
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
25
26
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- description: admin_assistant is a Rails plugin that automates a lot of features typically
31
- needed in admin interfaces.
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 3
31
+ segments:
32
+ - 0
33
+ version: "0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ description: admin_assistant is a Rails plugin that automates a lot of features typically needed in admin interfaces.
32
37
  email: sera@fhwang.net
33
38
  executables: []
39
+
34
40
  extensions: []
35
- extra_rdoc_files:
41
+
42
+ extra_rdoc_files:
36
43
  - README
37
- files:
44
+ files:
38
45
  - MIT-LICENSE
39
46
  - README
40
47
  - Rakefile
@@ -73,11 +80,12 @@ files:
73
80
  - lib/images/sort-asc.png
74
81
  - lib/images/sort-desc.png
75
82
  - lib/javascripts/admin_assistant.js
83
+ - lib/javascripts/jquery.tokeninput.js
76
84
  - lib/stylesheets/activescaffold.css
77
85
  - lib/stylesheets/default.css
86
+ - lib/stylesheets/token-input.css
78
87
  - lib/views/_polymorphic_field_search.html.erb
79
- - lib/views/_restricted_autocompleter.html.erb
80
- - lib/views/autocomplete.html.erb
88
+ - lib/views/_token_input.html.erb
81
89
  - lib/views/form.html.erb
82
90
  - lib/views/index.html.erb
83
91
  - lib/views/multi_form.html.erb
@@ -151,29 +159,41 @@ files:
151
159
  - website/quick_start.markdown
152
160
  - website/screenshots.markdown
153
161
  - website/tutorial.markdown
162
+ has_rdoc: true
154
163
  homepage: http://github.com/fhwang/admin_assistant
155
164
  licenses: []
165
+
156
166
  post_install_message:
157
167
  rdoc_options: []
158
- require_paths:
168
+
169
+ require_paths:
159
170
  - lib
160
- required_ruby_version: !ruby/object:Gem::Requirement
171
+ required_ruby_version: !ruby/object:Gem::Requirement
161
172
  none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ hash: 3
177
+ segments:
178
+ - 0
179
+ version: "0"
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
181
  none: false
168
- requirements:
169
- - - ! '>='
170
- - !ruby/object:Gem::Version
171
- version: '0'
182
+ requirements:
183
+ - - ">"
184
+ - !ruby/object:Gem::Version
185
+ hash: 25
186
+ segments:
187
+ - 1
188
+ - 3
189
+ - 1
190
+ version: 1.3.1
172
191
  requirements: []
192
+
173
193
  rubyforge_project:
174
- rubygems_version: 1.8.25
194
+ rubygems_version: 1.3.7
175
195
  signing_key:
176
196
  specification_version: 3
177
- summary: admin_assistant is a Rails plugin that automates a lot of features typically
178
- needed in admin interfaces.
197
+ summary: admin_assistant is a Rails plugin that automates a lot of features typically needed in admin interfaces.
179
198
  test_files: []
199
+
@@ -1,53 +0,0 @@
1
- <%
2
- record = form.object
3
- unless defined?(palette_clones_input_width) && !palette_clones_input_width.nil?
4
- palette_clones_input_width = true
5
- end
6
- class_name = record.class.name.gsub(/.*::/, '').underscore.downcase
7
- associated_class_name = column.associated_class.name.underscore
8
- text_field_id = "#{associated_class_name}_autocomplete_input"
9
- palette_id = "#{associated_class_name}_autocomplete_palette"
10
- hidden_field_id = "#{class_name}_#{column.association_foreign_key}"
11
- associated = record.send(column.name)
12
- if associated
13
- associated_id = associated.id
14
- else
15
- associated_id = nil
16
- end
17
- autocompleter_js_var = "#{associated_class_name}_autocompleter"
18
- target = AdminAssistant::AssociationTarget.new column.associated_class
19
- %>
20
- <%= text_field_tag(
21
- text_field_id, target.assoc_value(record.send(column.name)),
22
- :id => text_field_id
23
- ) %>
24
- <%=
25
- form.hidden_field(column.association_foreign_key, :id => hidden_field_id)
26
- %>
27
- <div id="<%= palette_id %>" class="autocomplete_palette" style="display:none"></div>
28
-
29
- <div id="clear_<%= associated_class_name %>_link" style="display:none; padding: 5px">
30
- <%= link_to_function("Clear #{associated_class_name}", "") %>
31
- </div>
32
-
33
- <%
34
- auth_token = if protect_against_forgery?
35
- form_authenticity_token
36
- else
37
- ''
38
- end
39
- options = {
40
- :includeBlank => select_options[:include_blank],
41
- :paletteClonesInputWidth => palette_clones_input_width,
42
- :parameters => "authenticity_token=#{auth_token}"
43
- }
44
- %>
45
- <script type="text/javascript">
46
- new AdminAssistant.RestrictedAutocompleter(
47
- "<%= associated_class_name %>",
48
- "<%= hidden_field_id %>",
49
- "/<%= controller.controller_path %>/autocomplete_<%= associated_class_name %>",
50
- <%= options.to_json %>
51
- );
52
- </script>
53
-