[7196] | 1 | {literal} |
---|
| 2 | <style type='text/css'> |
---|
| 3 | #iASECategoryCategory { |
---|
| 4 | width:500px; |
---|
| 5 | } |
---|
| 6 | </style> |
---|
| 7 | |
---|
| 8 | <script type="text/javascript"> |
---|
| 9 | /** |
---|
| 10 | * include this template in a page and use dialogChooseASECategoryBox.show({options}) to display |
---|
| 11 | * the dialog box |
---|
| 12 | * |
---|
| 13 | */ |
---|
| 14 | dialogChooseASECategoryBox = function() |
---|
| 15 | { |
---|
| 16 | var dialogOptions = { |
---|
| 17 | id:'', |
---|
| 18 | eventOk:null, |
---|
| 19 | cBuilder:null, |
---|
| 20 | |
---|
| 21 | values: { |
---|
| 22 | subCat:'=', |
---|
| 23 | catIdList:new Array() |
---|
| 24 | }, |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * initialize the dialog box |
---|
| 29 | */ |
---|
| 30 | var initDialogBox = function() |
---|
| 31 | { |
---|
| 32 | $("#iDialogASECategoryChoose") |
---|
| 33 | .dialog( |
---|
| 34 | { |
---|
| 35 | autoOpen: false, |
---|
| 36 | resizable: false, |
---|
| 37 | width:765, |
---|
[7328] | 38 | height:200, |
---|
[7196] | 39 | modal: true, |
---|
| 40 | draggable:true, |
---|
| 41 | dialogClass: 'gcBgTabSheet gcBorder', |
---|
| 42 | title: '{/literal}{"ase_choose_categories"|@translate}{literal}', |
---|
| 43 | open: function(event, ui) |
---|
| 44 | { |
---|
| 45 | }, |
---|
| 46 | buttons: |
---|
| 47 | { |
---|
| 48 | '{/literal}{"ase_ok"|@translate}{literal}': |
---|
| 49 | function() |
---|
| 50 | { |
---|
| 51 | if(checkValidity()) |
---|
| 52 | { |
---|
| 53 | dialogOptions.values.catIdList=$('#iASECategoryCategory').categorySelector('value'); |
---|
| 54 | dialogOptions.values.subCat=$('#iASECategorySubCat').val(); |
---|
| 55 | |
---|
| 56 | |
---|
| 57 | if(dialogOptions.cBuilder!=null) |
---|
| 58 | { |
---|
| 59 | setCBuilderItem(dialogOptions.id, dialogOptions.values); |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | if(dialogOptions.eventOk!=null) |
---|
| 63 | { |
---|
| 64 | dialogOptions.eventOk(dialogOptions.id, dialogOptions.values); |
---|
| 65 | } |
---|
| 66 | $(this).dialog('close'); |
---|
| 67 | } |
---|
| 68 | }, |
---|
| 69 | '{/literal}{"ase_cancel"|@translate}{literal}': |
---|
| 70 | function() |
---|
| 71 | { |
---|
| 72 | $(this).dialog('close'); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | ) |
---|
| 77 | .parent().css('overflow', 'visible'); |
---|
| 78 | |
---|
| 79 | |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | $('#iASECategoryCategory').categorySelector( |
---|
| 83 | { |
---|
| 84 | multiple:true, |
---|
| 85 | listMaxWidth:1, |
---|
| 86 | listMaxHeight:350, |
---|
[7318] | 87 | displayStatus:{/literal}{if is_admin()}true{else}false{/if}{literal}, |
---|
[7196] | 88 | levelIndent:20, |
---|
[7318] | 89 | userMode:{/literal}{if is_admin()}'admin'{else}'public'{/if}{literal}, |
---|
[7196] | 90 | galleryRoot:false, |
---|
| 91 | load: function (event) { $(this).categorySelector('collapse', ':all'); } |
---|
| 92 | } |
---|
| 93 | ); |
---|
| 94 | |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * check the validity of the condition |
---|
| 100 | * return Boolean : true if OK, otherwise false |
---|
| 101 | */ |
---|
| 102 | var checkValidity = function () |
---|
| 103 | { |
---|
| 104 | |
---|
| 105 | if($('#iASECategoryCategory').categorySelector('value') .length==0) |
---|
| 106 | { |
---|
| 107 | alert('ase_one_category_must_be_selected'); |
---|
| 108 | return(false); |
---|
| 109 | } |
---|
| 110 | return(true); |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * the show() function display and manage a dialog box to choose categories |
---|
| 116 | * and the kind of test to apply |
---|
| 117 | * |
---|
| 118 | * @param options : properties to manage the dialog box |
---|
| 119 | * - id : a string to identify a DOM object ; this parameter |
---|
| 120 | * is given to the callback when the OK button is pushed |
---|
| 121 | * - values : an object with 2 properties |
---|
| 122 | * - subCat : true or false, search in subcategories |
---|
| 123 | * - catIdList : an array of categories Id |
---|
| 124 | * - eventOK : a callback function, with 2 parameters : id of |
---|
| 125 | * the given DOM object and values parameted |
---|
| 126 | * - cBuilder : a criteriaBuilder object |
---|
| 127 | * if set, the dialog box manage automaticaly |
---|
| 128 | * the criteria builder interface |
---|
| 129 | */ |
---|
| 130 | this.show = function (options) |
---|
| 131 | { |
---|
| 132 | showDialog(options); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | /** |
---|
| 136 | * private function used to show the dialog box |
---|
| 137 | */ |
---|
| 138 | var showDialog = function(options) |
---|
| 139 | { |
---|
| 140 | if(options.id!=null) |
---|
| 141 | { |
---|
| 142 | dialogOptions.id=options.id; |
---|
| 143 | } |
---|
| 144 | else |
---|
| 145 | { |
---|
| 146 | dialogOptions.id=''; |
---|
| 147 | } |
---|
| 148 | |
---|
| 149 | if(options.eventOk!=null) |
---|
| 150 | { |
---|
| 151 | dialogOptions.eventOk=options.eventOk; |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | if(options.cBuilder!=null) |
---|
| 155 | { |
---|
| 156 | dialogOptions.cBuilder=options.cBuilder; |
---|
| 157 | dialogOptions.cBuilder.doAction('setOptions', |
---|
| 158 | { |
---|
| 159 | onEdit:function (e) { editCB(e.data); }, |
---|
| 160 | onDelete:function (e) { deleteCB(e.data); }, |
---|
| 161 | } |
---|
| 162 | ); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | if(options.values!=null) |
---|
| 166 | { |
---|
| 167 | dialogOptions.values=jQuery.extend(dialogOptions.values, options.values); |
---|
| 168 | } |
---|
| 169 | else |
---|
| 170 | { |
---|
| 171 | dialogOptions.values.subCat='y'; |
---|
| 172 | dialogOptions.values.catIdList=0; |
---|
| 173 | } |
---|
| 174 | $('#iASECategorySubCat').val(dialogOptions.values.subCat); |
---|
| 175 | $('#iASECategoryCategory').categorySelector('value', ':none'); |
---|
| 176 | $('#iASECategoryCategory').categorySelector('value', dialogOptions.values.catIdList); |
---|
| 177 | $('#iASECategoryCategory').categorySelector('collapse', ':all'); |
---|
| 178 | for(var i=0;i<dialogOptions.values.catIdList.length;i++) |
---|
| 179 | { |
---|
| 180 | $('#iASECategoryCategory').categorySelector('expand', dialogOptions.values.catIdList[i]+'<'); |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | |
---|
| 184 | $("#iDialogASECategoryChoose").dialog('open'); |
---|
| 185 | } |
---|
| 186 | |
---|
| 187 | |
---|
| 188 | |
---|
| 189 | /** |
---|
| 190 | * manage the 'edit' button from criteria builder interface |
---|
| 191 | * @param String itemId : the itemId |
---|
| 192 | */ |
---|
| 193 | var editCB = function (itemId) |
---|
| 194 | { |
---|
| 195 | extraData=dialogOptions.cBuilder.doAction('getExtraData', itemId); |
---|
| 196 | showDialog( |
---|
| 197 | { |
---|
| 198 | id:itemId, |
---|
| 199 | values: |
---|
| 200 | { |
---|
| 201 | subCat:extraData.param.subCat, |
---|
| 202 | catIdList:extraData.param.catIdList, |
---|
| 203 | }, |
---|
| 204 | } |
---|
| 205 | ); |
---|
| 206 | } |
---|
| 207 | |
---|
| 208 | /** |
---|
| 209 | * manage the 'delete' button from criteria builder interface |
---|
| 210 | * @param String itemId : the itemId |
---|
| 211 | */ |
---|
| 212 | var deleteCB = function (itemId) |
---|
| 213 | { |
---|
| 214 | dialogOptions.cBuilder.doAction('delete', itemId); |
---|
| 215 | } |
---|
| 216 | |
---|
| 217 | /** |
---|
| 218 | * set the content for the cBuilder item |
---|
| 219 | */ |
---|
| 220 | var setCBuilderItem = function(id) |
---|
| 221 | { |
---|
| 222 | var content="<div>", |
---|
| 223 | list=$('#iASECategoryCategory').categorySelector('name'); |
---|
| 224 | |
---|
| 225 | if(dialogOptions.values.catIdList.length==1) |
---|
| 226 | { |
---|
| 227 | content+="{/literal}{'ase_category'|@translate}{literal}"; |
---|
| 228 | } |
---|
| 229 | else |
---|
| 230 | { |
---|
| 231 | content+="{/literal}{'ase_categories'|@translate}{literal}"; |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | if(dialogOptions.values.subCat=='y') |
---|
| 235 | { |
---|
| 236 | content+=" ({/literal}{'ase_with_search_in_subcat'|@translate}{literal})"; |
---|
| 237 | } |
---|
| 238 | content+=" :"; |
---|
| 239 | |
---|
| 240 | |
---|
[7374] | 241 | content+="<div style='font-style:italic;padding-left:15px;'>" |
---|
[7196] | 242 | for(i=0;i<list.length;i++) |
---|
| 243 | { |
---|
[7374] | 244 | content+=list[i]+"<br>"; |
---|
[7196] | 245 | } |
---|
| 246 | |
---|
[7374] | 247 | content+="</div></div>"; |
---|
[7196] | 248 | |
---|
| 249 | |
---|
| 250 | if(id=='') |
---|
| 251 | { |
---|
| 252 | //no id:add a new item in the list |
---|
| 253 | dialogOptions.cBuilder.doAction( |
---|
| 254 | 'add', |
---|
| 255 | content, |
---|
| 256 | criteriaBuilder.makeExtendedData( |
---|
| 257 | 'ASECategory', |
---|
| 258 | { |
---|
| 259 | subCat:dialogOptions.values.subCat, |
---|
| 260 | catIdList:dialogOptions.values.catIdList |
---|
| 261 | } |
---|
| 262 | ) |
---|
| 263 | ); |
---|
| 264 | } |
---|
| 265 | else |
---|
| 266 | { |
---|
| 267 | // update item |
---|
| 268 | dialogOptions.cBuilder.doAction( |
---|
| 269 | 'edit', |
---|
| 270 | id, |
---|
| 271 | content, |
---|
| 272 | criteriaBuilder.makeExtendedData( |
---|
| 273 | 'ASECategory', |
---|
| 274 | { |
---|
| 275 | subCat:dialogOptions.values.subCat, |
---|
| 276 | catIdList:dialogOptions.values.catIdList |
---|
| 277 | } |
---|
| 278 | ) |
---|
| 279 | ); |
---|
| 280 | } |
---|
| 281 | } |
---|
| 282 | |
---|
| 283 | initDialogBox(); |
---|
| 284 | } |
---|
| 285 | |
---|
| 286 | |
---|
| 287 | </script> |
---|
| 288 | {/literal} |
---|
| 289 | |
---|
| 290 | <div id="iDialogASECategoryChoose" style='display:none;'> |
---|
| 291 | |
---|
| 292 | <table class="formtable"> |
---|
| 293 | <tr> |
---|
| 294 | <td>{'ase_categories'|@translate}</td> |
---|
| 295 | <td> |
---|
| 296 | <div id='iASECategoryCategory'></div> |
---|
| 297 | </td> |
---|
| 298 | </tr> |
---|
| 299 | |
---|
| 300 | <tr> |
---|
| 301 | <td>{'ase_searching_in_subcat'|@translate}</td> |
---|
| 302 | <td> |
---|
| 303 | <select id='iASECategorySubCat'> |
---|
| 304 | <option value='y'>{'ase_y'|@translate}</option> |
---|
| 305 | <option value='n'>{'ase_n'|@translate}</option> |
---|
| 306 | </select> |
---|
| 307 | </td> |
---|
| 308 | </tr> |
---|
| 309 | </table> |
---|
| 310 | |
---|
| 311 | </div> |
---|
| 312 | |
---|
| 313 | |
---|