Skip to content
This repository
Browse code

Ensure that blocks have a name.

  • Loading branch information...
commit ced844ad91e91a4a46863924f6abee31376365f9 1 parent 8614336
Marc Worrell mworrell authored
3  .gitmodules
@@ -16,3 +16,6 @@
16 16 [submodule "deps/mimetypes"]
17 17 path = deps/mimetypes
18 18 url = git://github.com/zotonic/mimetypes.git
  19 +[submodule "deps/bert.erl"]
  20 + path = deps/bert.erl
  21 + url = git@github.com:zotonic/bert.erl.git
1  deps/bert.erl
... ... @@ -0,0 +1 @@
  1 +Subproject commit 6b142ed266c8f61b543179e01a1500fccc0b7191
27 modules/mod_admin/lib/js/apps/admin-common.js
@@ -91,6 +91,33 @@ window.zEditLanguage = function() {
91 91 }
92 92
93 93
  94 +
  95 +function z_admin_ensure_block_names() {
  96 + var names = [];
  97 + $('.blocks input.block-name').each(function() {
  98 + var name = $(this).val();
  99 + if (name != '') {
  100 + names.push(name);
  101 + }
  102 + });
  103 +
  104 + $('.blocks input.block-name').each(function() {
  105 + var name = $(this).val();
  106 + if (name == '')
  107 + {
  108 + var $block = $(this).closest(".block");
  109 + name = $("input.block-type", $block).val().split("_")[0]
  110 + var ct = 1;
  111 + while (names.indexOf(name+ct) != -1) {
  112 + ct++;
  113 + }
  114 + $("input.block-name", $block).val(name+ct);
  115 + names.push(name+ct);
  116 + }
  117 + });
  118 +}
  119 +
  120 +
94 121 tinyInit = {
95 122 mode: "none",
96 123 theme: "advanced",
3  modules/mod_admin/templates/_admin_edit_block_li.tpl
@@ -7,7 +7,7 @@
7 7 <input type="text" class="block-name" name="block-{{#s}}-name" id="block-{{#s}}-name" value="{{ blk.name|escape }}" title="{_ Block name _}" placeholder="{_ name _}" />
8 8 </h3>
9 9 <div class="widget-content">
10   - <input type="hidden" name="block-{{#s}}-type" value="{{ blk.type }}" />
  10 + <input type="hidden" class="block-type" name="block-{{#s}}-type" value="{{ blk.type }}" />
11 11 {% include ["blocks/_admin_edit_block_li_",blk.type,".tpl"]|join name=#s blk=blk id=id is_editable=is_editable is_new=is_new %}
12 12 </div>
13 13 {% if is_new %}
@@ -23,5 +23,6 @@
23 23 {% if is_new %}
24 24 {% javascript %}
25 25 $("#{{ #block }} .widget").effect("highlight");
  26 + z_admin_ensure_block_names();
26 27 {% endjavascript %}
27 28 {% endif %}

3 comments on commit ced844a

Andreas Stenius
Owner

From the commit message, I wonder if adding the bert submodule was unintentional... ?!

Marc Worrell
Owner

Indeed. Not too bad, we needed that one anyway for the mod_backup.

Andreas Stenius
Owner

Ah, ok then :)

Please sign in to comment.
Something went wrong with that request. Please try again.