c80_yax 0.1.0.3 → 0.1.0.4

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: 7c1babe3e4c6239617ef6d4318770105186fb00c
4
- data.tar.gz: 83a06df3d5a039cba4b75bb733fb4cdc610ba99c
3
+ metadata.gz: d8896703e173f7ebc35c9c9bb777b505e3cd76d3
4
+ data.tar.gz: 14fe702299e0a2057d8bfa37cfe20a270415c363
5
5
  SHA512:
6
- metadata.gz: 1daca052cdc67e37d9e18b4bef01eedd23d5c03b683386fd10006a7b06b3655c6f89a4dd40417e87cb4f0aca2a098f1652f0d886d210af49c95ff504e77d9d8a
7
- data.tar.gz: 8221ce3523da4216eac3fd792e260a61a719682d4f133186e182465692f100f41f5eb4da70be1da3e05c91ea2a95a6d8067ea59f611cc7944d9955b61481db3b
6
+ metadata.gz: 11abc62b900d27625364db159894c648727086b793d6550e2955b5540b6a2fbc91df9aed4137352bc246442ae03e5c3edfe90020a1f3446fe5f96c93b1e450bf
7
+ data.tar.gz: 9117242d0ecf263ebd5dd09b4483c79f5a17346ff73e7bf2fcee3f059714332668c0007e98fe874679d6d30c8e5ace6681e21787430133c88d5d29981843376c
@@ -8,6 +8,7 @@ ActiveAdmin.register C80Yax::Cat, as: 'Cat' do
8
8
  permit_params :title,
9
9
  :slug,
10
10
  :ord,
11
+ :image,
11
12
  :strsubcat_ids => []
12
13
 
13
14
  config.batch_actions = false
@@ -18,7 +19,9 @@ ActiveAdmin.register C80Yax::Cat, as: 'Cat' do
18
19
  id_column
19
20
  column :ord
20
21
  column :title
21
-
22
+ column :image do |cat|
23
+ cat_image(cat)
24
+ end
22
25
  column :strsubcats do |cat|
23
26
  res = '-'
24
27
  if cat.strsubcats.count > 0
@@ -38,6 +41,7 @@ ActiveAdmin.register C80Yax::Cat, as: 'Cat' do
38
41
  f.inputs 'Свойства категории' do
39
42
  f.input :title
40
43
  f.input :ord
44
+ f.input :image, :as => :file, :hint => cat_image(f.object)
41
45
  f.input :strsubcats, :as => :check_boxes
42
46
  end
43
47
 
@@ -0,0 +1,15 @@
1
+ module C80Yax
2
+ module Cats
3
+ module CatViewHelper
4
+
5
+ def cat_image(cat)
6
+ res = ''
7
+ if cat.image.present?
8
+ res = image_tag cat.image.thumb_md
9
+ end
10
+ res.html_safe
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -1,25 +1,29 @@
1
1
  require 'babosa'
2
2
 
3
- class C80Yax::Cat < ActiveRecord::Base
3
+ module C80Yax
4
+ class Cat < ActiveRecord::Base
4
5
 
5
- validates :title,
6
- presence: true,
7
- uniqueness: true,
8
- length: { in: 6..50 }
6
+ validates :title,
7
+ presence: true,
8
+ uniqueness: true,
9
+ length: { in: 6..50 }
9
10
 
10
- has_and_belongs_to_many :strsubcats
11
+ has_and_belongs_to_many :strsubcats
12
+ mount_uploader :image, IcatUploader
11
13
 
12
- extend FriendlyId
13
- friendly_id :slug_candidates, :use => :slugged
14
+ extend FriendlyId
15
+ friendly_id :slug_candidates, :use => :slugged
14
16
 
15
- def slug_candidates
16
- [:title] + Array.new(6) {|index| [:title, index+2]}
17
- end
17
+ def slug_candidates
18
+ [:title] + Array.new(6) {|index| [:title, index+2]}
19
+ end
18
20
 
19
- def normalize_friendly_id(input)
20
- input.to_s.to_slug.normalize(transliterations: :russian).to_s
21
- end
21
+ def normalize_friendly_id(input)
22
+ input.to_s.to_slug.normalize(transliterations: :russian).to_s
23
+ end
22
24
 
23
- scope :menu_order, -> {order(:ord => :asc)}
25
+ scope :menu_order, -> {order(:ord => :asc)}
26
+
27
+ end
24
28
 
25
- end
29
+ end
@@ -0,0 +1,23 @@
1
+ module C80Yax
2
+
3
+ # грузит картинку категории
4
+ class IcatUploader < BaseFileUploader
5
+
6
+ process :resize_to_limit => [1024,768]
7
+
8
+ version :thumb_md do
9
+ begin
10
+ p = C80Yax::Prop.first
11
+ process :resize_to_fill => [p.thumb_md_width, p.thumb_md_height]
12
+ rescue => e
13
+ Rails.logger.debug "[TRACE] <icat_uploader.thumb_md> [ERROR] #{e}"
14
+ end
15
+ end
16
+
17
+ def store_dir
18
+ 'uploads/cats'
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -2,6 +2,7 @@ class CreateC80YaxCats < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :c80_yax_cats do |t|
4
4
  t.string :title
5
+ t.string :image
5
6
  t.string :slug
6
7
  t.integer :ord
7
8
 
@@ -1,3 +1,3 @@
1
1
  module C80Yax
2
- VERSION = '0.1.0.3'
2
+ VERSION = '0.1.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_yax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.3
4
+ version: 0.1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-24 00:00:00.000000000 Z
11
+ date: 2017-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -153,6 +153,7 @@ files:
153
153
  - app/assets/stylesheets/c80_yax_backend.scss
154
154
  - app/controllers/c80_yax/admin_data_controller.rb
155
155
  - app/controllers/c80_yax/app_controller.rb
156
+ - app/helpers/c80_yax/cats/cat_view_helper.rb
156
157
  - app/helpers/c80_yax/data_helper.rb
157
158
  - app/helpers/c80_yax/items/asterix_helper.rb
158
159
  - app/helpers/c80_yax/items/buy_options_helper.rb
@@ -181,6 +182,7 @@ files:
181
182
  - app/models/c80_yax/strsubcat_observer.rb
182
183
  - app/models/c80_yax/uom.rb
183
184
  - app/models/c80_yax/vendor.rb
185
+ - app/uploaders/c80_yax/icat_uploader.rb
184
186
  - app/uploaders/c80_yax/iphoto_uploader.rb
185
187
  - app/views/admin/strsubcats/_view.html.erb
186
188
  - app/views/c80_yax/items/_buy_options.html.erb