filter "dissociate" action + display bug of Selectize widget
git-svn-id: http://piwigo.org/svn/trunk@29760 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
3ef5464b26
commit
9d0357e889
2 changed files with 26 additions and 4 deletions
|
|
@ -529,6 +529,25 @@ SELECT category_id
|
||||||
|
|
||||||
$template->assign('filter_category_selected', $selected_category);
|
$template->assign('filter_category_selected', $selected_category);
|
||||||
|
|
||||||
|
// Dissociate from a category : categories listed for dissociation can only
|
||||||
|
// represent virtual links. We can't create orphans. Links to physical
|
||||||
|
// categories can't be broken.
|
||||||
|
if (count($page['cat_elements_id']) > 0)
|
||||||
|
{
|
||||||
|
$query = '
|
||||||
|
SELECT
|
||||||
|
DISTINCT(category_id) AS id
|
||||||
|
FROM '.IMAGE_CATEGORY_TABLE.' AS ic
|
||||||
|
JOIN '.IMAGES_TABLE.' AS i ON i.id = ic.image_id
|
||||||
|
WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).')
|
||||||
|
AND (
|
||||||
|
ic.category_id != i.storage_category_id
|
||||||
|
OR i.storage_category_id IS NULL
|
||||||
|
)
|
||||||
|
;';
|
||||||
|
|
||||||
|
$template->assign('associated_categories', query2array($query, 'id', 'id'));
|
||||||
|
}
|
||||||
|
|
||||||
if (count($page['cat_elements_id']) > 0)
|
if (count($page['cat_elements_id']) > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -43,16 +43,17 @@ jQuery(document).ready(function() {
|
||||||
serverId: '{$CACHE_KEYS._hash}',
|
serverId: '{$CACHE_KEYS._hash}',
|
||||||
rootUrl: '{$ROOT_URL}'
|
rootUrl: '{$ROOT_URL}'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var associated_categories = {$associated_categories|@json_encode};
|
||||||
|
|
||||||
categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
|
categoriesCache.selectize(jQuery('[data-selectize=categories]'), {
|
||||||
filter: function(categories, options) {
|
filter: function(categories, options) {
|
||||||
if (this.name == 'dissociate') {
|
if (this.name == 'dissociate') {
|
||||||
var filtered = jQuery.grep(categories, function(cat) {
|
var filtered = jQuery.grep(categories, function(cat) {
|
||||||
return !cat.dir;
|
return !!associated_categories[cat.id];
|
||||||
});
|
});
|
||||||
|
|
||||||
if (filtered.length > 0) {
|
if (filtered.length > 0) {
|
||||||
jQuery('.albumDissociate').show();
|
|
||||||
options.default = filtered[0].id;
|
options.default = filtered[0].id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -552,7 +553,9 @@ UL.thumbnails SPAN.wrap2 {ldelim}
|
||||||
<option value="delete" class="icon-trash">{'Delete selected photos'|@translate}</option>
|
<option value="delete" class="icon-trash">{'Delete selected photos'|@translate}</option>
|
||||||
<option value="associate">{'Associate to album'|@translate}</option>
|
<option value="associate">{'Associate to album'|@translate}</option>
|
||||||
<option value="move">{'Move to album'|@translate}</option>
|
<option value="move">{'Move to album'|@translate}</option>
|
||||||
<option value="dissociate" class="albumDissociate" style="display:none">{'Dissociate from album'|@translate}</option>
|
{if !empty($associated_categories)}
|
||||||
|
<option value="dissociate">{'Dissociate from album'|@translate}</option>
|
||||||
|
{/if}
|
||||||
<option value="add_tags">{'Add tags'|@translate}</option>
|
<option value="add_tags">{'Add tags'|@translate}</option>
|
||||||
{if !empty($associated_tags)}
|
{if !empty($associated_tags)}
|
||||||
<option value="del_tags">{'remove tags'|@translate}</option>
|
<option value="del_tags">{'remove tags'|@translate}</option>
|
||||||
|
|
@ -597,7 +600,7 @@ UL.thumbnails SPAN.wrap2 {ldelim}
|
||||||
|
|
||||||
|
|
||||||
<!-- dissociate -->
|
<!-- dissociate -->
|
||||||
<div id="action_dissociate" class="bulkAction albumDissociate" style="display:none">
|
<div id="action_dissociate" class="bulkAction">
|
||||||
<select data-selectize="categories" placeholder="{'Type in a search term'|translate}"
|
<select data-selectize="categories" placeholder="{'Type in a search term'|translate}"
|
||||||
name="dissociate" style="width:600px"></select>
|
name="dissociate" style="width:600px"></select>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue