active_list 6.1.0 → 6.1.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.
@@ -6,8 +6,12 @@ module ActiveList
|
|
6
6
|
class ActionColumn < AbstractColumn
|
7
7
|
include ActiveList::Helpers
|
8
8
|
|
9
|
+
ID_PLACEHOLDER = "##IDS##"
|
10
|
+
|
9
11
|
USE_MODES = [:none, :single, :many, :both]
|
10
12
|
|
13
|
+
attr_reader :use_mode
|
14
|
+
|
11
15
|
def initialize(table, name, options = {})
|
12
16
|
super(table, name, options)
|
13
17
|
@use_mode = (@options.delete(:on) || :single).to_sym
|
@@ -53,7 +57,7 @@ module ActiveList
|
|
53
57
|
url[:format] = @options[:format]
|
54
58
|
end
|
55
59
|
if use_many? and use_mode == :many
|
56
|
-
url[:id] ||=
|
60
|
+
url[:id] ||= ID_PLACEHOLDER
|
57
61
|
end
|
58
62
|
return url
|
59
63
|
end
|
@@ -86,11 +90,11 @@ module ActiveList
|
|
86
90
|
raise StandardError, "Only compatible with single actions"
|
87
91
|
end
|
88
92
|
unless @options[:actions].is_a? Hash
|
89
|
-
raise StandardError, "
|
93
|
+
raise StandardError, ":actions parameter have to be a Hash."
|
90
94
|
end
|
91
95
|
cases = []
|
92
96
|
for expected, url in @options[:actions]
|
93
|
-
cases << record+"."+@name.to_s+" == " + expected.inspect + "\nlink_to(content_tag(:i) + h(#{url[:action].inspect}.t(scope: '
|
97
|
+
cases << record+"."+@name.to_s+" == " + expected.inspect + "\nlink_to(content_tag(:i) + h(#{url[:action].inspect}.t(scope: 'rest.actions'))"+
|
94
98
|
", {"+(url[:controller] ? 'controller: :'+url[:controller].to_s+', ' : '')+"action: '"+url[:action].to_s+"', id: "+record+".id"+format+"}"+
|
95
99
|
", {:class => '#{@name}'"+link_options+"}"+
|
96
100
|
")\n"
|
@@ -102,10 +106,11 @@ module ActiveList
|
|
102
106
|
url[:controller] ||= (@options[:controller] || "RECORD.class.name.tableize".c) # self.table.model.name.underscore.pluralize.to_s
|
103
107
|
url[:action] ||= @name.to_s
|
104
108
|
url[:id] ||= "RECORD.id".c
|
109
|
+
url[:id] = "RECORD.id".c if url[:id] == ID_PLACEHOLDER
|
105
110
|
url.delete_if{|k, v| v.nil?}
|
106
111
|
url = "{" + url.collect{|k, v| "#{k}: " + urlify(v, record)}.join(", ")+format+"}"
|
107
112
|
code = "{class: '#{@name}'" + link_options+"}"
|
108
|
-
code = "link_to(content_tag(:i) + h(' ' + '#{action}'.t(scope: '
|
113
|
+
code = "link_to(content_tag(:i) + h(' ' + '#{action}'.t(scope: 'rest.actions')), " + url + ", " + code + ")"
|
109
114
|
end
|
110
115
|
if @options[:if]
|
111
116
|
code = "if " + recordify!(@options[:if], record) + "\n" + code.dig + "end"
|
@@ -13,7 +13,6 @@ module ActiveList
|
|
13
13
|
@options[:renderer] ||= :simple_renderer
|
14
14
|
@options[:per_page] = 20 if @options[:per_page].to_i <= 0
|
15
15
|
@options[:page] = 1 if @options[:page].to_i <= 0
|
16
|
-
@selector = @options.delete(:selector)
|
17
16
|
@columns = []
|
18
17
|
@id = ActiveList.new_uid
|
19
18
|
end
|
@@ -58,7 +57,7 @@ module ActiveList
|
|
58
57
|
end
|
59
58
|
|
60
59
|
def selectable?
|
61
|
-
|
60
|
+
action_columns.select(&:use_many?).any?
|
62
61
|
end
|
63
62
|
|
64
63
|
# Retrieves all columns in database
|
@@ -283,7 +283,7 @@ module ActiveList
|
|
283
283
|
actioner = ""
|
284
284
|
actioner << "<span class=\"actioner\">'"
|
285
285
|
for column in table.global_action_columns
|
286
|
-
actioner << " + link_to(content_tag(:i) + h(' ' + :#{column.name.to_s}.t(scope: '
|
286
|
+
actioner << " + link_to(content_tag(:i) + h(' ' + :#{column.name.to_s}.t(scope: 'rest.actions')), #{column.default_url.inspect}, class: 'btn btn-#{column.name}'#{', style: "display: none"' unless column.use_none?}#{', method: "' + column.options[:method].to_s + '"' if column.options[:method]}, data: {list_actioner: :#{column.use_none? ? 'none' : 'many'}#{', confirm: :' + column.options[:confirm].to_s + '.t(scope: "labels")' if column.options[:confirm]}})"
|
287
287
|
end
|
288
288
|
actioner << " + '</span>"
|
289
289
|
code << "'#{actioner}'"
|
@@ -297,7 +297,7 @@ module ActiveList
|
|
297
297
|
last_page = "#{var_name(:last)}"
|
298
298
|
|
299
299
|
pagination << "<span class=\"pagination\">"
|
300
|
-
pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + 1), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>"
|
300
|
+
pagination << "<span class=\"status\">' + 'list.pagination.x_to_y_of_total'.t(x: (#{var_name(:offset)} + (#{var_name(:count)} > 0 ? 1 : 0)), y: ((#{var_name(:last)} == #{var_name(:page)}) ? #{var_name(:count)} : #{var_name(:offset)} + #{var_name(:limit)}), total: #{var_name(:count)}) + '</span>"
|
301
301
|
|
302
302
|
pagination << "<span class=\"paginator\">"
|
303
303
|
|
data/lib/active_list/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-05-
|
12
|
+
date: 2014-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|