Merge pull request #6465 from opf/fix/28103/reorder-my-page-blocks

[28103] Fix reorder my page blocks

[ci skip]
pull/6470/head
Oliver Günther 6 years ago committed by GitHub
commit fb88d179f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/assets/javascripts/my_page.js
  2. 3
      app/controllers/my_controller.rb
  3. 1
      app/views/my/page_layout.html.erb

@ -111,7 +111,7 @@ jQuery(document).ready(function($) {
// On 'el' drop, we fire an Ajax request to persist the order chosen by
// the user. Actual ordering details are handled on the server.
drake.on('drop', function(el, target, source, sibling){
var url = "<%= my_order_blocks_url %>";
var url = window.gon.my_order_blocks_url;
// Array of target ordered children after this drop.
var target_ordered_children = jQuery(target).find('.block-wrapper').map(function(){

@ -168,6 +168,9 @@ class MyController < ApplicationController
@blocks = get_current_layout
@block_options = []
# Pass block url to frontend
gon.my_order_blocks_url = my_order_blocks_url;
# We track blocks that will show up on the page. This is in order to have
# them disabled in the blocks-to-add-to-page dropdown.
blocks_on_page = get_current_layout.values.flatten

@ -27,6 +27,7 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<%= javascript_include_tag 'my_page' %>
<%= include_gon(nonce: content_security_policy_nonce(:script)) %>
<%= toolbar title: l(:label_my_page) do %>
<%= styled_form_tag({ action: "add_block" }, class: 'my-page--block-form') do %>

Loading…
Cancel
Save