redde 0.3.23 → 0.3.24

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: d0efa702172d1b777179f2041fdab06a083f4f01
4
- data.tar.gz: eb958f7bc8cc84e9524ea3f586bfa05d8d58480c
3
+ metadata.gz: c4a929d175b37bbd530e0430504cf643ab11a4e8
4
+ data.tar.gz: 5c9c478d9a0879200ab9f8a953ca0af002fa246a
5
5
  SHA512:
6
- metadata.gz: 458cdf655e6ee8990d5aafe0e48bc231112cce07c35dff89d13a01bf894182fca5842aef1c8bc9a67aeada5091537b076845c097b5c5b81d2de602ff27cd2c8c
7
- data.tar.gz: cede951278c32817510c45fe5e2d73c72cfb875a05c2876f43f9a2ea0e188eaf302fdb21a0a74d81d37a68e1c13307ab5fec8aad31b777df0b91bbee9879b83c
6
+ metadata.gz: 34dd432d80560a684109474d084db0a5378a8ec19702d6a269ddab2eb15fda49f14fa00e3ddfa535d353697da1399d4a584bb5a01f364fed0dd7433ef8b5822e
7
+ data.tar.gz: b3e6908d2bff02e27078485ecb0bbddbd411b95a4c56c916f14ad0e670f46a5c4f75d374f8802c058fb2635730b797d859e02b1adfd4c1ba0188f42e6e9c542c
@@ -12,6 +12,13 @@ $ ->
12
12
  accept: "image/*"
13
13
  onFileComplete: (e, uiEvt)->
14
14
  if uiEvt.status is 200 && uiEvt.error is false
15
- $('.js-photos').append( uiEvt.result )
15
+ $photo = $( uiEvt.result )
16
+ $photo.appendTo( $('.js-photos') )
17
+ if !$box.find("input[name='redde_photo[imageable_id]']").val()
18
+ id = $photo.attr('id').replace(/\D/gi, '')
19
+ $form = $('form[data-redde]')
20
+ formId = $form.attr('id')
21
+ objectName = $form.data('redde').objectName
22
+ $photo.append("<input type='hidden' name='#{objectName}[photo_ids][]' value='#{id}' form='#{formId}'>")
16
23
  else
17
24
  alert('Ошибка загрузки')
@@ -8,8 +8,12 @@ class Admin::ReddePhotosController < ActionController::Base
8
8
  end
9
9
 
10
10
  def create
11
- parent = photo_params[:imageable_type].constantize.find(photo_params[:imageable_id])
12
- @photo = parent.photos.build(photo_params)
11
+ if photo_params[:imageable_id].present?
12
+ parent = photo_params[:imageable_type].constantize.find(photo_params[:imageable_id])
13
+ @photo = parent.photos.build(photo_params)
14
+ else
15
+ @photo = Redde::Photo.new(photo_params)
16
+ end
13
17
  if @photo.save
14
18
  render(partial: 'photo', object: @photo)
15
19
  else
@@ -24,7 +24,7 @@ module Redde::AdminHelper
24
24
  capture do
25
25
  concat page_header
26
26
  concat redde_form_for([:admin, item]) { |f| capture(f, &block) }
27
- concat photoable(item)
27
+ concat render('admin/redde_photos/photos', parent: item) if item.class.reflect_on_association(:photos)
28
28
  end
29
29
  end
30
30
 
@@ -61,10 +61,6 @@ module Redde::AdminHelper
61
61
  link_to title, path, class: classes
62
62
  end
63
63
 
64
- def photoable(parent)
65
- render('admin/redde_photos/photos', parent: parent) if parent.class.reflect_on_association(:photos)
66
- end
67
-
68
64
  def tsingular(model)
69
65
  model.model_name.human
70
66
  end
@@ -10,6 +10,7 @@ module Redde::FormHelper
10
10
  def redde_form_for(object, options = {}, &block)
11
11
  options = make_options(options)
12
12
  options[:builder] ||= ReddeFormBuilder
13
+ options[:html] = { 'data-redde' => { objectName: (object.kind_of?(Array) ? object.last : object).class.model_name.param_key }.to_json }
13
14
 
14
15
  with_clean_form_field_error_proc do
15
16
  form_for(object, options) do |f|
@@ -1,23 +1,22 @@
1
- - unless parent.new_record?
2
- = page_sidebar raw("Фотографии ").concat(if editable ||= false then link_to("ред.", [:admin, parent]) end) do
3
- %ul.photos.js-photos{ "data-sortable" => { items: :li, handle: nil, axis: nil, url: url_for([:sort, :admin, :redde_photos])}.to_json }
4
- = render partial: 'admin/redde_photos/photo', collection: parent.photos
1
+ = page_sidebar raw("Фотографии ").concat(if editable ||= false then link_to("ред.", [:admin, parent]) end) do
2
+ %ul.photos.js-photos{ "data-sortable" => { items: :li, handle: nil, axis: nil, url: url_for([:sort, :admin, :redde_photos])}.to_json, form: 'new_article' }
3
+ = render partial: 'admin/redde_photos/photo', collection: parent.photos
5
4
 
6
- -#
7
- #preview
8
- #drag-n-drop{:style => "display: none; margin-top: 5px;"}
9
- #drop-zone.b-dropzone{style: 'height: 100px;', data: {"upload-url" => url_for([:admin, parent, :photos])}}
10
- .b-dropzone__bg
11
- .b-dropzone__txt Перетащите файлы сюда
5
+ -#
6
+ #preview
7
+ #drag-n-drop{:style => "display: none; margin-top: 5px;"}
8
+ #drop-zone.b-dropzone{style: 'height: 100px;', data: {"upload-url" => url_for([:admin, Redde::Photo])}}
9
+ .b-dropzone__bg
10
+ .b-dropzone__txt Перетащите файлы сюда
12
11
 
13
- #buttons-panel{style: 'margin-bottom: 10px;'}
14
- .b-button.js-fileapi-wrapper
15
- .b-button__text Загрузить файлы
16
- %input.b-button__input.js-fileapi{:name => "files", :type => "file", :multiple => true, data: {"upload-url" => url_for([:admin, parent, :photos])}}
12
+ #buttons-panel{style: 'margin-bottom: 10px;'}
13
+ .b-button.js-fileapi-wrapper
14
+ .b-button__text Загрузить файлы
15
+ %input.b-button__input.js-fileapi{:name => "files", :type => "file", :multiple => true, data: {"upload-url" => url_for([:admin, Redde::Photo])}}
17
16
 
18
- = form_for [:admin, parent.photos.build], html: { class: 'photos-uploader js-photos-uploader' } do |f|
19
- = f.hidden_field :imageable_type
20
- = f.hidden_field :imageable_id
21
- %span.sbm.photos-uploader__btn.icon-upload
22
- Загрузить
23
- = f.file_field :src, class: 'photos-uploader__inp'
17
+ = form_for [:admin, parent.photos.build], html: { class: 'photos-uploader js-photos-uploader' } do |f|
18
+ = f.hidden_field :imageable_type
19
+ = f.hidden_field :imageable_id
20
+ %span.sbm.photos-uploader__btn.icon-upload
21
+ Загрузить
22
+ = f.file_field :src, class: 'photos-uploader__inp'
@@ -97,7 +97,7 @@ module Redde
97
97
  when 'url' then 'Ссылка'
98
98
  when 'value' then 'Значение'
99
99
  when 'articul' then 'Артикул'
100
- when 'guid' then ''
100
+ when 'guid' then 'GUID'
101
101
  when 'tag_list' then 'Тэги'
102
102
  when 'category_id' then 'Категория'
103
103
  when 'message' then 'Сообщение'
data/lib/redde/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Redde
2
- VERSION = '0.3.23'.freeze
2
+ VERSION = '0.3.24'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.23
4
+ version: 0.3.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Bovykin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-03-18 00:00:00.000000000 Z
12
+ date: 2016-03-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jquery-rails
@@ -510,7 +510,6 @@ files:
510
510
  - app/mailers/.keep
511
511
  - app/models/.keep
512
512
  - app/models/concerns/redde/layouts.rb
513
- - app/models/concerns/redde/photoable.rb
514
513
  - app/models/concerns/redde/sluggable.rb
515
514
  - app/models/concerns/redde/tree_sortable.rb
516
515
  - app/models/concerns/redde/with_photo.rb
@@ -1,5 +0,0 @@
1
- module Redde::Photoable
2
- extend ActiveSupport::Concern
3
-
4
-
5
- end