diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-07-25 13:58:17 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-07-25 13:58:17 (GMT) |
commit | f7d18490894ca9f23fbeb66a9f20b6b9599d24eb (patch) | |
tree | db9f59b90fc770eba833f438b6610957fb688c2e | |
parent | 8a196bde827727464b301935d12551c653438319 (diff) |
Bug Fix: Issue #3823
-rw-r--r-- | webapp/polls/templates/mustache/option_image_upload.html | 7 | ||||
-rw-r--r-- | webapp/webapp/static/js/dynamic_structure.js | 29 |
2 files changed, 29 insertions, 7 deletions
diff --git a/webapp/polls/templates/mustache/option_image_upload.html b/webapp/polls/templates/mustache/option_image_upload.html index 477c86f..b8fa886 100644 --- a/webapp/polls/templates/mustache/option_image_upload.html +++ b/webapp/polls/templates/mustache/option_image_upload.html @@ -2,6 +2,11 @@ <script type="text/x-mustache-template" name="field_option_image_upload"> <div class="fileupload fileupload-new span3 well well-small WFieldImageOption_container" data-provides="fileupload" style="margin: 10px;"> + <span class="pull-right"> + <a href="#" class="WFieldImageOptions_remove_button btn btn-danger"> + <i class="icon-trash icon-white"></i> + </a> + </span> <label> <b>ID</b>: <span class="draggable"><i class="icon-move"></i>[[ id ]]</span> </label><br /> @@ -17,7 +22,7 @@ type="text" name="groups.[[ group_order ]].fields.[[ field_order ]].options.[[ id ]].text" value="[[ text ]]" - placeholder="(texto opcional)" /> + placeholder='(texto opcional)' /> <br /> <b>Peso</b>: <input diff --git a/webapp/webapp/static/js/dynamic_structure.js b/webapp/webapp/static/js/dynamic_structure.js index f2488ff..1773100 100644 --- a/webapp/webapp/static/js/dynamic_structure.js +++ b/webapp/webapp/static/js/dynamic_structure.js @@ -127,6 +127,17 @@ var factoryImageOptionUpload = function(id, value, container, group_order, field if (row_fluid.size() == 0) row_fluid = $('<div class="row-fluid"></div>'); + // Get remove option button and bind with remove option event + option.find('.WFieldImageOptions_remove_button').on('click', function(event) { + event.preventDefault(); + + if(confirm('La opciĆ³n ' + id + ' va a ser eliminada.')) { + var container_row_fuild = option.parent(".row-fluid"); + + option.remove(); + } + }); + // Draggable option ID to droppable dependence field option.find(".draggable") .draggable({'helper': 'clone'}) @@ -335,7 +346,8 @@ var bindFieldWidgetTypeSelectBox = function(widget_types_select_box) { container = field_widget.find('.WFieldOptions_container'), buttons_container = field_widget.find('.WFieldAddOptionButton_container'), field_order = parseInt(field_widget.find(".field_order").attr("value")), - add_option_button; + add_option_button, + add_option_none_button; // Get current selected widget type for current field var current_widget_type = $(this).attr('value'); @@ -343,6 +355,11 @@ var bindFieldWidgetTypeSelectBox = function(widget_types_select_box) { // Clear all options container.contents().remove(); + add_option_none_button = buttons_container.find('.WFieldOptionsNone_add_button').find('button'); + if ($.inArray(current_widget_type, ["MultipleCheckBox", "ImageCheckBox"]) == -1) { + add_option_none_button.remove(); + } + if ($.inArray(current_widget_type, WITH_OPTIONS) == -1) { // Not need options -> remove add_option_button and show option default add_option_button = buttons_container.find('.WFieldOptions_add_button').find('button'); @@ -356,11 +373,11 @@ var bindFieldWidgetTypeSelectBox = function(widget_types_select_box) { buttons_container.append(add_option_button); // Bind add option button bindFieldAddOptionButton(add_option_button); - if ($.inArray(current_widget_type, ["MultipleCheckBox", "ImageCheckBox"]) != -1) { - var add_option_none_button = $(Mustache.render(TEMPLATES['field_add_option_none_button'], {})); - buttons_container.append(add_option_none_button); - bindFieldAddOptionButton(add_option_none_button, {none: 'True'}); - } + } + if (!add_option_none_button.length && $.inArray(current_widget_type, ["MultipleCheckBox", "ImageCheckBox"]) != -1) { + var add_option_none_button = $(Mustache.render(TEMPLATES['field_add_option_none_button'], {})); + buttons_container.append(add_option_none_button); + bindFieldAddOptionButton(add_option_none_button, {none: 'True'}); } } |