alchemy_cms 8.3.6 → 8.3.7

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
  SHA256:
3
- metadata.gz: e13db27417e434306c2ba48c7b3718758690ca49b7cc0ad85aea8921210779e6
4
- data.tar.gz: 2a13089265941fac886d3523485414f4cf774d0150382926a0a7131d421f0296
3
+ metadata.gz: c8f639a1d9089eea972ddfa6d299a072337dfe342441fddd6150cd2dfae8e47f
4
+ data.tar.gz: dcc66f199295ff7bffbe07e5e2c28f98e3867675066faa87a6142d745425bf5a
5
5
  SHA512:
6
- metadata.gz: 4aa7ac27020b95dea3b8ea39a039a0186c5d62d12461f2a6af14d1ff3122fb74fbf33f6e44313345e2d04c8b5b3c8c668658cc7beacf34cf35cdd0af63539280
7
- data.tar.gz: b301ea1b3dfc42b213fc6af56f08feabec797d6ffe8354614a8465ec653b436065fd292183593bb71bbccb9225207c64e8608239602cc23929e1d3ba3653280d
6
+ metadata.gz: 65edc33be6840411cefa89b7a01e99f9d63d556b80c7e3b51f8efe40eac5d75fb6fc9ed7622c9af74161ac80719834e1128dfb7e312e85db5cc0a1254a0f5bd1
7
+ data.tar.gz: 00254aaacad56b9fd1cd0ac085d676bb3907f4c69f73a0590ab6c0e1b43ae0f7ae0b59c83e84b953131e65a1937da917cbccecd14ec6447af3080921bd1a54fa
@@ -10,6 +10,8 @@ module Alchemy
10
10
  # name of an action to evaluate if the user can perform these action on the given object
11
11
  # @param [String, nil] :tooltip
12
12
  # show a tooltip around the button
13
+ # @param [Object, nil] :resource
14
+ # the resource of the row the action belongs to
13
15
  # @param [Lambda] :block
14
16
  # a block to include a button or a link
15
17
  #
@@ -30,15 +32,11 @@ module Alchemy
30
32
  <% end %>
31
33
  ERB
32
34
 
33
- def initialize(name = nil, tooltip = nil, &block)
35
+ def initialize(name = nil, tooltip = nil, resource = nil, &block)
34
36
  @name = name
35
37
  @tooltip = tooltip
36
- @block = block
37
- end
38
-
39
- def with_resource(resource)
40
38
  @resource = resource
41
- self
39
+ @block = block
42
40
  end
43
41
  end
44
42
  end
@@ -7,6 +7,8 @@ module Alchemy
7
7
  #
8
8
  # @param [String, nil] :css_classes
9
9
  # css classes that are show at the table cell
10
+ # @param [Object, nil] :resource
11
+ # the resource of the row the cell belongs to
10
12
  # @param [Lambda] :block
11
13
  # a block to include a button or a link
12
14
  #
@@ -19,14 +21,10 @@ module Alchemy
19
21
  </td>
20
22
  ERB
21
23
 
22
- def initialize(css_classes, &block)
24
+ def initialize(css_classes, resource = nil, &block)
23
25
  @css_classes = css_classes
24
- @block = block
25
- end
26
-
27
- def with_resource(resource)
28
26
  @resource = resource
29
- self
27
+ @block = block
30
28
  end
31
29
  end
32
30
  end
@@ -69,12 +69,12 @@ module Alchemy
69
69
  <% collection.each do |resource| %>
70
70
  <tr class="<%= cycle('even', 'odd') %>">
71
71
  <% cells.each do |cell| %>
72
- <%= render cell.with_resource(resource) %>
72
+ <%= render cell_for(cell, resource) %>
73
73
  <% end %>
74
74
  <% if actions? %>
75
75
  <td class="tools">
76
76
  <% actions.each do |action| %>
77
- <%= render action.with_resource(resource) %>
77
+ <%= render action_for(action, resource) %>
78
78
  <% end %>
79
79
  </td>
80
80
  <% end %>
@@ -134,6 +134,18 @@ module Alchemy
134
134
 
135
135
  private
136
136
 
137
+ # A fresh cell instance is built for every resource because ViewComponent
138
+ # instances are single-use and may not be rendered more than once.
139
+ def cell_for(cell, resource)
140
+ Cell.new(cell.css_classes, resource, &cell.block)
141
+ end
142
+
143
+ # A fresh action instance is built for every resource because ViewComponent
144
+ # instances are single-use and may not be rendered more than once.
145
+ def action_for(action, resource)
146
+ Action.new(action.name, action.tooltip, resource, &action.block)
147
+ end
148
+
137
149
  ##
138
150
  # if no cells are available the resource_helper will be used, to generate the
139
151
  # default attributes of the given resource
@@ -10,9 +10,11 @@ module Alchemy
10
10
  include Alchemy::Admin::PreviewTime
11
11
 
12
12
  before_action :load_element, only: [:update, :destroy, :collapse, :expand, :publish]
13
- authorize_resource class: Alchemy::Element
13
+ authorize_resource class: Alchemy::Element, except: [:index]
14
14
 
15
15
  def index
16
+ authorize! :edit_content, @page
17
+
16
18
  preloaded = Alchemy::ElementPreloader
17
19
  .new(page_version: @page_version)
18
20
  .call
@@ -17,7 +17,7 @@
17
17
  box-shadow: 0 0 0 1px #fff;
18
18
  box-sizing: border-box;
19
19
  border-bottom-right-radius: var(--border-radius);
20
- padding: 12px 16px 12px;
20
+ padding: 12px 16px 12px 12px;
21
21
  gap: 12px;
22
22
  justify-content: space-between;
23
23
  align-items: center;
@@ -26,6 +26,7 @@
26
26
  font-family: "Open Sans", "Lucida Grande", "Lucida Sans Unicode",
27
27
  "Lucida Sans", Verdana, Tahoma, sans-serif;
28
28
  font-size: 13px;
29
+ line-height: normal;
29
30
  }
30
31
 
31
32
  .menubar * {
@@ -107,7 +108,7 @@
107
108
  <% end %>
108
109
  <% end %>
109
110
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30">
110
- <path fill="#fff" d="M15.7 7.9L9.9 2.2 2.1 4.3 0 12.1l5.7 5.8 7.8-2.1 2.2-7.9zm-5.3 10.3l-1.2 4.4 3.2 3.2 4.4-1.2 1.2-4.4-3.2-3.2-4.4 1.2zM23.5 7.3L17.2 9l-1.7 6.2 4.5 4.6 6.2-1.7 1.7-6.2-4.4-4.6z"/>
111
+ <path fill="#fff" d="M15.7 7.9L9.9 2.2 2.1 4.3 0 12.1l5.7 5.8 7.8-2.1 2.2-7.9zm-5.3 10.3l-1.2 4.4 3.2 3.2 4.4-1.2 1.2-4.4-3.2-3.2-4.4 1.2zM23.5 7.3L17.2 9l-1.7 6.2 4.5 4.6 6.2-1.7 1.7-6.2-4.4-4.6z" />
111
112
  </svg>
112
113
  </div>
113
114
  </template>
@@ -111,7 +111,6 @@ module Alchemy
111
111
  def create_page(draft, attributes = {})
112
112
  children = draft.delete("children") || []
113
113
  page = Alchemy::Page.new(draft.merge(attributes))
114
- page.versions.build
115
114
  page.save!
116
115
  log "Created page: #{page.name}"
117
116
  children.each do |child|
@@ -3,7 +3,7 @@
3
3
  module Alchemy
4
4
  extend self
5
5
 
6
- VERSION = "8.3.6"
6
+ VERSION = "8.3.7"
7
7
 
8
8
  def version
9
9
  VERSION
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: 8.3.6
4
+ version: 8.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen