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:
Willy "Linty
2023-12-22 10:20:49 +01:00
parent dca43a71bc
commit 06e0b50043
4 changed files with 33 additions and 12 deletions
+6 -1
View File
@@ -55,8 +55,13 @@ $tabsheet->assign();
// | Load the tab | // | Load the tab |
// +-----------------------------------------------------------------------+ // +-----------------------------------------------------------------------+
$category_name = trigger_change(
'render_category_name',
$category['name'],
'get_cat_display_name_cache'
);
$template->assign(array( $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'], 'ADMIN_PAGE_OBJECT_ID' => '#'.$category['id'],
)); ));
+1
View File
@@ -128,6 +128,7 @@ $all_tags = array();
while ($tag = pwg_db_fetch_assoc($result)) while ($tag = pwg_db_fetch_assoc($result))
{ {
$raw_name = $tag['name']; $raw_name = $tag['name'];
$tag['raw_name'] = $raw_name;
$tag['name'] = trigger_change('render_tag_name', $raw_name, $tag); $tag['name'] = trigger_change('render_tag_name', $raw_name, $tag);
$counter = intval(@$tag_counters[ $tag['id'] ]); $counter = intval(@$tag_counters[ $tag['id'] ]);
if ($counter > 0) if ($counter > 0)
+22 -10
View File
@@ -41,14 +41,21 @@ $('.info-warning p a').on('click', () => {
//Create and recycle tag box //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_edit = 'admin.php?page=batch_manager&filter=tag-'+id;
let u_view = 'index.php?/tags/'+id+'-'+url_name; let u_view = 'index.php?/tags/'+id+'-'+url_name;
let html = $('.tag-template').html() let html = $('.tag-template').html()
.replace(/%name%/g, unescape(name)) .replace(/%name%/g, unescape(name))
.replace('%U_VIEW%', u_view) .replace('%U_VIEW%', u_view)
.replace('%U_EDIT%', u_edit) .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")) { if ($("#toggleSelectionMode").is(":checked")) {
newTag.addClass('selection'); newTag.addClass('selection');
newTag.find(".in-selection-mode").show(); newTag.find(".in-selection-mode").show();
@@ -62,12 +69,16 @@ function createTagBox(id, name, url_name, count) {
return newTag; 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 = tagBox.first();
tagBox.attr('data-id', id); tagBox.attr('data-id', id);
tagBox.find('.tag-name, .tag-dropdown-header b').html(name); tagBox.find('.tag-name, .tag-dropdown-header b').html(name);
tagBox.find('.tag-name-editable').val(name) tagBox.find('.tag-name-editable').val(name)
tagBox.attr('data-selected', 0) tagBox.attr('data-selected', 0)
tagBox.find('.tag-name').data('rawname', raw_name);
//Dropdown //Dropdown
let u_edit = 'admin.php?page=batch_manager&filter=tag-'+id; let u_edit = 'admin.php?page=batch_manager&filter=tag-'+id;
@@ -174,6 +185,7 @@ function addTag(name) {
//Update the data //Update the data
dataTags.unshift({ dataTags.unshift({
name:data.result.name, name:data.result.name,
raw_name:data.result.name,
id:data.result.id, id:data.result.id,
url_name:data.result.url_name url_name:data.result.url_name
}); });
@@ -229,7 +241,7 @@ function setupTagbox(tagBox) {
//Edit Name //Edit Name
tagBox.find('.dropdown-option.edit').on('click', function() { 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() rename_tag_open()
}) })
@@ -255,14 +267,14 @@ function setupTagbox(tagBox) {
//Duplicate Tag //Duplicate Tag
tagBox.find('.dropdown-option.duplicate').on('click', function () { 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)) 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); $(".RenameTagPopInContainer").find(".tag-property-input").attr("id", id);
@@ -271,7 +283,7 @@ function set_up_popin(id, tagName) {
rename_tag_close() rename_tag_close()
}); });
$(".TagSubmit").html(str_yes_rename_confirmation); $(".TagSubmit").html(str_yes_rename_confirmation);
$(".RenameTagPopInContainer").find(".tag-property-input").val(tagName); $(".RenameTagPopInContainer").find(".tag-property-input").val(tagRawName);
} }
function rename_tag_close() { function rename_tag_close() {
@@ -809,7 +821,7 @@ function isSearched(tagBox, stringSearch) {
} }
function isDataSearched(tagObj) { function isDataSearched(tagObj) {
let name = tagObj.name.toLowerCase(); let name = tagObj.raw_name.toLowerCase();
let stringSearch = $("#search-tag .search-input").val(); let stringSearch = $("#search-tag .search-input").val();
if (name.includes(stringSearch.toLowerCase())) { if (name.includes(stringSearch.toLowerCase())) {
return true; return true;
@@ -968,7 +980,7 @@ function updatePage() {
for (let i = 0; i < boxToRecycle; i++) { for (let i = 0; i < boxToRecycle; i++) {
let tag = dataToDisplay[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) { if (dataToDisplay.length < tagBoxes.length) {
@@ -978,7 +990,7 @@ function updatePage() {
} else if (dataToDisplay.length > tagBoxes.length) { } else if (dataToDisplay.length > tagBoxes.length) {
for (let j = boxToRecycle; j < dataToDisplay.length; j++) { for (let j = boxToRecycle; j < dataToDisplay.length; j++) {
let tag = dataToDisplay[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); newTag.css('opacity', 0);
$('.tag-container').append(newTag); $('.tag-container').append(newTag);
setupTagbox(newTag); setupTagbox(newTag);
+4 -1
View File
@@ -56,7 +56,7 @@ if (!$.cookie("pwg_tags_per_page")) {
{function name=tagContent} {function name=tagContent}
{function 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> <a class="icon-ellipsis-vert showOptions"></a>
<div class="tag-dropdown-block dropdown"> <div class="tag-dropdown-block dropdown">
<div class="dropdown-content"> <div class="dropdown-content">
@@ -197,6 +197,7 @@ if (!$.cookie("pwg_tags_per_page")) {
tag_U_EDIT = 'admin.php?page=batch_manager&amp;filter=tag-%s'|@sprintf:$tag['id'] tag_U_EDIT = 'admin.php?page=batch_manager&amp;filter=tag-%s'|@sprintf:$tag['id']
has_image = ($tag.counter > 0) has_image = ($tag.counter > 0)
tag_count = $tag.counter tag_count = $tag.counter
tag_raw_name = $tag.raw_name
} }
{else} {else}
{tagContent {tagContent
@@ -205,6 +206,7 @@ if (!$.cookie("pwg_tags_per_page")) {
tag_U_EDIT = 'admin.php?page=batch_manager&amp;filter=tag-%s'|@sprintf:$tag['id'] tag_U_EDIT = 'admin.php?page=batch_manager&amp;filter=tag-%s'|@sprintf:$tag['id']
has_image = false has_image = false
tag_count = 0 tag_count = 0
tag_raw_name = $tag.raw_name
} }
{/if} {/if}
@@ -256,5 +258,6 @@ if (!$.cookie("pwg_tags_per_page")) {
tag_U_EDIT='%U_EDIT%' tag_U_EDIT='%U_EDIT%'
has_image=false has_image=false
tag_count='%count%' tag_count='%count%'
tag_raw_name = '%raw_name%'
} }
</div> </div>