ecm_pictures 1.0.5.pre → 1.0.6.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
1
+ ActiveAdmin.register Ecm::Pictures::AttachedPicture do
2
+ menu false
3
+
4
+ actions :destroy
5
+
6
+ controller do
7
+ def destroy
8
+ destroy! do |format|
9
+ format.html { redirect_to :back }
10
+ end
11
+ end
12
+ end
13
+ end
14
+
@@ -65,18 +65,18 @@ ActiveAdmin.register Ecm::Pictures::PictureGallery do
65
65
  sortable_columns
66
66
  column :thumbnail do |picture|
67
67
  link_to(image_tag(picture.image.url(:default_thumb)), [:admin, picture])
68
- end
68
+ end # column
69
69
  column :name
70
70
  column :image_file_size, :sortable => :image_file_size do |picture|
71
71
  number_to_human_size(picture.image_file_size)
72
- end
72
+ end # column
73
73
  column :created_at
74
74
  column do |picture|
75
75
  link_to(I18n.t('active_admin.view'), [:admin, picture], :class => "member_link view_link") +
76
76
  link_to(I18n.t('active_admin.edit'), [:edit, :admin, picture], :class => "member_link edit_link")
77
- end
78
- end
79
- end
77
+ end # column
78
+ end # table_for
79
+ end # panel
80
80
  end # show
81
81
 
82
82
  sidebar Ecm::Pictures::PictureGallery.human_attribute_name(:details), :only => :show do
@@ -7,6 +7,14 @@ ActiveAdmin.register Ecm::Pictures::Picture do
7
7
  config.sort_order = 'picture_gallery_id, position'
8
8
  sortable_member_actions
9
9
 
10
+ controller do
11
+ def destroy
12
+ destroy! do |format|
13
+ format.html { redirect_to :back }
14
+ end
15
+ end
16
+ end
17
+
10
18
  form :html => { :enctype => "multipart/form-data" } do |f|
11
19
  f.inputs do
12
20
  f.input :picture_gallery
@@ -52,7 +60,19 @@ ActiveAdmin.register Ecm::Pictures::Picture do
52
60
  ecm_pictures_picture.display_code(:textile)
53
61
  end
54
62
  end
55
- end
63
+
64
+ ecm_pictures_picture.attached_pictures.all.group_by(&:pictureable_type).each do |type, attached_pictures|
65
+ panel type.constantize.model_name.human do
66
+ table_for attached_pictures.map(&:pictureable) do
67
+ column :to_s
68
+ column do |obj|
69
+ link_to(I18n.t('active_admin.view'), [:admin, obj], :class => "member_link view_link") +
70
+ link_to(I18n.t('active_admin.edit'), [:edit, :admin, obj], :class => "member_link edit_link")
71
+ end # column
72
+ end # table_for
73
+ end # panel
74
+ end # each
75
+ end # show
56
76
 
57
77
  sidebar Ecm::Pictures::Picture.human_attribute_name(:details), :only => :show do
58
78
  attributes_table_for ecm_pictures_picture do
@@ -0,0 +1,5 @@
1
+ .picture-gallery .row-fluid [class*="span"] {
2
+ margin-left: 0px;
3
+ margin-right: 1.9%;
4
+ }
5
+
@@ -0,0 +1,16 @@
1
+ module Ecm::Pictures
2
+ class AttachedPicture < ActiveRecord::Base
3
+ self.table_name = 'ecm_pictures_attached_pictures'
4
+
5
+ # associations
6
+ belongs_to :picture, :foreign_key => 'ecm_pictures_picture_id'
7
+ belongs_to :pictureable, :polymorphic => true
8
+
9
+ # attributes
10
+ attr_accessible :ecm_pictures_picture_id
11
+
12
+ # validations
13
+ validates :picture, :pictureable, :presence => true
14
+ end # class AttachedPicture < ActiveRecord::Base
15
+ end# module Ecm::Pictures
16
+
@@ -3,7 +3,7 @@ class Ecm::Pictures::Picture < ActiveRecord::Base
3
3
 
4
4
  # associations
5
5
  belongs_to :picture_gallery, :counter_cache => true
6
-
6
+ has_many :attached_pictures, :foreign_key => 'ecm_pictures_picture_id'
7
7
  # attributes
8
8
  attr_accessible :description,
9
9
  :image,
@@ -0,0 +1,15 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ ecm/pictures/attached_picture:
5
+ one: Verknüpftes Bild
6
+ other: Verknüpfte Bilder
7
+ attributes:
8
+ ecm/pictures/attached_picture:
9
+ picture: Bild
10
+ pictureable: Verknüpft mit
11
+ created_at: Erstellt am
12
+ updated_at: Aktualisiert am
13
+ resources:
14
+ ecm_pictures_pictures: verknuepfte-bilder
15
+
@@ -0,0 +1,15 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ ecm/pictures/attached_picture:
5
+ one: attached picture
6
+ other: attached pictures
7
+ attributes:
8
+ ecm/pictures/attached_picture:
9
+ picture: picture
10
+ pictureable: attached to
11
+ created_at: created at
12
+ updated_at: updated at
13
+ resources:
14
+ ecm_pictures_pictures: attached-pictures
15
+
@@ -1,4 +1,6 @@
1
1
  de:
2
+ active_admin:
3
+ delete_link: "Verknüpfung entfernen"
2
4
  back: Zurück
3
5
  ecm:
4
6
  pictures:
@@ -0,0 +1,10 @@
1
+ class CreateEcmPicturesAttachedPictures < ActiveRecord::Migration
2
+ def change
3
+ create_table :ecm_pictures_attached_pictures do |t|
4
+ t.references :ecm_pictures_picture
5
+ t.references :pictureable, :polymorphic => true
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
10
+
@@ -0,0 +1,53 @@
1
+ require 'active_admin'
2
+
3
+ module Ecm::Pictures
4
+ module ActiveAdmin
5
+ module PictureableHelper
6
+ def form_inputs_for_pictureable(f)
7
+ f.inputs do
8
+ f.has_many :pictures do |p|
9
+ p.input :name
10
+ p.input :image, :as => :file, :hint => p.template.image_tag(p.object.image.url(:default_thumb))
11
+ p.input :description
12
+
13
+ p.inputs do
14
+ p.input :markup_language, :as => :select, :collection => Ecm::Pictures::Configuration.markup_languages
15
+ end # p.inputs
16
+ end # f.has_many :pictures
17
+ end # f.inputs
18
+
19
+ f.inputs do
20
+ f.has_many :attached_pictures do |p|
21
+ p.input :picture, :as => :select, :collection => Ecm::Pictures::Picture.all.collect { |picture| [picture, picture.id, {:style => "background-image: url('#{picture.image.url(:medium_thumb)}'); width: #{Ecm::Pictures::Configuration.picture_image_styles[:medium_thumb].split('x').first}px; height: #{Ecm::Pictures::Configuration.picture_image_styles[:medium_thumb].split('x').last}px; background-repeat: no-repeat; background-position: center;"}] }
22
+ end # f.has_many :attached_pictures
23
+ end # f.inputs
24
+ end # def
25
+
26
+ def panel_for_pictureable
27
+ panel Ecm::Pictures::PictureGallery.human_attribute_name(:pictures) do
28
+ table_for resource.pictures, :i18n => Ecm::Pictures::Picture do
29
+ sortable_columns
30
+ column :thumbnail do |picture|
31
+ link_to(image_tag(picture.image.url(:default_thumb)), [:admin, picture])
32
+ end # column
33
+ column :name
34
+ column :image_file_size, :sortable => :image_file_size do |picture|
35
+ number_to_human_size(picture.image_file_size)
36
+ end # column
37
+ column :created_at
38
+ column do |picture|
39
+ link_to(I18n.t('active_admin.view'), [:admin, picture], :class => "member_link view_link") +
40
+ link_to(I18n.t('active_admin.edit'), [:edit, :admin, picture], :class => "member_link edit_link") +
41
+ link_to(I18n.t('active_admin.delete'), [:admin, picture], :class => "member_link delete_link", :method => :delete) +
42
+ link_to(I18n.t('active_admin.delete_link'), [:admin, picture.attached_pictures.where(:pictureable_type => resource.class, :pictureable_id => resource).first], :class => "member_link delete_link", :method => :delete)
43
+ end # column
44
+ end # table_for
45
+ end # panel
46
+ end # def
47
+ end # module PictureableHelper
48
+ end # module ActiveAdmin
49
+ end # module Ecm::Pictures
50
+
51
+ ::ActiveAdmin::ResourceDSL.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
52
+ ::ActiveAdmin::Views::Pages::Show.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
53
+ ::ActiveAdmin::Views::Pages::Form.send :include, Ecm::Pictures::ActiveAdmin::PictureableHelper
@@ -2,9 +2,9 @@ module Ecm
2
2
  module Pictures
3
3
  class Engine < Rails::Engine
4
4
  initializer :ecm_pictures_engine do
5
- ActiveAdmin.setup do |active_admin_config|
6
- active_admin_config.load_paths += Dir[File.dirname(__FILE__) + '/active_admin']
7
- end if defined?(ActiveAdmin)
5
+ ::ActiveAdmin.setup do |config|
6
+ config.load_paths << File.join(self.root, 'app/admin')
7
+ end
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,6 @@
1
1
  module Ecm
2
2
  module Pictures
3
- VERSION = "1.0.5.pre"
4
- end
3
+ VERSION = "1.0.6.pre"
4
+ end
5
5
  end
6
+
data/lib/ecm_pictures.rb CHANGED
@@ -8,6 +8,7 @@ require 'ecm/pictures/engine'
8
8
  require 'ecm/pictures/configuration'
9
9
  require 'ecm/pictures/routing'
10
10
  require 'ecm/pictures/version'
11
+ require 'ecm/pictures/active_admin/pictureable_helper'
11
12
 
12
13
  module Ecm
13
14
  module Pictures
@@ -10,6 +10,9 @@ module Ecm
10
10
  copy_file "ecm.pictures.en.yml", "config/locales/ecm.pictures.en.yml"
11
11
  copy_file "ecm.pictures.de.yml", "config/locales/ecm.pictures.de.yml"
12
12
 
13
+ copy_file "ecm.pictures.attached_picture.en.yml", "config/locales/ecm.pictures.attached_picture.en.yml"
14
+ copy_file "ecm.pictures.attached_picture.de.yml", "config/locales/ecm.pictures.attached_picture.de.yml"
15
+
13
16
  copy_file "ecm.pictures.picture.en.yml", "config/locales/ecm.pictures.picture.en.yml"
14
17
  copy_file "ecm.pictures.picture.de.yml", "config/locales/ecm.pictures.picture.de.yml"
15
18
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_pictures
3
3
  version: !ruby/object:Gem::Version
4
- hash: 961915968
4
+ hash: 961915980
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
9
+ - 6
10
10
  - pre
11
- version: 1.0.5.pre
11
+ version: 1.0.6.pre
12
12
  platform: ruby
13
13
  authors:
14
14
  - Roberto Vasquez Angel
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-03-27 00:00:00 Z
19
+ date: 2014-02-07 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: rails
@@ -26,12 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- hash: 25
29
+ hash: 21
30
30
  segments:
31
31
  - 3
32
32
  - 2
33
- - 11
34
- version: 3.2.11
33
+ - 13
34
+ version: 3.2.13
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -227,12 +227,14 @@ dependencies:
227
227
  requirement: &id015 !ruby/object:Gem::Requirement
228
228
  none: false
229
229
  requirements:
230
- - - ">="
230
+ - - <
231
231
  - !ruby/object:Gem::Version
232
- hash: 3
232
+ hash: 11
233
233
  segments:
234
+ - 2
235
+ - 1
234
236
  - 0
235
- version: "0"
237
+ version: 2.1.0
236
238
  type: :development
237
239
  version_requirements: *id015
238
240
  - !ruby/object:Gem::Dependency
@@ -296,7 +298,7 @@ dependencies:
296
298
  type: :development
297
299
  version_requirements: *id019
298
300
  - !ruby/object:Gem::Dependency
299
- name: guard-rspec
301
+ name: guard-rails
300
302
  prerelease: false
301
303
  requirement: &id020 !ruby/object:Gem::Requirement
302
304
  none: false
@@ -310,7 +312,7 @@ dependencies:
310
312
  type: :development
311
313
  version_requirements: *id020
312
314
  - !ruby/object:Gem::Dependency
313
- name: guard-bundler
315
+ name: guard-rspec
314
316
  prerelease: false
315
317
  requirement: &id021 !ruby/object:Gem::Requirement
316
318
  none: false
@@ -323,6 +325,20 @@ dependencies:
323
325
  version: "0"
324
326
  type: :development
325
327
  version_requirements: *id021
328
+ - !ruby/object:Gem::Dependency
329
+ name: guard-bundler
330
+ prerelease: false
331
+ requirement: &id022 !ruby/object:Gem::Requirement
332
+ none: false
333
+ requirements:
334
+ - - ">="
335
+ - !ruby/object:Gem::Version
336
+ hash: 3
337
+ segments:
338
+ - 0
339
+ version: "0"
340
+ type: :development
341
+ version_requirements: *id022
326
342
  description: Provides picture galleries for active admin.
327
343
  email:
328
344
  - roberto@vasquez-angel.de
@@ -345,23 +361,30 @@ files:
345
361
  - app/views/ecm/pictures/pictures/show.html.erb
346
362
  - app/views/ecm/pictures/pictures/_picture_for_gallery.html.erb
347
363
  - app/views/ecm/pictures/pictures/index.html.erb
364
+ - app/models/ecm/pictures/attached_picture.rb
348
365
  - app/models/ecm/pictures/picture_gallery.rb
349
366
  - app/models/ecm/pictures/picture.rb
367
+ - app/admin/ecm_pictures_picture_galleries.rb
368
+ - app/admin/ecm_pictures_pictures.rb
369
+ - app/admin/ecm_pictures_attached_pictures.rb
370
+ - app/assets/stylesheets/ecm_pictures.css.less
371
+ - config/locales/ecm.pictures.attached_picture.en.yml
350
372
  - config/locales/ecm.pictures.picture_gallery.de.yml
351
373
  - config/locales/ecm.pictures.de.yml
374
+ - config/locales/ecm.pictures.attached_picture.de.yml
352
375
  - config/locales/ecm.pictures.picture.de.yml
353
376
  - config/locales/ecm.pictures.picture.en.yml
354
377
  - config/locales/ecm.pictures.en.yml
355
378
  - config/locales/ecm.pictures.picture_gallery.en.yml
356
379
  - db/migrate/002_create_ecm_pictures_pictures.rb
357
380
  - db/migrate/001_create_ecm_pictures_picture_galleries.rb
381
+ - db/migrate/003_create_ecm_pictures_attached_pictures.rb
358
382
  - lib/generators/ecm/pictures/locales/locales_generator.rb
359
383
  - lib/generators/ecm/pictures/install/install_generator.rb
360
384
  - lib/generators/ecm/pictures/install/templates/ecm_pictures.rb
361
385
  - lib/tasks/ecm_pictures_tasks.rake
362
386
  - lib/ecm_pictures.rb
363
- - lib/ecm/pictures/active_admin/ecm_pictures_picture_galleries.rb
364
- - lib/ecm/pictures/active_admin/ecm_pictures_pictures.rb
387
+ - lib/ecm/pictures/active_admin/pictureable_helper.rb
365
388
  - lib/ecm/pictures/engine.rb
366
389
  - lib/ecm/pictures/version.rb
367
390
  - lib/ecm/pictures/routing.rb