From 06e0b5004399af14908a6ce81fa8ac0fdc638c17 Mon Sep 17 00:00:00 2001 From: "Willy \"Linty" Date: Fri, 22 Dec 2023 10:20:49 +0100 Subject: [PATCH] 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. --- admin/album.php | 7 +++++- admin/tags.php | 1 + admin/themes/default/js/tags.js | 32 ++++++++++++++++++-------- admin/themes/default/template/tags.tpl | 5 +++- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/admin/album.php b/admin/album.php index 3fc91701a..010c146e4 100644 --- a/admin/album.php +++ b/admin/album.php @@ -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').' '.$category['name'].'', + 'ADMIN_PAGE_TITLE' => l10n('Edit album').' '.$category_name.'', 'ADMIN_PAGE_OBJECT_ID' => '#'.$category['id'], )); diff --git a/admin/tags.php b/admin/tags.php index c8add65fc..58cc5fe46 100644 --- a/admin/tags.php +++ b/admin/tags.php @@ -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) diff --git a/admin/themes/default/js/tags.js b/admin/themes/default/js/tags.js index 741b23f9e..92c221439 100644 --- a/admin/themes/default/js/tags.js +++ b/admin/themes/default/js/tags.js @@ -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 = $('
'+html+'
'); + .replace('%raw_name%', raw_name) + if(name == raw_name) { + html = html.replace('icon-globe', ''); + } + newTag = $('
'+html+'
'); 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); diff --git a/admin/themes/default/template/tags.tpl b/admin/themes/default/template/tags.tpl index 5f0e2d744..c8ecada69 100644 --- a/admin/themes/default/template/tags.tpl +++ b/admin/themes/default/template/tags.tpl @@ -56,7 +56,7 @@ if (!$.cookie("pwg_tags_per_page")) { {function name=tagContent} {function tagContent} -

{$tag_name}

+

{$tag_name}