mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
issue #2073 add raw_name in tags property
We present the raw version in the input, and on the rendered version there's a small globe to show that there's a difference between the rendered and raw versions. We have also modified the album title in the album edit page. The rendered version is now displayed, we keep the raw version in the input field.
This commit is contained in:
parent
dca43a71bc
commit
06e0b50043
4 changed files with 33 additions and 12 deletions
|
@ -55,8 +55,13 @@ $tabsheet->assign();
|
|||
// | Load the tab |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$category_name = trigger_change(
|
||||
'render_category_name',
|
||||
$category['name'],
|
||||
'get_cat_display_name_cache'
|
||||
);
|
||||
$template->assign(array(
|
||||
'ADMIN_PAGE_TITLE' => l10n('Edit album').' <strong>'.$category['name'].'</strong>',
|
||||
'ADMIN_PAGE_TITLE' => l10n('Edit album').' <strong>'.$category_name.'</strong>',
|
||||
'ADMIN_PAGE_OBJECT_ID' => '#'.$category['id'],
|
||||
));
|
||||
|
||||
|
|
|
@ -128,6 +128,7 @@ $all_tags = array();
|
|||
while ($tag = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
$raw_name = $tag['name'];
|
||||
$tag['raw_name'] = $raw_name;
|
||||
$tag['name'] = trigger_change('render_tag_name', $raw_name, $tag);
|
||||
$counter = intval(@$tag_counters[ $tag['id'] ]);
|
||||
if ($counter > 0)
|
||||
|
|
|
@ -41,14 +41,21 @@ $('.info-warning p a').on('click', () => {
|
|||
|
||||
|
||||
//Create and recycle tag box
|
||||
function createTagBox(id, name, url_name, count) {
|
||||
function createTagBox(id, name, url_name, count, raw_name = null) {
|
||||
if(raw_name === null) {
|
||||
raw_name = name
|
||||
}
|
||||
let u_edit = 'admin.php?page=batch_manager&filter=tag-'+id;
|
||||
let u_view = 'index.php?/tags/'+id+'-'+url_name;
|
||||
let html = $('.tag-template').html()
|
||||
.replace(/%name%/g, unescape(name))
|
||||
.replace('%U_VIEW%', u_view)
|
||||
.replace('%U_EDIT%', u_edit)
|
||||
newTag = $('<div class="tag-box" data-id='+id+' data-selected="0">'+html+'</div>');
|
||||
.replace('%raw_name%', raw_name)
|
||||
if(name == raw_name) {
|
||||
html = html.replace('icon-globe', '');
|
||||
}
|
||||
newTag = $('<div class="tag-box test" data-id='+id+' data-selected="0">'+html+'</div>');
|
||||
if ($("#toggleSelectionMode").is(":checked")) {
|
||||
newTag.addClass('selection');
|
||||
newTag.find(".in-selection-mode").show();
|
||||
|
@ -62,12 +69,16 @@ function createTagBox(id, name, url_name, count) {
|
|||
return newTag;
|
||||
}
|
||||
|
||||
function recycleTagBox(tagBox, id, name, url_name, count) {
|
||||
function recycleTagBox(tagBox, id, name, url_name, count, raw_name = null) {
|
||||
if(raw_name === null) {
|
||||
raw_name = name
|
||||
}
|
||||
tagBox = tagBox.first();
|
||||
tagBox.attr('data-id', id);
|
||||
tagBox.find('.tag-name, .tag-dropdown-header b').html(name);
|
||||
tagBox.find('.tag-name-editable').val(name)
|
||||
tagBox.attr('data-selected', 0)
|
||||
tagBox.find('.tag-name').data('rawname', raw_name);
|
||||
|
||||
//Dropdown
|
||||
let u_edit = 'admin.php?page=batch_manager&filter=tag-'+id;
|
||||
|
@ -174,6 +185,7 @@ function addTag(name) {
|
|||
//Update the data
|
||||
dataTags.unshift({
|
||||
name:data.result.name,
|
||||
raw_name:data.result.name,
|
||||
id:data.result.id,
|
||||
url_name:data.result.url_name
|
||||
});
|
||||
|
@ -229,7 +241,7 @@ function setupTagbox(tagBox) {
|
|||
|
||||
//Edit Name
|
||||
tagBox.find('.dropdown-option.edit').on('click', function() {
|
||||
set_up_popin(tagBox.data('id'), tagBox.find('.tag-name').html());
|
||||
set_up_popin(tagBox.data('id'), tagBox.find('.tag-name').data('rawname'), tagBox.find('.tag-name').html());
|
||||
rename_tag_open()
|
||||
})
|
||||
|
||||
|
@ -255,14 +267,14 @@ function setupTagbox(tagBox) {
|
|||
|
||||
//Duplicate Tag
|
||||
tagBox.find('.dropdown-option.duplicate').on('click', function () {
|
||||
duplicateTag(tagBox.data('id'), tagBox.find('.tag-name').html()).then((data) => {
|
||||
duplicateTag(tagBox.data('id'), tagBox.find('.tag-name').data('rawname')).then((data) => {
|
||||
showMessage(str_tag_created.replace('%s',data.result.name))
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function set_up_popin(id, tagName) {
|
||||
function set_up_popin(id, tagRawName, tagName) {
|
||||
|
||||
$(".RenameTagPopInContainer").find(".tag-property-input").attr("id", id);
|
||||
|
||||
|
@ -271,7 +283,7 @@ function set_up_popin(id, tagName) {
|
|||
rename_tag_close()
|
||||
});
|
||||
$(".TagSubmit").html(str_yes_rename_confirmation);
|
||||
$(".RenameTagPopInContainer").find(".tag-property-input").val(tagName);
|
||||
$(".RenameTagPopInContainer").find(".tag-property-input").val(tagRawName);
|
||||
}
|
||||
|
||||
function rename_tag_close() {
|
||||
|
@ -809,7 +821,7 @@ function isSearched(tagBox, stringSearch) {
|
|||
}
|
||||
|
||||
function isDataSearched(tagObj) {
|
||||
let name = tagObj.name.toLowerCase();
|
||||
let name = tagObj.raw_name.toLowerCase();
|
||||
let stringSearch = $("#search-tag .search-input").val();
|
||||
if (name.includes(stringSearch.toLowerCase())) {
|
||||
return true;
|
||||
|
@ -968,7 +980,7 @@ function updatePage() {
|
|||
|
||||
for (let i = 0; i < boxToRecycle; i++) {
|
||||
let tag = dataToDisplay[i];
|
||||
recycleTagBox($(tagBoxes[i]), tag.id, tag.name, tag.url_name, tag.counter)
|
||||
recycleTagBox($(tagBoxes[i]), tag.id, tag.name, tag.url_name, tag.counter, tag.raw_name)
|
||||
}
|
||||
|
||||
if (dataToDisplay.length < tagBoxes.length) {
|
||||
|
@ -978,7 +990,7 @@ function updatePage() {
|
|||
} else if (dataToDisplay.length > tagBoxes.length) {
|
||||
for (let j = boxToRecycle; j < dataToDisplay.length; j++) {
|
||||
let tag = dataToDisplay[j];
|
||||
newTag = createTagBox(tag.id, tag.name, tag.url_name, tag.counter);
|
||||
newTag = createTagBox(tag.id, tag.name, tag.url_name, tag.counter, tag.raw_name);
|
||||
newTag.css('opacity', 0);
|
||||
$('.tag-container').append(newTag);
|
||||
setupTagbox(newTag);
|
||||
|
|
|
@ -56,7 +56,7 @@ if (!$.cookie("pwg_tags_per_page")) {
|
|||
|
||||
{function name=tagContent}
|
||||
{function tagContent}
|
||||
<p class='tag-name'>{$tag_name}</p>
|
||||
<p class='tag-name {($tag_raw_name !== $tag_name) ? 'icon-globe' : ''}' data-rawname="{$tag_raw_name}">{$tag_name}</p>
|
||||
<a class="icon-ellipsis-vert showOptions"></a>
|
||||
<div class="tag-dropdown-block dropdown">
|
||||
<div class="dropdown-content">
|
||||
|
@ -197,6 +197,7 @@ if (!$.cookie("pwg_tags_per_page")) {
|
|||
tag_U_EDIT = 'admin.php?page=batch_manager&filter=tag-%s'|@sprintf:$tag['id']
|
||||
has_image = ($tag.counter > 0)
|
||||
tag_count = $tag.counter
|
||||
tag_raw_name = $tag.raw_name
|
||||
}
|
||||
{else}
|
||||
{tagContent
|
||||
|
@ -205,6 +206,7 @@ if (!$.cookie("pwg_tags_per_page")) {
|
|||
tag_U_EDIT = 'admin.php?page=batch_manager&filter=tag-%s'|@sprintf:$tag['id']
|
||||
has_image = false
|
||||
tag_count = 0
|
||||
tag_raw_name = $tag.raw_name
|
||||
}
|
||||
{/if}
|
||||
|
||||
|
@ -256,5 +258,6 @@ if (!$.cookie("pwg_tags_per_page")) {
|
|||
tag_U_EDIT='%U_EDIT%'
|
||||
has_image=false
|
||||
tag_count='%count%'
|
||||
tag_raw_name = '%raw_name%'
|
||||
}
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue