Changeset 13063


Ignore:
Timestamp:
Feb 9, 2012, 1:02:11 AM (9 years ago)
Author:
plg
Message:

feature 2470 added: ability to create a new album "on the fly" on the
"associate to album" action of the Batch Manager. The code was moved
from the upload form and is now used by the upload form + Batch Manager.

Location:
trunk/admin
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r12930 r13063  
    529529;';
    530530display_select_cat_wrapper($query, array(), 'associate_options', true);
     531display_select_cat_wrapper($query, array(), 'category_parent_options');
    531532
    532533// in the filter box, which category to select by default
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r12630 r13063  
    22{include file='include/datepicker.inc.tpl'}
    33{include file='include/colorbox.inc.tpl'}
     4{include file='include/add_album.inc.tpl'}
    45
    56{footer_script}{literal}
     
    645646    <!-- associate -->
    646647    <div id="action_associate" class="bulkAction">
    647           <select style="width:400px" name="associate" size="1">
     648          <select id="albumSelect" style="width:400px" name="associate" size="1">
    648649            {html_options options=$associate_options }
    649650         </select>
     651<br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
    650652    </div>
    651653
  • trunk/admin/themes/default/template/photos_add_direct.tpl

    r13018 r13063  
    88
    99{include file='include/colorbox.inc.tpl'}
     10{include file='include/add_album.inc.tpl'}
    1011
    1112{footer_script}{literal}
     
    6768    return byteSize+suffix;
    6869  }
    69 
    70   function fillCategoryListbox(selectId, selectedValue) {
    71     jQuery.getJSON(
    72       "ws.php?format=json&method=pwg.categories.getList",
    73       {
    74         recursive: true,
    75         fullname: true,
    76         format: "json",
    77       },
    78       function(data) {
    79         jQuery.each(
    80           data.result.categories,
    81           function(i,category) {
    82             var selected = null;
    83             if (category.id == selectedValue) {
    84               selected = "selected";
    85             }
    86            
    87             jQuery("<option/>")
    88               .attr("value", category.id)
    89               .attr("selected", selected)
    90               .text(category.name)
    91               .appendTo("#"+selectId)
    92               ;
    93           }
    94         );
    95       }
    96     );
    97   }
    98 
    99   jQuery(".addAlbumOpen").colorbox({
    100     inline:true,
    101     href:"#addAlbumForm",
    102     onComplete:function(){
    103       jQuery("input[name=category_name]").focus();
    104     }
    105   });
    106 
    107   jQuery("#addAlbumForm form").submit(function(){
    108       jQuery("#categoryNameError").text("");
    109 
    110       jQuery.ajax({
    111         url: "ws.php?format=json&method=pwg.categories.add",
    112         data: {
    113           parent: jQuery("select[name=category_parent] option:selected").val(),
    114           name: jQuery("input[name=category_name]").val(),
    115         },
    116         beforeSend: function() {
    117           jQuery("#albumCreationLoading").show();
    118         },
    119         success:function(html) {
    120           jQuery("#albumCreationLoading").hide();
    121 
    122           var newAlbum = jQuery.parseJSON(html).result.id;
    123           jQuery(".addAlbumOpen").colorbox.close();
    124 
    125           jQuery("#albumSelect").find("option").remove();
    126           fillCategoryListbox("albumSelect", newAlbum);
    127 
    128           /* we refresh the album creation form, in case the user wants to create another album */
    129           jQuery("#category_parent").find("option").remove();
    130 
    131           jQuery("<option/>")
    132             .attr("value", 0)
    133             .text("------------")
    134             .appendTo("#category_parent")
    135           ;
    136 
    137           fillCategoryListbox("category_parent", newAlbum);
    138 
    139           jQuery("#addAlbumForm form input[name=category_name]").val('');
    140 
    141           jQuery("#albumSelection").show();
    142 
    143           return true;
    144         },
    145         error:function(XMLHttpRequest, textStatus, errorThrows) {
    146             jQuery("#albumCreationLoading").hide();
    147             jQuery("#categoryNameError").text(errorThrows).css("color", "red");
    148         }
    149       });
    150 
    151       return false;
    152   });
    15370
    15471  jQuery("#hideErrors").click(function() {
     
    352269</div>
    353270
    354 <div style="display:none">
    355   <div id="addAlbumForm" style="text-align:left;padding:1em;">
    356     <form>
    357       {'Parent album'|@translate}<br>
    358       <select id ="category_parent" name="category_parent">
    359         <option value="0">------------</option>
    360         {html_options options=$category_parent_options selected=$category_parent_options_selected}
    361       </select>
    362 
    363       <br><br>{'Album name'|@translate}<br><input name="category_name" type="text"> <span id="categoryNameError"></span>
    364       <br><br><br><input type="submit" value="{'Create'|@translate}"> <span id="albumCreationLoading" style="display:none"><img src="themes/default/images/ajax-loader-small.gif"></span>
    365     </form>
    366   </div>
    367 </div>
    368271
    369272<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
Note: See TracChangeset for help on using the changeset viewer.