diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 0159d6d..09d8f3c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,10 @@ Changelog * Provide the actual object for a block in the ``rendered_block`` tuples to allow more flexibility in the templates, especially in ``container.html``. +* Move the block selection modal markup from within the container into the + body of the page. This means we only need a single modal including all + available blocks. Also it avoids problems with displaying the modal. + 0.1.0 ----- diff --git a/fancypages/static/fancypages/js/editor.js b/fancypages/static/fancypages/js/editor.js index 566c0d7..8e143ea 100644 --- a/fancypages/static/fancypages/js/editor.js +++ b/fancypages/static/fancypages/js/editor.js @@ -161,6 +161,7 @@ fancypages.editor = { //load the form to select a new block to add to the container //and display it in a modal $("a[data-behaviours~=load-modal]").click(fancypages.eventHandlers.loadModal); + $("a[data-behaviours~=show-block-selection]").click(fancypages.eventHandlers.showBlockSelection); $('.edit-button').click(fancypages.eventHandlers.editWidget); $('div.delete').click(fancypages.eventHandlers.deleteWidget); @@ -350,7 +351,6 @@ fancypages.editor = { } form.data('locked', true); - //formData.container = $(form).data('container-id'); $.ajax({ url: form.attr('action'), type: "POST", diff --git a/fancypages/static/fancypages/js/event-handlers.js b/fancypages/static/fancypages/js/event-handlers.js index 07e596e..700c93c 100644 --- a/fancypages/static/fancypages/js/event-handlers.js +++ b/fancypages/static/fancypages/js/event-handlers.js @@ -72,6 +72,20 @@ fancypages.eventHandlers = { }, + /** + * Open the block selection modal and attach the container ID of the + * current element to the form to make sure that submitting it to the API + * has access to the container that tiggered the adding of content. + */ + showBlockSelection: function (ev) { + var elem = $(this), + modalElem = $(elem.data('target')), + containerId = elem.data('container-id'); + $('form', modalElem).attr('data-container-id', containerId); + $('form input[name=container]').val(containerId); + modalElem.modal('show'); + }, + /** * Load and display the content of a modal. */ diff --git a/fancypages/templates/fancypages/container.html b/fancypages/templates/fancypages/container.html index 9ac581b..51eec8f 100644 --- a/fancypages/templates/fancypages/container.html +++ b/fancypages/templates/fancypages/container.html @@ -1,6 +1,6 @@ {% load i18n %} -{% load fp_block_tags %} {% load fp_container_tags %} +{% load url from future %}
@@ -34,5 +34,13 @@
{% if request.fp_edit_mode %} - {% render_block_selection %} +
+ + {% trans "Add content" %} + +
{% endif %} diff --git a/fancypages/templates/fancypages/dashboard/block_select.html b/fancypages/templates/fancypages/dashboard/block_select.html index 3afc271..e2bb490 100644 --- a/fancypages/templates/fancypages/dashboard/block_select.html +++ b/fancypages/templates/fancypages/dashboard/block_select.html @@ -1,18 +1,8 @@ {% load i18n %} {% load staticfiles %} {% load url from future %} -
- - {% trans "Add content" %} - -
-