sibu 0.1.26 → 0.1.27

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae660a877d92fc982f3f013404a4afd4d79e46de
4
- data.tar.gz: 5b4221c6178eb1b5cb4b497bfef8801e989c77a3
3
+ metadata.gz: eeb7409413b51b5a0933c57ea35a968ea821227b
4
+ data.tar.gz: 61391deb0edaccb79e69867f9ab2af20323a497b
5
5
  SHA512:
6
- metadata.gz: b954bf098086c3b9ac081be9538a5e565f93908ade83b99dd6dfb72f01e2efdb3a8f806d2bd8be10176a558723be7fbb3f3afc17893dcaa980e8d1ca414017cf
7
- data.tar.gz: 2a9d4af45641c0db7453ae2439c944df92a577cb401c3ed588ac8bf523801102b4ca190ee5cc0a8f278ac40ba0e50c6d6b58f2ed0c70016e9592ead171414b2c
6
+ metadata.gz: 29e4d615c196138a7456fabb3bf6a12b06934729d0c30be4d2d57c9d867fa41e68c02b7530111f10238901090febb34b8f2f7e2230a0bc86e4b4bdeaf0086c92
7
+ data.tar.gz: ab65058f811c6d7c9c8b3c6fc8dd0fa55890819c13b8ba7ff0acb00ab05a65c1f4413b907d5f644183a3ca2c8780f2d906ca91ac1f3b24aed1ffde28ec169078
@@ -17,15 +17,15 @@ module Sibu
17
17
  @image = Sibu::Image.new(image_params)
18
18
  if @image.save
19
19
  if @page_id && @section_id && @element_id && @size
20
- page = Sibu::Page.find(@page_id)
20
+ entity = @entity_type == 'site' ? @site : Sibu::Page.find(@page_id)
21
21
  ids = (@section_id.split('|') + @element_id.split('|')).uniq[0...-1]
22
- elt = page.update_element(*ids, {"id" => @img_id, "src" => @image.file_url(@size.to_sym), "alt" => @image.alt})
22
+ elt = entity.update_element(*ids, {"id" => @img_id, "src" => @image.file_url(@size.to_sym), "alt" => @image.alt})
23
23
  if elt.nil?
24
24
  msg = {alert: "Une erreur s'est produite lors de la mise à jour de l'image."}
25
25
  else
26
26
  msg = {notice: "L'image a bien été mise à jour."}
27
27
  end
28
- redirect_to site_page_edit_content_path(@site.id, page.id), msg
28
+ redirect_to site_page_edit_content_path(@site.id, @page_id), msg
29
29
  else
30
30
  redirect_to site_images_url(@image.site_id), notice: "L'image a bien été téléchargée."
31
31
  end
@@ -55,6 +55,7 @@ module Sibu
55
55
 
56
56
  def set_edition_context
57
57
  @page_id = params[:page_id]
58
+ @entity_type = params[:entity_type]
58
59
  @section_id = params[:section_id]
59
60
  @element_id = params[:element_id]
60
61
  @img_id = params[:img_id]
@@ -16,6 +16,7 @@
16
16
  </div>
17
17
  <%= f.hidden_field :site_id %>
18
18
  <%= hidden_field_tag :page_id, @page_id %>
19
+ <%= hidden_field_tag :entity_type, @entity_type %>
19
20
  <%= hidden_field_tag :element_id, @element_id %>
20
21
  <%= hidden_field_tag :section_id, @section_id %>
21
22
  <%= hidden_field_tag :img_id, @img_id %>
@@ -4,7 +4,7 @@
4
4
  <div class="sibu_edit_form">
5
5
  <%= form_tag(update_element_site_page_path(@site.id, @page.id), method: :patch, remote: true) do |f| %>
6
6
  <div class="sibu_select_images sibu_field">
7
- <p>Sélectionnez ou <%= link_to 'téléchargez', new_site_image_path(@site.id, page_id: @page.id, section_id: @section_id,
7
+ <p>Sélectionnez ou <%= link_to 'téléchargez', new_site_image_path(@site.id, page_id: @page.id, section_id: @section_id, entity_type: @entity_type,
8
8
  element_id: @element_id, img_id: @element["id"], size: @size) %> une image</p>
9
9
  <% site_images.each do |image| %>
10
10
  <div class="sibu_image" data-img-id="<%= image.id %>">
data/lib/sibu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sibu
2
- VERSION = '0.1.26'
2
+ VERSION = '0.1.27'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Baptiste Vilain