ecm_pictures2_backend 3.2.0 → 3.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b9cf1131af3dc346a6e1a627471b2a157bfe1d3
4
- data.tar.gz: c18acd53df03a461ffad0d239dc4a49dd9a3296a
3
+ metadata.gz: 4e34db79ab78f1d829cae81c7b8d7d19ae57a33c
4
+ data.tar.gz: 2a25ce6e82d1b243dd86d1ac4fe5ccce1bff0678
5
5
  SHA512:
6
- metadata.gz: 9222f4cab585e8d1e705c065ed04e77b5a3ef3556c29373a2aee7e40a6e26230be72324521622a360fbdaf9d548d5f6436111b85de683aa091bdf4d01ad55a62
7
- data.tar.gz: 9c717864e2192223fcc06044dc687d1f8f0ae896ee5d12d637b00726b4b6c407e1dc726bda5130ff975959cc1f87d30560976cbb76533abe579dbfab33ebfea6
6
+ metadata.gz: 6e65e8f5c05cd16cc26d6c492e37ad39b91feda7e282ebceb75233093ee7211eaac80e4fbe1b9906edc7ed751ccbf5d3bab23dc54b8509a313363cc501131e84
7
+ data.tar.gz: 38b5631ba0c2862e3ab5bea37c2d4016a5c8c9ae33877e21a54819327ad97602e47bc42f7363c26628f9993adf21b63e479ad42626e20480bfb45d3d8de95156
@@ -1,4 +1,8 @@
1
1
  class Ecm::Pictures::Backend::GalleriesController < Itsf::Backend::Resource::BaseController
2
+ include ResourcesController::Sorting
3
+ include ResourcesController::ActsAsListConcern
4
+ include ResourcesController::ActsAsPublishedConcern
5
+
2
6
  def self.resource_class
3
7
  Ecm::Pictures::Gallery
4
8
  end
@@ -8,6 +12,6 @@ class Ecm::Pictures::Backend::GalleriesController < Itsf::Backend::Resource::Bas
8
12
  def permitted_params
9
13
  params
10
14
  .require(:gallery)
11
- .permit(:name, :markup_language, :description, :link_images, :tag_list, picture_images: [])
15
+ .permit(:name, :markup_language, :description, :link_images, :tag_list, :published, picture_images: [])
12
16
  end
13
17
  end
@@ -1,53 +1,46 @@
1
- class Ecm::Pictures::Backend::PicturesController < Itsf::Backend::Resource::BaseController
2
- module ColumnsHashFix
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- before_action :fix_columns_hash, only: [:update]
7
- end
8
-
9
- private
10
-
11
- def fix_columns_hash
12
- # @todo Find out what is causing the loss of columns in columns_hash
13
- resource_class.reset_column_information
14
- end
15
- end
16
-
17
- include ColumnsHashFix
18
-
19
- def self.resource_class
20
- Ecm::Pictures::Picture
21
- end
22
-
23
- private
24
-
25
- def collection_scope
26
- super.includes(:gallery)
27
- end
28
-
29
- def extract_image_base64(encoded_image)
30
- decoded_image = Base64.decode64(encoded_image.gsub(/^data\:image\/\w+\;base64\,/, '')).force_encoding('UTF-8')
31
- content_type = encoded_image.split(';').first.split(':').last
32
- basename = 'image'
33
- extension = '.jpg'
34
-
35
- image = Tempfile.new([basename, extension])
36
- image.write decoded_image
37
- image.rewind
38
- image
39
- end
40
-
41
- def permitted_params
42
- processed_params = params.deep_dup
43
- image_base64 = processed_params[:picture].try(:delete, :image_base64)
44
-
45
- p = processed_params.require(:picture).permit(:gallery_id, :name, :markup_language, :description, :tag_list, :image)
46
-
47
- if image_base64.present?
48
- p.merge(image: extract_image_base64(image_base64) )
49
- else
50
- p
1
+ module Ecm
2
+ module Pictures
3
+ module Backend
4
+ class PicturesController < Itsf::Backend::Resource::BaseController
5
+ include ResourcesController::Sorting
6
+ include ResourcesController::ActsAsListConcern
7
+ include ResourcesController::ActsAsPublishedConcern
8
+
9
+ def self.resource_class
10
+ Ecm::Pictures::Picture
11
+ end
12
+
13
+ private
14
+
15
+ def load_collection_scope
16
+ super.includes(:gallery)
17
+ end
18
+
19
+ def extract_image_base64(encoded_image)
20
+ decoded_image = Base64.decode64(encoded_image.gsub(/^data\:image\/\w+\;base64\,/, '')).force_encoding('UTF-8')
21
+ content_type = encoded_image.split(';').first.split(':').last
22
+ basename = 'image'
23
+ extension = '.jpg'
24
+
25
+ image = Tempfile.new([basename, extension])
26
+ image.write decoded_image
27
+ image.rewind
28
+ image
29
+ end
30
+
31
+ def permitted_params
32
+ processed_params = params.deep_dup
33
+ image_base64 = processed_params[:picture].try(:delete, :image_base64)
34
+
35
+ p = processed_params.require(:picture).permit(:gallery_id, :name, :markup_language, :description, :tag_list, :image, :published)
36
+
37
+ if image_base64.present?
38
+ p.merge(image: extract_image_base64(image_base64))
39
+ else
40
+ p
41
+ end
42
+ end
43
+ end
51
44
  end
52
45
  end
53
46
  end
@@ -7,6 +7,7 @@
7
7
 
8
8
  .well
9
9
  = form.input :link_images
10
+ = form.input :published, as: :boolean
10
11
 
11
12
  .well
12
13
  = form.input :picture_images, as: :file, input_html: { multiple: 'multiple' }
@@ -4,7 +4,7 @@
4
4
  = table.row :pictures_count
5
5
  = table.row :position
6
6
  = table.row :markup_language
7
- = table.row :markup_language
7
+ = table.row :published
8
8
  = table.row(:tenant, as: :association) if table.resource.respond_to?(:tenant)
9
9
  = table.row(:tag_list) if table.resource.respond_to?(:tag_list)
10
10
  = table.row :display_code_for_erb
@@ -1,6 +1,10 @@
1
- = table.column :name, sortable: true, class: 'truncate-chars truncate-chars-30'
2
- = table.column :description, sortable: true, class: 'truncate-chars truncate-chars-30'
3
- = table.column :link_images, sortable: true
4
- = table.column :pictures_count, sortable: true do |gallery|
5
- %span.label.label-default= gallery.pictures_count
6
- = table.timestamps
1
+ = table.acts_as_list_actions
2
+ = table.column :name, sort: true, class: 'truncate-chars truncate-chars-30'
3
+ = table.column :description, sort: true, class: 'truncate-chars truncate-chars-30'
4
+ = table.boolean :link_images, sort: true
5
+ = table.column :pictures_count do |gallery|
6
+ - capture_haml do
7
+ %span.label.label-default
8
+ = gallery.pictures_count
9
+ = table.timestamps(sort: true)
10
+ = table.acts_as_published_actions
@@ -8,6 +8,9 @@
8
8
  = form.input :markup_language, collection: Ecm::Pictures::markup_languages
9
9
  = form.input :description, input_html: { 'data-add-editor': Itsf::Backend.features?(:'ace-rails-ap'), 'data-editor-syntax': :textile }
10
10
 
11
+ .well
12
+ = form.input :published, as: :boolean
13
+
11
14
  .well
12
15
  = form.input :image
13
16
  = image_tag(form.object.image.url(:default_thumb)) if form.object.image.present?
@@ -12,5 +12,6 @@
12
12
  = table.row :tag_list
13
13
  = table.row :display_code_for_textile
14
14
  = table.row :display_code_for_erb
15
+ = table.row :published
15
16
  = table.row :created_at
16
17
  = table.row :updated_at
@@ -1,7 +1,12 @@
1
- = table.association :gallery # , sortable: :gallery_name
1
+ = table.acts_as_list_actions
2
+ = table.association :gallery, sort: { column_name: 'ecm_pictures_galleries.name' }
2
3
  = table.column(:preview_picture) do |picture|
3
- %img.img-responsive.bottom-margin-2{ src: picture.image.url(:default_thumb) }
4
- = table.column :name, sortable: true, class: 'truncate-chars truncate-chars-30'
5
- = table.column :description, sortable: true, class: 'truncate-chars truncate-chars-30'
6
- = table.column(:image_file_size, sortable: true) { |picture| number_to_human_size(picture.image_file_size) }
7
- = table.timestamps
4
+ - capture_haml do
5
+ %img.img-responsive.bottom-margin-2{ src: picture.image.url(:default_thumb) }
6
+ = table.column :name, sort: true, class: 'truncate-chars truncate-chars-30'
7
+ = table.column :description, sort: true, class: 'truncate-chars truncate-chars-30'
8
+ = table.column(:image_file_size, sort: true) do |picture|
9
+ - capture_haml do
10
+ = number_to_human_size(picture.image_file_size)
11
+ = table.timestamps(sort: true)
12
+ = table.acts_as_published_actions
data/config/routes.rb CHANGED
@@ -1,6 +1,12 @@
1
1
  Ecm::Pictures::Backend::Engine.routes.draw do
2
- backend_resources :galleries
3
- backend_resources :pictures
2
+ backend_resources :galleries do
3
+ post :reposition, on: :member
4
+ post :toggle_published, on: :member
5
+ end
6
+ backend_resources :pictures do
7
+ post :reposition, on: :member
8
+ post :toggle_published, on: :member
9
+ end
4
10
 
5
11
  root to: 'home#index'
6
12
  end
@@ -1,7 +1,7 @@
1
1
  module Ecm
2
2
  module Pictures
3
3
  module Backend
4
- VERSION = '3.2.0'.freeze
4
+ VERSION = '3.3.0'.freeze
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecm_pictures2_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
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: 2017-07-15 00:00:00.000000000 Z
11
+ date: 2018-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails