pulitzer 0.15.14 → 0.15.15

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: 28bc18b90e428c4175a5d10bd2d4a39f264233c1
4
- data.tar.gz: fc3a3b64fd0f8c29d069aee7a6fd5a1c21113db6
3
+ metadata.gz: 257ca58d5e65ab4ed21ec10496f1b0304901e014
4
+ data.tar.gz: 63b3fa6ab76d1eda01eb948b422614d13ab390c9
5
5
  SHA512:
6
- metadata.gz: d99829d36453d6ae958e0b599ef7098045b3425a267eeaec87630264265203c4d0b02f1a6cbe92e9d0e2e505226f26678058e05b99b37da2fbb2747c7d23fe8e
7
- data.tar.gz: 7cd17af9eb7727fcd80de0530d3c89f491a9481eefe5c305c5dee60454e23fbb5d740918533d7ca7dc7e0ce803d2948f45a84ef70fffa465224b569e0f286c1c
6
+ metadata.gz: '0834f6c2053bae0a89d07407f5ef713f9e57d3f520eaee3876fc2764ed8577e51a2053a970abffb4a2465f8f92fc6e8fc5aaee6e7c7de4360d297999d8e3d1b5'
7
+ data.tar.gz: 3880a61be852368698131218084053bdee6f1d7977daf2a71b56ecc9acc541ce6f26c3b04483eccae4e61978c53eb3d79c47376ffa09e2c02302d18656c9ff71
@@ -47,7 +47,7 @@ class Pulitzer::PartialsController < Pulitzer::ApplicationController
47
47
 
48
48
  def upgrade
49
49
  @partial = UpgradePartialVersion.new(@partial).call
50
- render partial: 'show', locals: { partial: @partial }
50
+ render partial: 'show_wrapper', locals: { partial: @partial }
51
51
  end
52
52
 
53
53
  protected
@@ -3,7 +3,7 @@ class Pulitzer::PostTypeVersionsController < Pulitzer::ApplicationController
3
3
 
4
4
  def index
5
5
  @post_type = Pulitzer::PostType.find(params[:post_type_id])
6
- @post_type_versions = @post_type.post_type_versions
6
+ @post_type_versions = @post_type.post_type_versions.order(id: :desc)
7
7
  render_ajax
8
8
  end
9
9
 
@@ -5,8 +5,8 @@ class Pulitzer::CloneVersion
5
5
  @version = version
6
6
  @post = @version.post
7
7
  @new_version = new_version
8
- Rails.logger.info("Pulitzer::CloneVersion !!! ")
9
- Rails.logger.info($0)
8
+ Rails.logger.debug("Pulitzer::CloneVersion !!! ")
9
+ Rails.logger.debug($0)
10
10
  end
11
11
 
12
12
  def call
@@ -8,6 +8,7 @@ class Pulitzer::PartialsController::UpgradePartialVersion
8
8
  def call
9
9
  most_recent_partial_version = @partial.post_type_version.post_type.most_recent_published_post_type_version
10
10
  new_partial = @free_form_section.partials.create(label: @partial.label, post_type_version_id: most_recent_partial_version.id)
11
+ clone_styles(@partial,new_partial)
11
12
  Pulitzer::CreatePartialContentElements.new(new_partial).call
12
13
  content_elements = new_partial.content_elements.to_a
13
14
  content_elements.each do |ce|
@@ -18,7 +19,56 @@ class Pulitzer::PartialsController::UpgradePartialVersion
18
19
  ce.destroy
19
20
  end
20
21
  end
22
+ @partial.remove_show = true
23
+ @partial.broadcast_change if defined? ForeignOffice
21
24
  @partial.destroy
25
+
26
+ new_partial.reload_show = true
27
+ new_partial.broadcast_change if defined? ForeignOffice
22
28
  new_partial
23
29
  end
30
+
31
+ def clone_styles(old_partial,new_partial)
32
+ old_arrangement_style = old_partial.arrangement_style
33
+ old_justification_style = old_partial.justification_style
34
+ old_background_style = old_partial.background_style
35
+ old_sequence_flow_style = old_partial.sequence_flow_style
36
+ new_arrangement_styles = new_partial.post_type_version.arrangement_styles.to_a
37
+ new_justification_styles = new_partial.post_type_version.justification_styles.to_a
38
+ new_background_styles = new_partial.post_type_version.background_styles.to_a
39
+ new_sequence_flow_styles = new_partial.post_type_version.sequence_flow_styles.to_a
40
+ if old_arrangement_style.present?
41
+ new_style = new_arrangement_styles.detect do |style|
42
+ old_arrangement_style.view_file_name == style.view_file_name
43
+ end
44
+ if new_style.present?
45
+ new_partial.arrangement_style_id = new_style.id
46
+ end
47
+ end
48
+ if old_justification_style.present?
49
+ new_style = new_justification_styles.detect do |style|
50
+ old_justification_style.css_class_name == style.css_class_name
51
+ end
52
+ if new_style.present?
53
+ new_partial.justification_style_id = new_style.id
54
+ end
55
+ end
56
+ if old_background_style.present?
57
+ new_style = new_background_styles.detect do |style|
58
+ old_background_style.css_class_name == style.css_class_name
59
+ end
60
+ if new_style.present?
61
+ new_partial.background_style_id = new_style.id
62
+ end
63
+ end
64
+ if old_sequence_flow_style.present?
65
+ new_style = new_sequence_flow_styles.detect do |style|
66
+ old_sequence_flow_style.css_class_name == style.css_class_name
67
+ end
68
+ if new_style.present?
69
+ new_partial.sequence_flow_style_id = new_style.id
70
+ end
71
+ end
72
+ new_partial.save
73
+ end
24
74
  end
@@ -1,5 +1,7 @@
1
1
  module Pulitzer
2
2
  class Partial < Pulitzer::ApplicationRecord
3
+ include ForeignOffice::Broadcaster if defined? ForeignOffice
4
+
3
5
  belongs_to :free_form_section
4
6
  belongs_to :post_type_version
5
7
  belongs_to :background_style
@@ -12,7 +14,10 @@ module Pulitzer
12
14
 
13
15
  accepts_nested_attributes_for :content_elements
14
16
 
17
+ attr_accessor :reload_show, :remove_show
18
+
15
19
  delegate :name, :post_type_content_element_types, :has_display?, :post_type_id, :version_number, to: :post_type_version
20
+ delegate :most_recent_version_number, to: :post_type
16
21
  delegate :template_path, to: :layout, allow_nil: true
17
22
 
18
23
  before_save :handle_sort_order
@@ -107,5 +112,10 @@ module Pulitzer
107
112
  def upgradable?
108
113
  version_number < (post_type_version&.post_type&.post_type_versions&.published&.maximum(:version_number) || 0)
109
114
  end
115
+
116
+ def serialize
117
+ self.attributes.merge \
118
+ reload_show: self.reload_show
119
+ end
110
120
  end
111
121
  end
@@ -24,4 +24,8 @@ class Pulitzer::PostType < Pulitzer::ApplicationRecord
24
24
  def most_recent_published_post_type_version
25
25
  post_type_versions&.published&.order(version_number: :desc)&.first
26
26
  end
27
+
28
+ def most_recent_version_number
29
+ most_recent_published_post_type_version&.version_number
30
+ end
27
31
  end
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
  <div class="pulitzer-row margin-bottom">
17
17
  <% if partial.upgradable? %>
18
- <%= ajax_link "Upgrade #{partial.label} to the last partial version", upgrade_partial_path(partial), {class: 'button'}, dom_target(partial), http_method: 'PATCH' %>
18
+ <%= ajax_link "Upgrade #{partial.label} to the latest #{partial.name} version #{partial.most_recent_version_number}", upgrade_partial_path(partial), {class: 'button'}, dom_target(partial), insert_method: 'after', remove_on_success: dom_target(partial), http_method: 'PATCH' %>
19
19
  <% end %>
20
20
  </div>
21
21
  <div <%= collapsed(dom_id(partial)) %>>
@@ -1,3 +1,3 @@
1
- <div class="pulitzer-row margin-bottom list-item" id="<%= dom_id(partial) %>">
1
+ <div class="pulitzer-row margin-bottom list-item" id="<%= dom_id(partial) %>" <%= listener_attrs(partial, :reload_show, endpoint: pulitzer.partial_path(partial)) if defined? ForeignOffice %>>
2
2
  <%= render partial: '/pulitzer/partials/show', locals: { partial: partial } %>
3
3
  </div>
@@ -4,12 +4,12 @@
4
4
  <% if Pulitzer.skip_metadata_auth? || self.instance_eval(&Pulitzer.metadata_closure) %>
5
5
  <%= ajax_link "Create a blank version of this template",
6
6
  post_type_versions_path(post_type_version: {post_type_id: @post_type.id}),
7
- {}, '#post_type_versions_container', http_method: 'POST', insert_method: 'append' %>
7
+ {}, '#post_type_versions_container', http_method: 'POST', insert_method: 'prepend' %>
8
8
  <br>
9
9
  <div class="pulitzer-span right">
10
10
  <div class="pulitzer-row bold margin-bottom">Import New Version from JSON file</div>
11
11
  <div class="pulitzer-row">
12
- <%= form_for @post_type, url: import_version_post_type_path(@post_type), html: ajax_form_hash('#post_type_versions_container', insert_method: 'append').merge( multipart: true, method: 'PATCH') do |f| %>
12
+ <%= form_for @post_type, url: import_version_post_type_path(@post_type), html: ajax_form_hash('#post_type_versions_container', insert_method: 'prepend').merge( multipart: true, method: 'PATCH') do |f| %>
13
13
  <%= f.file_field :import_json %>
14
14
  <%= f.submit 'Import' %>
15
15
  <% end %>
@@ -18,7 +18,7 @@
18
18
  <% if @post_type.published_type_version %>
19
19
  <%= ajax_link "Clone the published version of this template",
20
20
  clone_post_type_versions_path(post_type_version: {post_type_id: @post_type.id}), {}, '#post_type_versions_container',
21
- http_method: 'POST', insert_method: 'append' %>
21
+ http_method: 'POST', insert_method: 'prepend' %>
22
22
  <% end %>
23
23
  <% end %>
24
24
  </div>
@@ -23,7 +23,7 @@ module Pulitzer
23
23
  if ptv.plural?
24
24
  ptv.posts.find_by!(slug: params[:slug]).send "get_#{status}_version!"
25
25
  else
26
- ptv.singleton_post.get_active_version!
26
+ ptv.singleton_post.send "get_#{status}_version!"
27
27
  end
28
28
  else
29
29
  nil
@@ -1,3 +1,3 @@
1
1
  module Pulitzer
2
- VERSION = '0.15.14'
2
+ VERSION = '0.15.15'
3
3
  end
Binary file