manage 1.3.10 → 1.3.11
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 +4 -4
- data/app/controllers/manage/resource_controller.rb +10 -1
- data/app/helpers/manage/application_helper.rb +38 -0
- data/app/helpers/manage/resource_helper.rb +18 -6
- data/app/views/manage/resource/edit.html.slim +3 -2
- data/app/views/manage/resource/index/_table.html.slim +1 -0
- data/app/views/manage/resource/show.html.slim +4 -3
- data/lib/manage/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: 21c3d5c131a6c25bf593aa26365e889a98bc890f
|
4
|
+
data.tar.gz: d73dbf2600dc124980aa35d6ed0abf36af33bbae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f341d89f133e308df43dc5d5333616471990882741bb345eabf3f1456f9402dce2a121fc9652576a90236b916da272527e6ace6a6d6c8199fe7c1571c661f0
|
7
|
+
data.tar.gz: f60fd459dc8af1f10e2ec36c96f921d4fe668dc3d6693bb0821cd4450f01d5d869dcf24938aebfbd524c3b2d5cca090fab4155b700c06eb3e61f26b45d5aab20
|
@@ -12,7 +12,7 @@ class Manage::ResourceController < Manage::ApplicationController
|
|
12
12
|
|
13
13
|
respond_to :html
|
14
14
|
|
15
|
-
helper_method :list_index_fields, :list_edit_fields, :list_search_fields, :list_action_links
|
15
|
+
helper_method :list_index_fields, :list_edit_fields, :list_search_fields, :list_action_links, :resource_actions
|
16
16
|
|
17
17
|
def end_of_association_chain
|
18
18
|
if self.resources_configuration[:self][:search_fields].blank?
|
@@ -84,6 +84,15 @@ class Manage::ResourceController < Manage::ApplicationController
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
#
|
88
|
+
# This doubles the list_action_links.
|
89
|
+
# It provides actions on existing resource.
|
90
|
+
# actions are used in index/show/edit screens
|
91
|
+
# returns html string
|
92
|
+
def resource_actions resource
|
93
|
+
nil
|
94
|
+
end
|
95
|
+
|
87
96
|
private
|
88
97
|
def self.setup_fields(key, *fields)
|
89
98
|
# :all means all the fields - default
|
@@ -1,4 +1,42 @@
|
|
1
1
|
module Manage
|
2
2
|
module ApplicationHelper
|
3
|
+
|
4
|
+
def collection_table collection, resource_class, no_items_text
|
5
|
+
|
6
|
+
if collection.empty?
|
7
|
+
return content_tag(:h3, resource_class.model_name.human(count: 2)) + content_tag(:p, no_items_text)
|
8
|
+
else
|
9
|
+
rows = []
|
10
|
+
|
11
|
+
ths = resource_class.attribute_names.collect do |attr|
|
12
|
+
content_tag(:td, truncate(resource_class.human_attribute_name(attr).to_s, length: 50))
|
13
|
+
end.join('').html_safe
|
14
|
+
rows << content_tag(:tr, ths)
|
15
|
+
|
16
|
+
collection.each do |item|
|
17
|
+
tds = resource_class.attribute_names.collect do |attr|
|
18
|
+
content_tag(:td, truncate(item.public_send(attr).to_s, length: 50))
|
19
|
+
end.join('').html_safe
|
20
|
+
|
21
|
+
rows << content_tag(:tr, tds)
|
22
|
+
end
|
23
|
+
content_tag(:h3, resource_class.model_name.human(count: 2)) +
|
24
|
+
content_tag(:table, rows.join('').html_safe)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def condensed_table resource_class, cols=2
|
29
|
+
rows = []
|
30
|
+
resource_class.attribute_names.each_slice(cols).each do |slice|
|
31
|
+
row = slice.collect do |attr|
|
32
|
+
content_tag(:td, resource_class.human_attribute_name(attr)) +
|
33
|
+
content_tag(:td, resource.public_send(attr))
|
34
|
+
end
|
35
|
+
rows << content_tag(:tr, row.join('').html_safe)
|
36
|
+
end
|
37
|
+
|
38
|
+
content_tag :table, rows.join('').html_safe
|
39
|
+
end
|
40
|
+
|
3
41
|
end
|
4
42
|
end
|
@@ -20,10 +20,25 @@ module Manage
|
|
20
20
|
Fields::Reader.field_title(resource_class, field_data)
|
21
21
|
end
|
22
22
|
|
23
|
+
|
24
|
+
#
|
25
|
+
# to customise the actions for a resource define a list of actions
|
26
|
+
#
|
27
|
+
# example:
|
28
|
+
# action_links :posts, :tickets, ->(resource) {link_to "#{resource.name}"}
|
29
|
+
#
|
30
|
+
# @param scope [type] [description]
|
31
|
+
# @param link_data [type] [description]
|
32
|
+
#
|
33
|
+
# @return [type] [description]
|
23
34
|
def action_link(scope, link_data)
|
24
35
|
value = nil
|
36
|
+
case link_data
|
37
|
+
|
38
|
+
when Proc
|
39
|
+
value = link_data.call(scope)
|
25
40
|
|
26
|
-
|
41
|
+
when Hash
|
27
42
|
relation = link_data.keys.first
|
28
43
|
entity = Fields::Reader.field_value(scope, relation)
|
29
44
|
unless entity.present?
|
@@ -37,9 +52,8 @@ module Manage
|
|
37
52
|
|
38
53
|
path = entity.class.name.dasherize.pluralize.downcase
|
39
54
|
return link_to value, [scope.public_send(relation)]
|
40
|
-
end
|
41
55
|
|
42
|
-
|
56
|
+
when *[Symbol, String]
|
43
57
|
relation = link_data.to_s
|
44
58
|
assocation = scope.class.reflect_on_association(link_data.to_sym)
|
45
59
|
raise "assocation #{link_data} not found on #{scope.class}" unless assocation
|
@@ -53,9 +67,7 @@ module Manage
|
|
53
67
|
key = scope.class.name.downcase.dasherize + '_id'
|
54
68
|
end
|
55
69
|
return "<a href=\"#{relation}?f%5B#{key}%5D=#{scope.id}\">#{resource_class.human_attribute_name(link_data.to_s)}</a>".html_safe
|
56
|
-
|
57
|
-
|
58
|
-
unless value
|
70
|
+
else
|
59
71
|
raise 'Unsupported link data'
|
60
72
|
end
|
61
73
|
|
@@ -2,8 +2,9 @@ h2 = t('manage.edit.title', model: resource_class.model_name.human)
|
|
2
2
|
|
3
3
|
nav
|
4
4
|
/ = link_to 'index', collection_url
|
5
|
-
|
6
|
-
|
5
|
+
= [ link_to(t('manage.actions.index', model: resource_class.model_name.human(count: 2)), resource.class, class: 'button small secondary'),
|
6
|
+
resource_actions(resource),
|
7
|
+
].compact.join(' '.html_safe)
|
7
8
|
|
8
9
|
.row
|
9
10
|
.columns.large-6
|
@@ -1,7 +1,8 @@
|
|
1
1
|
nav
|
2
|
-
= link_to
|
3
|
-
|
4
|
-
|
2
|
+
= [ link_to(t('manage.actions.index', model: resource_class.model_name.human(count: 2)), resource.class, class: 'button small secondary'),
|
3
|
+
link_to(t('manage.actions.edit'), [:edit, resource], class: 'button small'),
|
4
|
+
resource_actions(resource),
|
5
|
+
].compact.join(' '.html_safe)
|
5
6
|
|
6
7
|
article
|
7
8
|
dl
|
data/lib/manage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: manage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Empower United
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|