ecm_downloads2 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +9 -0
- data/app/decorators/ecm/downloads/download_category_decorator.rb +12 -1
- data/app/decorators/ecm/downloads/download_decorator.rb +4 -0
- data/app/helpers/ecm/downloads/download_category_helper.rb +9 -2
- data/app/helpers/ecm/downloads/download_helper.rb +9 -2
- data/app/models/ecm/downloads/download.rb +2 -2
- data/app/models/ecm/downloads/download_category.rb +0 -26
- data/app/views/ecm/downloads/download_categories/_download_category.html.erb +3 -3
- data/app/views/ecm/downloads/download_categories/_table.html.erb +1 -1
- data/app/views/ecm/downloads/download_categories/show.html.erb +1 -1
- data/app/views/ecm/downloads/downloads/_download.html.erb +1 -1
- data/app/views/ecm/downloads/downloads/_table_in_download_category.html.erb +12 -0
- data/config/locales/ecm.downloads.download.de.yml +2 -0
- data/config/locales/ecm.downloads.download.en.yml +2 -0
- data/config/locales/ecm.downloads.download_category.de.yml +1 -0
- data/config/locales/ecm.downloads.download_category.en.yml +1 -0
- data/lib/ecm/downloads/active_admin/ecm_downloads_download_categories.rb +4 -2
- data/lib/ecm/downloads/active_admin/ecm_downloads_downloads.rb +34 -0
- data/lib/ecm/downloads/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: 9e98577d017dc309342a2f23200aae085cbd737e
|
4
|
+
data.tar.gz: e1af520faeaffc7b564967af5019df69053aca30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3276c76926725bfd84f43f8609c44dab7e68b00ad7247fbf0b36e4b309c7d3650e31d4c09ed5a8067bce603815cfe181a173604450cd98d0908482889cdf76ed
|
7
|
+
data.tar.gz: 806c4ebc0a10b0a5a29787e9b7e18745027a97e5df9e899dca5a4dfb9dd96f2aeed8bdc20daf160172bf7083cf536c7db898af4ba738cc52e771ad9139e21f84
|
data/README.rdoc
CHANGED
@@ -38,6 +38,15 @@ Add the routes:
|
|
38
38
|
# config/routes.rb
|
39
39
|
Ecm::Downloads::Routing.routes(self)
|
40
40
|
|
41
|
+
Add the helpers to your application controller:
|
42
|
+
|
43
|
+
# app/controllers/application_controller.rb
|
44
|
+
class ApplicationController < ActionController::Base
|
45
|
+
helper Ecm::Downloads::DownloadCategoryHelper
|
46
|
+
helper Ecm::Downloads::DownloadHelper
|
47
|
+
...
|
48
|
+
end
|
49
|
+
|
41
50
|
== Optional: Generate locale files
|
42
51
|
|
43
52
|
You may want to copy the locales to your app:
|
@@ -1,8 +1,11 @@
|
|
1
1
|
module Ecm::Downloads
|
2
2
|
class DownloadCategoryDecorator < Draper::Decorator
|
3
|
-
# delegate :root?, :parent_id, :persisted?
|
4
3
|
delegate_all
|
5
4
|
|
5
|
+
def display_code
|
6
|
+
"<%= render_download_category '#{name}' %>"
|
7
|
+
end
|
8
|
+
|
6
9
|
def ecm_downloads_downloads_count_label
|
7
10
|
h.content_tag(:span, ecm_downloads_downloads_count, class: 'badge')
|
8
11
|
end
|
@@ -14,5 +17,13 @@ module Ecm::Downloads
|
|
14
17
|
def tree_name
|
15
18
|
name
|
16
19
|
end
|
20
|
+
|
21
|
+
def index_name
|
22
|
+
if self.root?
|
23
|
+
"[#{self.locale}] #{self.name}"
|
24
|
+
else
|
25
|
+
"#{'    ' * self.level} |-- #{self.name}".html_safe
|
26
|
+
end
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
@@ -1,11 +1,18 @@
|
|
1
1
|
module Ecm::Downloads
|
2
2
|
module DownloadCategoryHelper
|
3
3
|
def render_download_category(download_category_name, options = {})
|
4
|
-
download_category = DownloadCategory.where(:name => download_category_name).first
|
4
|
+
download_category = DownloadCategory.where(:name => download_category_name).first.decorate
|
5
5
|
if download_category.nil?
|
6
6
|
I18n.t('ecm.downloads.download_category.messages.not_found', :name => download_category_name)
|
7
7
|
else
|
8
|
-
|
8
|
+
begin
|
9
|
+
o = '<notextile>'
|
10
|
+
o << render(download_category)
|
11
|
+
o << '</notextile>'
|
12
|
+
return o.html_safe
|
13
|
+
rescue => e
|
14
|
+
raise e
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -1,11 +1,18 @@
|
|
1
1
|
module Ecm::Downloads
|
2
2
|
module DownloadHelper
|
3
3
|
def render_download(download_name, options = {})
|
4
|
-
download = Download.where(:name => download_name).first
|
4
|
+
download = Download.where(:name => download_name).first.decorate
|
5
5
|
if download.nil?
|
6
6
|
I18n.t('ecm.downloads.download.messages.not_found', :name => download_name)
|
7
7
|
else
|
8
|
-
|
8
|
+
begin
|
9
|
+
o = '<notextile>'
|
10
|
+
o << render(download)
|
11
|
+
o << '</notextile>'
|
12
|
+
return o.html_safe
|
13
|
+
rescue => e
|
14
|
+
raise e
|
15
|
+
end
|
9
16
|
end
|
10
17
|
end
|
11
18
|
end
|
@@ -70,7 +70,7 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
70
70
|
validates :name, :presence => true
|
71
71
|
validates_attachment :asset, presence => true
|
72
72
|
do_not_validate_attachment_file_type :asset
|
73
|
-
|
73
|
+
|
74
74
|
|
75
75
|
def human
|
76
76
|
name
|
@@ -80,8 +80,8 @@ class Ecm::Downloads::Download < ActiveRecord::Base
|
|
80
80
|
human
|
81
81
|
end
|
82
82
|
|
83
|
-
# private methods
|
84
83
|
private
|
84
|
+
|
85
85
|
def fix_updated_position
|
86
86
|
Rails.logger.debug "Fixing positions for #{self.to_s} (Moving to last)"
|
87
87
|
add_to_list_bottom
|
@@ -43,37 +43,11 @@ class Ecm::Downloads::DownloadCategory < ActiveRecord::Base
|
|
43
43
|
validates :locale, :absence => true,
|
44
44
|
:unless => :root?
|
45
45
|
|
46
|
-
# public methods
|
47
|
-
|
48
|
-
# public methods
|
49
|
-
|
50
|
-
def display_code
|
51
|
-
"<%= render_download_category '#{self.name}' %>"
|
52
|
-
end
|
53
|
-
|
54
46
|
def human
|
55
47
|
name
|
56
48
|
end
|
57
49
|
|
58
|
-
def index_name
|
59
|
-
if self.root?
|
60
|
-
"[#{self.locale}] #{self.name}"
|
61
|
-
else
|
62
|
-
"#{'    ' * self.level} |-- #{self.name}".html_safe
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
50
|
def to_s
|
67
51
|
name
|
68
52
|
end
|
69
|
-
|
70
|
-
# def tree_name
|
71
|
-
# root_prefix = (self.root?) ? "[#{self.locale}] " : ""
|
72
|
-
|
73
|
-
# if ecm_downloads_downloads_count < 1
|
74
|
-
# "#{root_prefix}#{to_s}"
|
75
|
-
# else
|
76
|
-
# "#{root_prefix}#{to_s} (#{ecm_downloads_downloads_count})"
|
77
|
-
# end
|
78
|
-
# end
|
79
53
|
end
|
@@ -7,14 +7,14 @@
|
|
7
7
|
</div>
|
8
8
|
<% end %>
|
9
9
|
|
10
|
-
<%= render partial: 'table', locals: { download_categories: Ecm::Downloads::DownloadCategoryDecorator.decorate_collection(download_category.descendants) } %>
|
10
|
+
<%= render partial: 'ecm/downloads/download_categories/table', locals: { download_categories: Ecm::Downloads::DownloadCategoryDecorator.decorate_collection(download_category.descendants) } %>
|
11
11
|
|
12
12
|
<div class="download_category-downloads item_list">
|
13
|
-
|
13
|
+
|
14
14
|
<% if download_category.ecm_downloads_downloads.published.count == 0 %>
|
15
15
|
<p><%= t('ecm.downloads.download_category.messages.no_downloads_available') %></p>
|
16
16
|
<% else %>
|
17
|
-
<%= render partial: 'ecm/downloads/downloads/
|
17
|
+
<%= render partial: 'ecm/downloads/downloads/table_in_download_category', locals: { downloads: download_category.ecm_downloads_downloads.published } %>
|
18
18
|
<% end %>
|
19
19
|
</div>
|
20
20
|
</div>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div class="table-responsive">
|
2
2
|
<table class="<%= Ecm::Downloads::Configuration.download_categories_table_classes %>">
|
3
3
|
<tbody>
|
4
|
-
<%= render partial: 'download_category_in_table', collection: download_categories, as: :download_category %>
|
4
|
+
<%= render partial: 'ecm/downloads/download_categories/download_category_in_table', collection: download_categories, as: :download_category %>
|
5
5
|
</tbody>
|
6
6
|
</table>
|
7
7
|
</div>
|
@@ -4,6 +4,6 @@
|
|
4
4
|
<% if @download_category.root? %>
|
5
5
|
<%= link_to(t('ecm.downloads.download_category.actions.back_to_index'), ecm_downloads_download_categories_path, class: 'btn btn-default') if respond_to?(:ecm_downloads_download_categories_path) %>
|
6
6
|
<% else %>
|
7
|
-
<%= link_to(
|
7
|
+
<%= link_to(t('ecm.downloads.views.actions.back'), @download_category.parent, class: 'btn btn-default') %>
|
8
8
|
<% end %>
|
9
9
|
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="panel panel-primary">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h3 class="panel-title"><%= Ecm::Downloads::DownloadCategory.human_attribute_name(:ecm_downloads_downloads) %></h3>
|
4
|
+
</div>
|
5
|
+
<div class="table-responsive">
|
6
|
+
<table class="<%= Ecm::Downloads::Configuration.downloads_table_classes %>">
|
7
|
+
<tbody>
|
8
|
+
<%= render partial: 'ecm/downloads/downloads/download_in_table', collection: downloads, as: :download %>
|
9
|
+
</tbody>
|
10
|
+
</table>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -3,6 +3,8 @@ if defined?(ActiveAdmin)
|
|
3
3
|
include ActiveAdmin::AwesomeNestedSet::Helper
|
4
4
|
|
5
5
|
ActiveAdmin.register Ecm::Downloads::DownloadCategory do
|
6
|
+
decorate_with Ecm::Downloads::DownloadCategoryDecorator
|
7
|
+
|
6
8
|
# menu entry settings
|
7
9
|
menu :parent => I18n.t('ecm.downloads.active_admin.menu')
|
8
10
|
|
@@ -41,7 +43,7 @@ if defined?(ActiveAdmin)
|
|
41
43
|
f.inputs do
|
42
44
|
f.semantic_errors *f.object.errors.keys
|
43
45
|
end
|
44
|
-
|
46
|
+
|
45
47
|
f.inputs do
|
46
48
|
f.input :parent, :as => :select,
|
47
49
|
:collection => nested_set_options(Ecm::Downloads::DownloadCategory, f.object) { |dc| "#{'-' * dc.depth} #{dc.name}" }
|
@@ -104,7 +106,7 @@ if defined?(ActiveAdmin)
|
|
104
106
|
|
105
107
|
panel Ecm::Downloads::DownloadCategory.human_attribute_name(:link) do
|
106
108
|
div do
|
107
|
-
ecm_downloads_download_category_path(
|
109
|
+
ecm_downloads_download_category_path(ecm_downloads_download_category)
|
108
110
|
end
|
109
111
|
end
|
110
112
|
|
@@ -2,6 +2,8 @@ include ActiveAdmin::ActsAsList::Helper
|
|
2
2
|
include ActsAsPublished::ActiveAdminHelper
|
3
3
|
|
4
4
|
ActiveAdmin.register Ecm::Downloads::Download do
|
5
|
+
decorate_with Ecm::Downloads::DownloadDecorator
|
6
|
+
|
5
7
|
# acts as list
|
6
8
|
sortable_member_actions
|
7
9
|
|
@@ -46,4 +48,36 @@ ActiveAdmin.register Ecm::Downloads::Download do
|
|
46
48
|
column :created_at
|
47
49
|
actions
|
48
50
|
end
|
51
|
+
|
52
|
+
show :title => :to_s do
|
53
|
+
attributes_table do
|
54
|
+
row :ecm_downloads_download_category
|
55
|
+
row :name
|
56
|
+
row :published_at
|
57
|
+
row :asset_file_name
|
58
|
+
row :filesize
|
59
|
+
row :asset_content_type
|
60
|
+
row :asset_fingerprint
|
61
|
+
row :created_at
|
62
|
+
row :updated_at
|
63
|
+
end
|
64
|
+
|
65
|
+
panel Ecm::Downloads::Download.human_attribute_name(:description) do
|
66
|
+
div do
|
67
|
+
ecm_downloads_download.description
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
panel Ecm::Downloads::Download.human_attribute_name(:display_code) do
|
72
|
+
div do
|
73
|
+
ecm_downloads_download.display_code
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
panel Ecm::Downloads::Download.human_attribute_name(:link) do
|
78
|
+
div do
|
79
|
+
ecm_downloads_download_path(ecm_downloads_download)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
49
83
|
end if defined?(ActiveAdmin)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ecm_downloads2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -439,6 +439,7 @@ files:
|
|
439
439
|
- app/views/ecm/downloads/downloads/_download.html.erb
|
440
440
|
- app/views/ecm/downloads/downloads/_download_in_table.html.erb
|
441
441
|
- app/views/ecm/downloads/downloads/_table.html.erb
|
442
|
+
- app/views/ecm/downloads/downloads/_table_in_download_category.html.erb
|
442
443
|
- app/views/ecm/downloads/downloads/index.html.erb
|
443
444
|
- app/views/ecm/downloads/downloads/show.html.erb
|
444
445
|
- config/locales/active_admin.patch.de.yml
|