alchemy_cms 2.7.1 → 2.7.2

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: 2e25191bd90849e3276a03f409875bcd05a49ce5
4
- data.tar.gz: ce85ab765e70be9351d4d6c69a7a5aaf84b174bd
3
+ metadata.gz: ecc49224edb076e4d074a37cd7c8b0d5c28980e5
4
+ data.tar.gz: a5f478f502e5385c1dde9763e448386cba0d41f0
5
5
  SHA512:
6
- metadata.gz: 4d0b6f298b7b9ccb71f4a539a329dc5b3e485f3c02a029ea248214b694634112b19712270009d5fe0f2f3e367972a10876d88be2e9508b72a116528d35e664cb
7
- data.tar.gz: 45bed619a0e65bb9427fe91c76ee8077c261c7c969ac3d07e455e9cdc50e02393ad40e07952c7f54bdfbb8a3360652621e703bcc7cd37f270ecb46c64c6a884f
6
+ metadata.gz: f5ca9eda67f8cda86864329b0b0f113d8d29da3aeb2db1f46a677ab6b4ef3da38ffe4d6b26b851824cc767bceb94751729e20876a8d7af6d4e0b8b430438bc0c
7
+ data.tar.gz: 87baad981ff2942c54e8a497738213fc529c94f0e997515c20081e99f3bc08d3b11bcb3865477880e87b363ee14566b2430c88c2c561865d67cebd77aef94bbd
@@ -28,11 +28,10 @@ $.extend Alchemy,
28
28
  params_string = ""
29
29
  cell_id = $(this).attr("data-cell-id")
30
30
  # Is the trash window open?
31
- if $("#alchemyTrashWindow").length > 0
32
- # updating the trash icon
31
+ if Alchemy.TrashWindow.current
32
+ # update the trash icon
33
33
  if $("#trash_items div.element_editor").not(".dragged").length is 0
34
34
  $("#element_trash_button .icon").removeClass "full"
35
- $("#trash_empty_notice").show()
36
35
  $(event.target).css "cursor", "progress"
37
36
  params_string = "page_id=" + page_id + "&authenticity_token=" + encodeURIComponent(form_token) + "&" + $.param(element_ids: ids)
38
37
  params_string += "&cell_id=" + cell_id if cell_id
@@ -29,7 +29,7 @@ div#element_area {
29
29
 
30
30
  .sortable_cell {
31
31
  min-height: 100px;
32
- padding: 8px 8px 2px;
32
+ padding: 8px 4px 2px;
33
33
  }
34
34
 
35
35
  textarea {
@@ -539,9 +539,10 @@ div.file_icon {
539
539
  }
540
540
 
541
541
  a.new_content_link {
542
- float: none;
543
- margin-bottom: 12px !important;
544
- margin-top: 4px !important;
542
+ display: block;
543
+ text-align: center;
544
+ margin-bottom: 12px;
545
+ margin-top: 4px;
545
546
  }
546
547
 
547
548
  div.tinymce_container {
@@ -16,21 +16,14 @@ module Alchemy
16
16
  @content = Content.create_from_scratch(@element, params[:content])
17
17
  @options = options_from_params
18
18
  @html_options = params[:html_options] || {}
19
- if @content.essence_type == "Alchemy::EssencePicture"
19
+ if picture_gallery_editor?
20
+ @content.update_essence(picture_id: params[:picture_id])
21
+ @options = options_for_picture_gallery
20
22
  @content_dom_id = "#add_picture_#{@element.id}"
21
- @content.essence.picture_id = params[:picture_id]
22
- @content.essence.save
23
- @contents_of_this_type = @element.contents.gallery_pictures
24
- @dragable = @contents_of_this_type.length > 1
25
- @options = @options.merge(:dragable => @dragable)
26
23
  else
27
24
  @content_dom_id = "#add_content_for_element_#{@element.id}"
28
25
  end
29
- @locals = {
30
- :content => @content,
31
- :options => @options.symbolize_keys,
32
- :html_options => @html_options.symbolize_keys
33
- }
26
+ @locals = essence_editor_locals
34
27
  end
35
28
 
36
29
  def update
@@ -53,6 +46,26 @@ module Alchemy
53
46
  @content.destroy
54
47
  end
55
48
 
49
+ private
50
+
51
+ def picture_gallery_editor?
52
+ params[:content][:essence_type] == 'Alchemy::EssencePicture' && @options[:grouped] == 'true'
53
+ end
54
+
55
+ def options_for_picture_gallery
56
+ @gallery_pictures = @element.contents.gallery_pictures
57
+ @dragable = @gallery_pictures.size > 1
58
+ @options.merge(dragable: @dragable)
59
+ end
60
+
61
+ def essence_editor_locals
62
+ {
63
+ content: @content,
64
+ options: @options.symbolize_keys,
65
+ html_options: @html_options.symbolize_keys
66
+ }
67
+ end
68
+
56
69
  end
57
70
  end
58
71
  end
@@ -83,12 +83,14 @@ module Alchemy
83
83
  end
84
84
 
85
85
  def order
86
+ @trashed_elements = []
86
87
  params[:element_ids].each do |element_id|
87
88
  element = Element.find(element_id)
88
89
  if element.trashed?
89
90
  element.page_id = params[:page_id]
90
91
  element.cell_id = params[:cell_id]
91
92
  element.insert_at
93
+ @trashed_elements << element
92
94
  end
93
95
  element.move_to_bottom
94
96
  end
@@ -101,7 +103,7 @@ module Alchemy
101
103
  @element.save
102
104
  end
103
105
 
104
- private
106
+ private
105
107
 
106
108
  # Returns the cell for element name in params.
107
109
  # Creates the cell if necessary.
@@ -4,8 +4,8 @@
4
4
 
5
5
  $("#element_<%= @element.id %>_content_missing").replaceWith('<%= escape_javascript(
6
6
  render(
7
- :partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
8
- :locals => @locals
7
+ partial: "alchemy/essences/#{@content.essence_partial_name}_editor",
8
+ locals: @locals
9
9
  )
10
10
  ) %>');
11
11
 
@@ -13,12 +13,12 @@
13
13
 
14
14
  $("<%= @content_dom_id %>").before('<%= escape_javascript(
15
15
  render(
16
- :partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
17
- :locals => @locals
16
+ partial: "alchemy/essences/#{@content.essence_partial_name}_editor",
17
+ locals: @locals
18
18
  )
19
19
  ) %>');
20
20
  Alchemy.Buttons.enable();
21
- Alchemy.growl('<%= _t("Successfully added content") % {:content => @content.name_for_label} %>')
21
+ Alchemy.growl('<%= _t("Successfully added content") % {content: @content.name_for_label} %>')
22
22
 
23
23
  <% end %>
24
24
 
@@ -28,16 +28,20 @@
28
28
  $('#picture_to_assign_<%= @content.ingredient.id %> a').attr('href', '#').off('click');
29
29
  <% end %>
30
30
 
31
- <% if @contents_of_this_type.length > 1 %>
31
+ <% if @gallery_pictures %>
32
+
33
+ <% if @gallery_pictures.size > 1 %>
32
34
  $('#element_<%= @element.id %>_contents .essence_picture_editor').addClass('dragable_picture');
33
35
  <% end %>
34
36
 
35
- <% if !max_image_count.blank? && @contents_of_this_type.length >= max_image_count %>
37
+ <% if !max_image_count.blank? && @gallery_pictures.size >= max_image_count %>
36
38
  $("#add_picture_<%= @element.id %>").remove();
37
39
  <% end %>
38
40
 
39
41
  Alchemy.SortableContents('#element_<%= @element.id %>_contents', '<%= form_authenticity_token %>');
40
42
 
43
+ <% end %>
44
+
41
45
  <% elsif @content.essence_type == "Alchemy::EssenceDate" %>
42
46
 
43
47
  Alchemy.Datepicker('#element_<%= @element.id %>');
@@ -1,7 +1,12 @@
1
- (function($) {
2
-
3
- Alchemy.growl('<%= _t(:successfully_saved_element_position) -%>');
4
- $('#element_area .ajax_folder').show();
5
- Alchemy.PreviewWindow.refresh();
6
-
7
- })(jQuery);
1
+ $('#element_area .ajax_folder').show();
2
+ Alchemy.PreviewWindow.refresh();
3
+ <% if @trashed_elements.any? %>
4
+ Alchemy.growl('<%= _t(:successfully_restored_element) -%>');
5
+ <% element_ids = @trashed_elements.collect { |e| ".dragged[data-element-id=\"#{e.id}\"]" }.join(", ").html_safe %>
6
+ <% @trashed_elements.each do |element| %>
7
+ $('<%= element_ids %>').each(function() { this.id = 'element_' + <%= element.id %> });
8
+ <% end %>
9
+ Alchemy.ElementEditors.reinit('<%= element_ids %>');
10
+ <% else %>
11
+ Alchemy.growl('<%= _t(:successfully_saved_element_position) -%>');
12
+ <% end %>
@@ -563,6 +563,7 @@ de:
563
563
  subject: "Betreff"
564
564
  successfully_added_element: "Element wurde hinzugefügt."
565
565
  successfully_deleted_tag: "Das Tag wurde gelöscht"
566
+ successfully_restored_element: "Das Element wurde wieder hergestellt."
566
567
  successfully_saved_element_position: "Die Elementposition wurde gespeichert."
567
568
  successfully_updated_tag: "Das Tag wurde gespeichert"
568
569
  swap_image: "Bild tauschen"
@@ -382,6 +382,7 @@ en:
382
382
  searchresults_editor_info: "This element displays the search and the searchresults."
383
383
  small_thumbnails: "Small thumbnails"
384
384
  successfully_added_element: "Succesfully added new element."
385
+ successfully_restored_element: "Element restored succesfully."
385
386
  successfully_saved_element_position: "Element position updated succesfully."
386
387
  swap_image: "Change image"
387
388
  "These pictures could not be deleted, because they were in use": "These pictures could not be deleted, because they were in use: %{names}"
@@ -150,7 +150,7 @@ module Alchemy #:nodoc:
150
150
  # Essence description from config/elements.yml
151
151
  def description
152
152
  return {} if element.nil? or element.content_descriptions.nil?
153
- element.content_descriptions.detect { |c| c['name'] == self.content.name }
153
+ element.content_descriptions.detect { |c| c['name'] == self.content.name } || {}
154
154
  end
155
155
 
156
156
  # Returns the Content Essence is in
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.7.1"
3
+ VERSION = "2.7.2"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -1,16 +1,16 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  <%%= element_editor_for(element) do |el| -%>
3
3
  <%- if @element['picture_gallery'] -%>
4
- <%%= render_picture_gallery_editor(element, :max_images => nil, :crop => true) %>
4
+ <%%= render_picture_gallery_editor(element, max_images: nil, crop: true) %>
5
5
  <%- end -%>
6
6
  <% @contents.each do |content| -%>
7
7
  <%%= el.edit :<%= content["name"] %> %>
8
8
  <% end -%>
9
9
  <%- if @element['available_contents'] -%>
10
- <%% element.contents.where(:name => ['<%= @available_contents_names.join("', '") %>']).each do |content| %>
10
+ <%% element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content| %>
11
11
  <%%= render_essence_editor content %>
12
12
  <%% end %>
13
13
  <p><%%= render_new_content_link(element) %></p>
14
14
  <%- end -%>
15
15
  <%%- end -%>
16
- <%- end -%>
16
+ <%- end -%>
@@ -1,15 +1,14 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  = element_editor_for(element) do |el|
3
3
  <%- if @element['picture_gallery'] -%>
4
- = render_picture_gallery_editor(element, :max_images => nil, :crop => true)
4
+ = render_picture_gallery_editor(element, max_images: nil, crop: true)
5
5
  <%- end -%>
6
6
  <% @contents.each do |content| -%>
7
7
  = el.edit :<%= content["name"] %>
8
8
  <% end -%>
9
9
  <%- if @element['available_contents'] -%>
10
- - element.contents.where(:name => ['<%= @available_contents_names.join("', '") %>']).each do |content|
10
+ - element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content|
11
11
  = render_essence_editor content
12
-
13
- %p= render_new_content_link(element)
12
+ %p = render_new_content_link(element)
13
+ <% end -%>
14
14
  <% end -%>
15
- <% end -%>
@@ -1,15 +1,14 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  = element_editor_for(element) do |el|
3
3
  <%- if @element['picture_gallery'] -%>
4
- = render_picture_gallery_editor(element, :max_images => nil, :crop => true)
4
+ = render_picture_gallery_editor(element, max_images: nil, crop: true)
5
5
  <%- end -%>
6
6
  <% @contents.each do |content| -%>
7
7
  = el.edit :<%= content["name"] %>
8
8
  <% end -%>
9
9
  <%- if @element['available_contents'] -%>
10
- - element.contents.where(:name => ['<%= @available_contents_names.join("', '") %>']).each do |content|
10
+ - element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content|
11
11
  = render_essence_editor content
12
-
13
- p= render_new_content_link(element)
12
+ p = render_new_content_link(element)
14
13
  <% end -%>
15
- <%- end -%>
14
+ <%- end -%>
@@ -1,10 +1,10 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  <%%= element_view_for(element) do |el| -%>
3
3
  <%- if @element["picture_gallery"] -%>
4
4
  <div class="<%= @element_name %>_images">
5
5
  <%%- element.contents.gallery_pictures.each do |image| -%>
6
6
  <div class="<%= @element_name %>_image <%%= image.essence.css_class %>">
7
- <%%= render_essence_view(image, :image_size => "160x120") %>
7
+ <%%= render_essence_view(image, image_size: '160x120') %>
8
8
  </div>
9
9
  <%%- end -%>
10
10
  </div>
@@ -18,5 +18,10 @@
18
18
  <%%= el.render :<%= content["name"] %> %>
19
19
  <%- end -%>
20
20
  <%- end -%>
21
+ <%- if @element['available_contents'] -%>
22
+ <%% element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content| %>
23
+ <%%= render_essence_view content %>
24
+ <%% end %>
25
+ <%- end -%>
21
26
  <%%- end -%>
22
- <%- end -%>
27
+ <%- end -%>
@@ -1,11 +1,11 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  = element_view_for(element) do |el|
3
- <%- if @element["picture_gallery"] -%>
3
+ <%- if @element["picture_gallery"] -%>
4
4
  .<%= @element_name %>_images
5
5
  - element.contents.gallery_pictures.each do |image|
6
6
  .<%= @element_name %>_image{class: image.essence.css_class}
7
7
  = render_essence_view(image, :image_size => "160x120")
8
- <%- end -%>
8
+ <%- end -%>
9
9
  <%- @contents.each do |content| -%>
10
10
  <%- if @contents.length > 1 -%>
11
11
  .<%= content["name"] %>
@@ -14,4 +14,8 @@
14
14
  = el.render :<%= content["name"] %>
15
15
  <%- end -%>
16
16
  <%- end -%>
17
- <%- end -%>
17
+ <%- if @element['available_contents'] -%>
18
+ - element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content|
19
+ = render_essence_view content
20
+ <%- end -%>
21
+ <%- end -%>
@@ -1,11 +1,11 @@
1
- <%- if @element['contents'].present? -%>
1
+ <%- if @element['contents'].present? || @element['available_contents'].present? -%>
2
2
  = element_view_for(element) do |el|
3
- <%- if @element["picture_gallery"] -%>
3
+ <%- if @element["picture_gallery"] -%>
4
4
  .<%= @element_name %>_images
5
5
  - element.contents.gallery_pictures.each do |image|
6
6
  .<%= @element_name %>_image class=image.essence.css_class
7
7
  = render_essence_view(image, :image_size => "160x120")
8
- <%- end -%>
8
+ <%- end -%>
9
9
  <%- @contents.each do |content| -%>
10
10
  <%- if @contents.length > 1 -%>
11
11
  .<%= content["name"] %>
@@ -14,4 +14,8 @@
14
14
  = el.render :<%= content["name"] %>
15
15
  <%- end -%>
16
16
  <%- end -%>
17
- <%- end -%>
17
+ <%- if @element['available_contents'] -%>
18
+ - element.contents.where(name: ['<%= @available_contents_names.join("', '") %>']).each do |content|
19
+ = render_essence_view content
20
+ <%- end -%>
21
+ <%- end -%>
@@ -19,6 +19,24 @@ describe Alchemy::Admin::ContentsController do
19
19
  xhr :post, :create, {content: {element_id: element.id, essence_type: 'EssencePicture'}}
20
20
  }.to change{element.contents.count}.by(1)
21
21
  end
22
+
23
+ context 'inside a picture gallery' do
24
+ let(:attributes) do
25
+ {content: {element_id: element.id, essence_type: 'Alchemy::EssencePicture'}, options: {grouped: 'true'}}
26
+ end
27
+
28
+ it "adds it into the gallery editor" do
29
+ xhr :post, :create, attributes
30
+ assigns(:content_dom_id).should eq("#add_picture_#{element.id}")
31
+ end
32
+
33
+ context 'with picture_id given' do
34
+ it "assigns the picture" do
35
+ Alchemy::Content.any_instance.should_receive(:update_essence).with(picture_id: '1')
36
+ xhr :post, :create, attributes.merge(picture_id: '1')
37
+ end
38
+ end
39
+ end
22
40
  end
23
41
 
24
42
  describe '#update' do
@@ -2,8 +2,46 @@ require 'spec_helper'
2
2
 
3
3
  module Alchemy
4
4
  describe "ActsAsEssence" do
5
- #let(:element) { FactoryGirl.create(:element, :name => 'headline', :create_contents_after_create => true) }
6
- let(:essence) { Alchemy::EssenceText.new }
5
+ let(:element) { Element.new }
6
+ let(:content) { Content.new(name: 'foo') }
7
+ let(:essence) { EssenceText.new }
8
+ let(:content_description) { {'name' => 'foo'} }
9
+
10
+ describe '#description' do
11
+ subject { essence.description }
12
+
13
+ context 'without element' do
14
+ it { should eq({}) }
15
+ end
16
+
17
+ context 'with element' do
18
+ before { essence.stub(element: element) }
19
+
20
+ context 'but without content descriptions' do
21
+ it { should eq({}) }
22
+ end
23
+
24
+ context 'and content descriptions' do
25
+ before do
26
+ essence.stub(content: content)
27
+ end
28
+
29
+ context 'containing the content name' do
30
+ before { element.stub(content_descriptions: [content_description]) }
31
+
32
+ it "returns the content description" do
33
+ should eq(content_description)
34
+ end
35
+ end
36
+
37
+ context 'not containing the content name' do
38
+ before { element.stub(content_descriptions: []) }
39
+
40
+ it { should eq({}) }
41
+ end
42
+ end
43
+ end
44
+ end
7
45
 
8
46
  describe '#ingredient=' do
9
47
  it 'should set the value to ingredient column' do
@@ -1,6 +1,4 @@
1
- require 'rspec'
2
- require File.dirname(__FILE__) + '/../../lib/alchemy/resource'
3
- require File.dirname(__FILE__) + '/../../lib/alchemy/errors'
1
+ require 'spec_helper'
4
2
 
5
3
  class Event
6
4
  end
@@ -1,7 +1,4 @@
1
- require 'rspec'
2
- require 'ostruct'
3
- require File.dirname(__FILE__) + "/../../lib/alchemy/resource"
4
- require File.dirname(__FILE__) + "/../../lib/alchemy/resources_helper"
1
+ require 'spec_helper'
5
2
 
6
3
  module Namespace
7
4
  class MyResource
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-11-18 00:00:00.000000000 Z
15
+ date: 2014-01-11 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
@@ -1146,7 +1146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1146
1146
  requirements:
1147
1147
  - ImageMagick (libmagick), v6.6 or greater.
1148
1148
  rubyforge_project:
1149
- rubygems_version: 2.1.10
1149
+ rubygems_version: 2.1.11
1150
1150
  signing_key:
1151
1151
  specification_version: 4
1152
1152
  summary: A powerful, userfriendly and flexible CMS for Rails 3