smart_listing 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/smart_listing/smart_listing.coffee.erb +23 -14
- data/app/helpers/smart_listing/helper.rb +19 -7
- data/app/views/smart_listing/_item_new.html.erb +5 -1
- data/app/views/smart_listing/item/_create_continue.js.erb +6 -0
- data/lib/generators/smart_listing/templates/initializer.rb +3 -2
- data/lib/smart_listing.rb +1 -1
- data/lib/smart_listing/config.rb +3 -2
- data/lib/smart_listing/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5029b5f33d511b0683ca39c58f1d4956b6fd29
|
4
|
+
data.tar.gz: d924b0eb292135656a20c0b37e2ef1cf7e48a95f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55401a3882f4b42e2797ea24c895d00e285c0f76b575b2809825b0f5ff4dd32ccf1953075290d4cdf25ad359e4c5446db5889b4e76797e529d9a58b93f603ac5
|
7
|
+
data.tar.gz: 6ab9ad98c2f7ec341d2d2d14c1a002f617cbb0317a1cb21b2ad82ac1003a77eec335beca1c68086342fc306aac15e8a4772d63b25b8025e9525423141b3c6516
|
@@ -39,6 +39,8 @@ class SmartListing
|
|
39
39
|
# Cancel new record
|
40
40
|
@container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
41
41
|
@container.find('.<%= SmartListing.config.classes(:new_item_action) %>').removeClass('<%= SmartListing.config.classes(:hidden) %>')
|
42
|
+
|
43
|
+
@setAutoshow(false)
|
42
44
|
false
|
43
45
|
|
44
46
|
@container.on 'click', '.<%= SmartListing.config.classes(:item_actions) %> a[data-<%= SmartListing.config.data_attributes(:confirmation) %>]', (event) =>
|
@@ -81,6 +83,9 @@ class SmartListing
|
|
81
83
|
maxCount: =>
|
82
84
|
parseInt(@container.data('<%= SmartListing.config.data_attributes(:max_count) %>'))
|
83
85
|
|
86
|
+
setAutoshow: (v) =>
|
87
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').data('<%= SmartListing.config.data_attributes(:autoshow) %>', v)
|
88
|
+
|
84
89
|
changeItemCount: (value) =>
|
85
90
|
@container.find('.<%= SmartListing.config.classes(:pagination_per_page) %> .<%= SmartListing.config.classes(:pagination_count) %>').html(@itemCount() + value)
|
86
91
|
|
@@ -107,12 +112,15 @@ class SmartListing
|
|
107
112
|
|
108
113
|
if @maxCount()
|
109
114
|
if @itemCount() >= @maxCount()
|
110
|
-
|
111
|
-
|
112
|
-
@container.find('.<%= SmartListing.config.classes(:new_item_action) %> .<%= SmartListing.config.classes(:new_item_button) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
115
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
116
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_action) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
113
117
|
else
|
114
|
-
@container.find('.<%= SmartListing.config.classes(:
|
115
|
-
|
118
|
+
if @container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').data('<%= SmartListing.config.data_attributes(:autoshow) %>')
|
119
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').removeClass('<%= SmartListing.config.classes(:hidden) %>')
|
120
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_action) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
121
|
+
else
|
122
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
123
|
+
@container.find('.<%= SmartListing.config.classes(:new_item_action) %>').removeClass('<%= SmartListing.config.classes(:hidden) %>')
|
116
124
|
|
117
125
|
@status.each (index, status) =>
|
118
126
|
$(status).find('.<%= SmartListing.config.classes(:limit) %>').html(@maxCount() - @itemCount())
|
@@ -132,18 +140,19 @@ class SmartListing
|
|
132
140
|
# Methods executed by rails UJS:
|
133
141
|
|
134
142
|
new_item: (content) =>
|
135
|
-
|
136
|
-
|
143
|
+
if !@maxCount() || (@itemCount() < @maxCount())
|
144
|
+
new_item_action = @container.find('.<%= SmartListing.config.classes(:new_item_action) %>')
|
145
|
+
new_item_placeholder = @container.find('.<%= SmartListing.config.classes(:new_item_placeholder) %>').addClass('<%= SmartListing.config.classes(:hidden) %>')
|
137
146
|
|
138
|
-
|
139
|
-
|
147
|
+
@container.find('.<%= SmartListing.config.classes(:editable) %>').each (i, v) =>
|
148
|
+
@cancelEdit($(v))
|
140
149
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
150
|
+
new_item_action.addClass('<%= SmartListing.config.classes(:hidden) %>')
|
151
|
+
new_item_placeholder.removeClass('<%= SmartListing.config.classes(:hidden) %>')
|
152
|
+
new_item_placeholder.html(content)
|
153
|
+
new_item_placeholder.addClass('<%= SmartListing.config.classes(:inline_editing) %>')
|
145
154
|
|
146
|
-
|
155
|
+
@fadeLoaded()
|
147
156
|
|
148
157
|
create: (id, success, content) =>
|
149
158
|
new_item_action = @container.find('.<%= SmartListing.config.classes(:new_item_action) %>')
|
@@ -116,26 +116,37 @@ module SmartListing
|
|
116
116
|
end
|
117
117
|
|
118
118
|
# Add new item button & placeholder to list
|
119
|
-
def item_new options = {}
|
120
|
-
new_item_action_classes = [SmartListing.config.classes(:new_item_action)]
|
121
|
-
new_item_action_classes << SmartListing.config.classes(:hidden) if !empty? && max_count?
|
119
|
+
def item_new options = {}, &block
|
122
120
|
no_records_classes = [SmartListing.config.classes(:no_records)]
|
123
121
|
no_records_classes << SmartListing.config.classes(:hidden) unless empty?
|
124
122
|
new_item_button_classes = []
|
125
123
|
new_item_button_classes << SmartListing.config.classes(:hidden) if max_count?
|
126
124
|
|
127
125
|
locals = {
|
128
|
-
:placeholder_classes => [SmartListing.config.classes(:new_item_placeholder), SmartListing.config.classes(:hidden)],
|
129
|
-
:new_item_action_classes => new_item_action_classes,
|
130
126
|
:colspan => options.delete(:colspan),
|
131
127
|
:no_items_classes => no_records_classes,
|
132
128
|
:no_items_text => options.delete(:no_items_text),
|
133
129
|
:new_item_button_url => options.delete(:link),
|
134
130
|
:new_item_button_classes => new_item_button_classes,
|
135
131
|
:new_item_button_text => options.delete(:text),
|
132
|
+
:new_item_autoshow => block_given?,
|
133
|
+
:new_item_content => nil,
|
136
134
|
}
|
137
135
|
|
138
|
-
|
136
|
+
unless block_given?
|
137
|
+
locals[:placeholder_classes] = [SmartListing.config.classes(:new_item_placeholder), SmartListing.config.classes(:hidden)]
|
138
|
+
locals[:new_item_action_classes] = [SmartListing.config.classes(:new_item_action)]
|
139
|
+
locals[:new_item_action_classes] << SmartListing.config.classes(:hidden) if !empty? && max_count?
|
140
|
+
|
141
|
+
@template.render(:partial => 'smart_listing/item_new', :locals => default_locals.merge(locals))
|
142
|
+
else
|
143
|
+
locals[:placeholder_classes] = [SmartListing.config.classes(:new_item_placeholder)]
|
144
|
+
locals[:placeholder_classes] << SmartListing.config.classes(:hidden) if !empty? && max_count?
|
145
|
+
locals[:new_item_action_classes] = [SmartListing.config.classes(:new_item_action), SmartListing.config.classes(:hidden)]
|
146
|
+
|
147
|
+
locals[:new_item_content] = @template.capture(&block)
|
148
|
+
@template.render(:partial => 'smart_listing/item_new', :locals => default_locals.merge(locals))
|
149
|
+
end
|
139
150
|
end
|
140
151
|
|
141
152
|
# Check if smart list is empty
|
@@ -272,8 +283,9 @@ module SmartListing
|
|
272
283
|
id = options[:id] || object.try(:id)
|
273
284
|
valid = options[:valid] if options.has_key?(:valid)
|
274
285
|
object_key = options.delete(:object_key) || :object
|
286
|
+
new = options.delete(:new)
|
275
287
|
|
276
|
-
render(:partial => "smart_listing/item/#{item_action.to_s}", :locals => {:name => name, :id => id, :valid => valid, :object_key => object_key, :object => object, :part => partial})
|
288
|
+
render(:partial => "smart_listing/item/#{item_action.to_s}", :locals => {:name => name, :id => id, :valid => valid, :object_key => object_key, :object => object, :part => partial, :new => new})
|
277
289
|
end
|
278
290
|
end
|
279
291
|
end
|
@@ -10,9 +10,13 @@
|
|
10
10
|
new_item_button_url: argument to link_to (new item button)
|
11
11
|
new_item_button_classes
|
12
12
|
new_item_button_text
|
13
|
+
new_item_autoshow automatically show new item placeholder
|
14
|
+
new_item_content new item placeholder content (usually some form)
|
13
15
|
-%>
|
14
16
|
|
15
|
-
<%= content_tag(:tr, '', :class => placeholder_classes + %w{info}) %>
|
17
|
+
<%= content_tag(:tr, '', :class => placeholder_classes + %w{info}, :data => {SmartListing.config.data_attributes(:autoshow) => new_item_autoshow}) do %>
|
18
|
+
<%= new_item_content %>
|
19
|
+
<% end %>
|
16
20
|
<%= content_tag(:tr, :class => new_item_action_classes + %w{info}) do %>
|
17
21
|
<%= content_tag(:td, :colspan => colspan) do %>
|
18
22
|
<%= content_tag(:p, :class => no_items_classes + %w{pull-left}) do %>
|
@@ -0,0 +1,6 @@
|
|
1
|
+
var smart_listing = $('#<%= name %>').smart_listing();
|
2
|
+
smart_listing.create(<%= id || 0 %>, <%= object.persisted? %>, "<%= escape_javascript(render(:partial => part, :locals => {object_key => object})) %>");
|
3
|
+
smart_listing.setAutoshow(true);
|
4
|
+
<% if object.persisted? %>
|
5
|
+
smart_listing.new_item("<%= escape_javascript(render(:partial => new.last, :locals => {object_key => new.first})) %>");
|
6
|
+
<% end %>
|
@@ -16,8 +16,8 @@ SmartListing.configure do |config|
|
|
16
16
|
#:pagination_count => "count",
|
17
17
|
#:inline_editing => "info",
|
18
18
|
#:no_records => "no-records",
|
19
|
-
#:limit => "limit",
|
20
|
-
#:limit_alert => "limit-alert",
|
19
|
+
#:limit => "smart-listing-limit",
|
20
|
+
#:limit_alert => "smart-listing-limit-alert",
|
21
21
|
#:controls => "smart-listing-controls",
|
22
22
|
#:controls_reset => "reset",
|
23
23
|
#:filtering => "filter",
|
@@ -46,6 +46,7 @@ SmartListing.configure do |config|
|
|
46
46
|
#:params => "params",
|
47
47
|
#:observed => "observed",
|
48
48
|
#:href => "href",
|
49
|
+
#:autoshow => "autoshow",
|
49
50
|
}
|
50
51
|
|
51
52
|
config.constants :selectors, {
|
data/lib/smart_listing.rb
CHANGED
@@ -91,7 +91,7 @@ module SmartListing
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
else
|
94
|
-
@collection = @collection.order("#{@sort_attr} #{@sort_order}") if @options[:sort] && @sort_attr && !@sort_attr.empty? && @sort_order
|
94
|
+
@collection = @collection.order("#{@sort_attr} #{@sort_order}") if @options[:sort] && @sort_attr && !@sort_attr.empty? && @collection.column_names.include?(@sort_attr) && @sort_order
|
95
95
|
if @options[:paginate] && @per_page > 0
|
96
96
|
@collection = @collection.page(@page).per(@per_page)
|
97
97
|
end
|
data/lib/smart_listing/config.rb
CHANGED
@@ -27,8 +27,8 @@ module SmartListing
|
|
27
27
|
:pagination_count => "count",
|
28
28
|
:inline_editing => "info",
|
29
29
|
:no_records => "no-records",
|
30
|
-
:limit => "limit",
|
31
|
-
:limit_alert => "limit-alert",
|
30
|
+
:limit => "smart-listing-limit",
|
31
|
+
:limit_alert => "smart-listing-limit-alert",
|
32
32
|
:controls => "smart-listing-controls",
|
33
33
|
:controls_reset => "reset",
|
34
34
|
:filtering => "filter",
|
@@ -56,6 +56,7 @@ module SmartListing
|
|
56
56
|
:params => "params",
|
57
57
|
:observed => "observed",
|
58
58
|
:href => "href",
|
59
|
+
:autoshow => "autoshow",
|
59
60
|
},
|
60
61
|
:selectors => {
|
61
62
|
:item_action_destroy => "a.destroy",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smart_listing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sology
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- app/views/smart_listing/_sortable.html.erb
|
93
93
|
- app/views/smart_listing/_update_list.js.erb
|
94
94
|
- app/views/smart_listing/item/_create.js.erb
|
95
|
+
- app/views/smart_listing/item/_create_continue.js.erb
|
95
96
|
- app/views/smart_listing/item/_destroy.js.erb
|
96
97
|
- app/views/smart_listing/item/_edit.js.erb
|
97
98
|
- app/views/smart_listing/item/_new.js.erb
|