fixes #556, tag manager actions in a list, not buttons

The actions are no longer displayed a individual submit buttons, but as a
select, like on other managers (users, photos, groups).

The edit/duplicate/merge forms are still displayed only after a first submit.
To be improved to be available right after the action selection.

When we display an action form edit/duplicate/merge, we don't show other
fieldsets on the page to focus on the important action.
This commit is contained in:
plegall
2016-11-29 10:51:11 +01:00
parent ef02933d57
commit c5725f3108
2 changed files with 129 additions and 16 deletions
+15 -8
View File
@@ -302,20 +302,27 @@ SELECT
if (isset($_POST['delete']) and isset($_POST['tags']))
{
$query = '
if (!isset($_POST['confirm_deletion']))
{
$page['errors'][] = l10n('You need to confirm deletion');
}
else
{
$query = '
SELECT name
FROM '.TAGS_TABLE.'
WHERE id IN ('.implode(',', $_POST['tags']).')
;';
$tag_names = array_from_query($query, 'name');
$tag_names = array_from_query($query, 'name');
delete_tags($_POST['tags']);
delete_tags($_POST['tags']);
$page['infos'][] = l10n_dec(
'The following tag was deleted', 'The %d following tags were deleted',
count($tag_names)
)
.' : '.implode(', ', $tag_names);
$page['infos'][] = l10n_dec(
'The following tag was deleted', 'The %d following tags were deleted',
count($tag_names)
)
.' : '.implode(', ', $tag_names);
}
}
// +-----------------------------------------------------------------------+
+114 -8
View File
@@ -2,6 +2,7 @@
{html_style}
.showInfo { text-indent:5px; }
.buttonLike i { font-size:14px; }
{/html_style}
{footer_script require='jquery'}
@@ -62,6 +63,68 @@ $("#searchInput").on("keydown", function(e) {
e.preventDefault();
}
});
jQuery('input[name="tags[]"]').click(function() {
var nbSelected = 0;
nbSelected = jQuery('input[name="tags[]"]').filter(':checked').length;
if (nbSelected == 0) {
jQuery("#permitAction").hide();
jQuery("#forbidAction").show();
}
else {
jQuery("#permitAction").show();
jQuery("#forbidAction").hide();
}
});
jQuery("[id^=action_]").hide();
jQuery("select[name=selectAction]").change(function () {
jQuery("[id^=action_]").hide();
jQuery("#action_"+jQuery(this).prop("value")).show();
jQuery("#displayFormBlock").hide();
jQuery("#applyActionBlock").hide();
if (jQuery(this).val() != -1 ) {
if (jQuery(this).val() == 'delete') {
jQuery("#applyActionBlock").show();
jQuery("#applyAction").attr("name", jQuery(this).val());
}
else {
jQuery("#displayForm").attr("name", jQuery(this).val());
jQuery("#displayFormBlock").show();
}
}
else {
}
});
jQuery("input[name=delete]").click(function() {
console.log("salut");
return false;
if (!jQuery("input[name=confirm_deletion]").is(":checked")) {
jQuery("#action_delete .errors").show();
return false;
}
});
jQuery("form").submit(function() {
console.log("hello");
if (jQuery("select[name=selectAction]").val() == "delete") {
if (!jQuery("input[name=confirm_deletion]").is(":checked")) {
jQuery("#action_delete .errors").show();
return false;
}
}
/* return false; */
});
jQuery("input[name=confirm_deletion]").change(function() {
jQuery("#action_delete .errors").hide();
});
{/footer_script}
@@ -70,6 +133,8 @@ $("#searchInput").on("keydown", function(e) {
</div>
<form action="{$F_ACTION}" method="post">
<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
{if isset($EDIT_TAGS_LIST)}
<fieldset>
<legend>{'Edit tags'|@translate}</legend>
@@ -148,11 +213,13 @@ $("#searchInput").on("keydown", function(e) {
<p><input class="submit" type="submit" name="add" value="{'Submit'|@translate}"></p>
</fieldset>
{if !isset($EDIT_TAGS_LIST) and !isset($DUPLIC_TAGS_LIST) and !isset($MERGE_TAGS_LIST)}
<fieldset>
<legend>{'Tag selection'|@translate}</legend>
{if count($all_tags)}
<div><label><span class="icon-filter" style="visibility:hidden" id="filterIcon"></span>{'Search'|@translate}: <input id="searchInput" type="text" size="12"></label></div>
<div><label><span class="icon-filter" style="visibility:hidden" id="filterIcon"></span>{'Search'|@translate} <input id="searchInput" type="text" size="12"></label></div>
{/if}
<ul class="tagSelection">
@@ -172,13 +239,52 @@ $("#searchInput").on("keydown", function(e) {
{/foreach}
</ul>
<p>
<input type="hidden" name="pwg_token" value="{$PWG_TOKEN}">
<input type="submit" name="edit" value="{'Edit selected tags'|@translate}">
<input type="submit" name="duplicate" value="{'Duplicate selected tags'|@translate}">
<input type="submit" name="merge" value="{'Merge selected tags'|@translate}">
<input type="submit" name="delete" value="{'Delete selected tags'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');">
</p>
</fieldset>
<fieldset id="action">
<legend>{'Action'|@translate}</legend>
<div id="forbidAction">{'No tag selected, no action possible.'|@translate}</div>
<div id="permitAction" style="display:none">
<select name="selectAction">
<option value="-1">{'Choose an action'|@translate}</option>
<option disabled="disabled">------------------</option>
<option value="edit">{'Edit selected tags'|@translate}</option>
<option value="duplicate">{'Duplicate selected tags'|@translate}</option>
<option value="merge">{'Merge selected tags'|@translate}</option>
<option value="delete">{'Delete selected tags'|@translate}</option>
{if !empty($tag_manager_plugin_actions)}
{foreach from=$tag_manager_plugin_actions item=action}
<option value="{$action.ID}">{$action.NAME}</option>
{/foreach}
{/if}
</select>
<!-- delete -->
<div id="action_delete" class="bulkAction">
<p>
<label><input type="checkbox" name="confirm_deletion" value="1"> {'Are you sure?'|@translate}</label>
<span class="errors" style="display:none"><i class="icon-cancel"></i> we really need you to confirm</span>
</p>
</div>
{* plugins *}
{if !empty($tag_manage_plugin_actions)}
{foreach from=$element_set_groupe_plugins_actions item=action}
<div id="action_{$action.ID}" class="bulkAction">
{if !empty($action.CONTENT)}{$action.CONTENT}{/if}
</div>
{/foreach}
{/if}
<span id="displayFormBlock" style="display:none">
<button id="displayForm" class="buttonLike" type="submit" name="">{'Display form'|translate} <i class="icon-right"></i></button>
</span>
<p id="applyActionBlock" style="display:none" class="actionButtons">
<input id="applyAction" class="submit" type="submit" value="{'Apply action'|@translate}" name=""> <span id="applyOnDetails"></span>
</p>
</div> {* #permitAction *}
</fieldset>
{/if}
</form>