Skip to content

Commit

Permalink
related to #1704 Added alert is album is locked
Browse files Browse the repository at this point in the history
* Corrected french sentences spelled wrong
* Added max length for album names in breadcrumbs
* Added attribute 'visible' in categories.setInfos
* Can now unlock an album by clicking on the alert
* Switch used to lock an album works properly now
  • Loading branch information
MatthieuLP committed Jan 4, 2023
1 parent 4729504 commit 4e899b5
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 10 deletions.
5 changes: 4 additions & 1 deletion admin/cat_modify.php
Expand Up @@ -159,6 +159,9 @@ function get_site_url($category_id)
$self_url.= '&parent_id='.$category['id_uppercat'];
}

// We show or hide this warning in JS
$page['warnings'][] = l10n('This album is currently locked, visible only to administrators.').'<span class="icon-key unlock-album">'.l10n('Unlock it').'</span>';

$template->assign(
array(
'CATEGORIES_NAV' => preg_replace("# {2,}#"," ",preg_replace("#(\r\n|\n\r|\n|\r)#"," ",$navigation)),
Expand All @@ -167,7 +170,7 @@ function get_site_url($category_id)
'CAT_ID' => $category['id'],
'CAT_NAME' => @htmlspecialchars($category['name']),
'CAT_COMMENT' => @htmlspecialchars($category['comment']),
'IS_LOCKED' => $category['status'] == "private",
'IS_VISIBLE' => boolean_to_string($category['visible']),

'U_DELETE' => $base_url.'albums',

Expand Down
69 changes: 66 additions & 3 deletions admin/themes/default/js/cat_modify.js
@@ -1,6 +1,56 @@
jQuery(document).ready(function() {

activateCommentDropdown()
activateCommentDropdown();
checkAlbumLock();

$(".unlock-album").on('click', function () {
jQuery.ajax({
url: "ws.php?format=json&method=pwg.categories.setInfo",
type:"POST",
dataType: "json",
data: {
category_id: album_id,
visible: 'true',
},
success:function(data) {
if (data.stat == "ok") {

is_visible = 'true';
if ($("#cat-locked").is(":checked")) {
$("input[id='cat-locked']").trigger('click');
}
checkAlbumLock();

setTimeout(
function() {
$('.info-message').hide()
},
5000
)
} else {
$('.info-error').show()
setTimeout(
function() {
$('.info-error').hide()
},
5000
)
}
},
error:function(XMLHttpRequest, textStatus, errorThrows) {
save_button_set_loading(false)

$('.info-error').show()
setTimeout(
function() {
$('.info-error').hide()
},
5000
)
console.log(errorThrows);
}
});
})

jQuery('.tiptip').tipTip({
'delay' : 0,
Expand All @@ -21,8 +71,8 @@ jQuery(document).ready(function() {
category_id: album_id,
name: $("#cat-name").val(),
comment: $("#cat-comment").val(),
status: $("#cat-locked").is(":checked")? "public":"private",
commentable: $("#cat-commentable").is(":checked")? "true":"false",
visible: $("#cat-locked").is(":checked") ? 'false' : 'true',
commentable: $("#cat-commentable").is(":checked") ? "true":"false",
apply_commentable_to_subalbums: $("#cat-apply-commentable-on-sub").is(":checked")? "true":"false",
},
success:function(data) {
Expand All @@ -32,6 +82,10 @@ jQuery(document).ready(function() {
$('.info-message').show()
$('.cat-modification .cat-modify-info-subcontent').html(str_just_now)
$('.cat-modification .cat-modify-info-content').html(str_just_now)

is_visible = $("#cat-locked").is(":checked") ? 'false' : 'true';
checkAlbumLock();

setTimeout(
function() {
$('.info-message').hide()
Expand Down Expand Up @@ -410,6 +464,15 @@ jQuery(document).ready(function() {
});
});

function checkAlbumLock() {
console.log(is_visible);
if (is_visible == 'true') {
$(".warnings").hide();
} else {
$(".warnings").show();
}
}

// Parent album popin functions
function set_up_popin() {
$(".ClosePopIn").on('click', function () {
Expand Down
5 changes: 3 additions & 2 deletions admin/themes/default/template/cat_modify.tpl
Expand Up @@ -17,6 +17,7 @@ const album_name = "{$CAT_NAME}"
const nb_sub_albums = {$NB_SUBCATS}
const pwg_token = '{$PWG_TOKEN}'
const u_delete = '{$U_DELETE}'
var is_visible = '{$IS_VISIBLE}'

const str_cancel = '{'No, I have changed my mind'|@translate|@escape}'
const str_delete_album = '{'Delete album'|@translate|escape:javascript}'
Expand Down Expand Up @@ -170,12 +171,12 @@ str_root = '{'Root'|@translate}';
<div class="cat-modify-switch-container">
<div class="switch-input">
<label class="switch">
<input type="checkbox" name="locked" id="cat-locked" value="true" {if !$IS_LOCKED}checked{/if}>
<input type="checkbox" name="locked" id="cat-locked" value="true" {if $IS_VISIBLE == 'false'}checked{/if}>
<span class="slider round"></span>
</label>

</div>
<label class="switch-label" for="cat-locked"><span>{'Unlocked album'|@translate}</span> <i class="icon-help-circled tiptip" title="{'Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'|@translate}" style="cursor:help"></i></label>
<label class="switch-label" for="cat-locked"><span>{'Locked album'|@translate}</span> <i class="icon-help-circled tiptip" title="{'Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'|@translate}" style="cursor:help"></i></label>
</div>
</div>
</div>
Expand Down
23 changes: 23 additions & 0 deletions admin/themes/default/theme.css
Expand Up @@ -404,6 +404,10 @@ LI.menuLi {
}

/* Cat Modify */
.unlock-album {
cursor: pointer;
}

.cat-modify {
height: calc(100vh - 192px);
width: calc(100vw - 205px);
Expand All @@ -425,6 +429,25 @@ LI.menuLi {
}
.cat-modify-ariane a {
white-space: nowrap;
max-width: 300px;
overflow: hidden;
text-overflow: ellipsis;
}

#cat-parent {
display: flex;
flex-direction: row;
white-space: nowrap;
flex-wrap: wrap;
}
#cat-parent span {
margin: 0 5px;
}
#cat-parent a {
max-width: 175px;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}

.cat-modify-ariane > * {
Expand Down
3 changes: 2 additions & 1 deletion include/ws_functions/pwg.categories.php
Expand Up @@ -753,6 +753,7 @@ function ws_categories_setRank($params, &$service)
* @option int cat_id
* @option string name (optional)
* @option string status (optional)
* @option bool visible (optional)
* @option string comment (optional)
* @option bool commentable (optional)
* @option bool apply_commentable_to_subalbums (optional)
Expand Down Expand Up @@ -791,7 +792,7 @@ function ws_categories_setInfo($params, &$service)
'id' => $params['category_id'],
);

$info_columns = array('name', 'comment','commentable');
$info_columns = array('name', 'comment','commentable', 'visible');

$perform_update = false;
foreach ($info_columns as $key)
Expand Down
5 changes: 4 additions & 1 deletion language/en_UK/admin.lang.php
Expand Up @@ -1258,7 +1258,7 @@
$lang['action successfully performed.'] = 'action successfully performed.';
$lang['%s lines'] = "%s lines";
$lang['%s line'] = "%s line";
$lang['Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'] = 'Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Locking this album will also lock its sub-albums';
$lang['Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'] = 'Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Locking this album will also lock its sub-albums.';
$lang['Webmaster status required'] = 'Webmaster status required';
$lang['%s plugins found'] = '<b>%s</b> plugins found';
$lang['%s plugin found'] = '<b>%s</b> plugin found';
Expand Down Expand Up @@ -1342,4 +1342,7 @@
$lang['%d lineage pictures'] = '%d lineage pictures';
$lang['Put at the root'] = 'Put at the root';
$lang['or'] = 'or';
$lang['Locked album'] = 'Locked album';
$lang['This album is currently locked, visible only to administrators.'] = 'This album is currently locked, visible only to administrators.';
$lang['Unlock it'] = 'Unlock it';
// Leave this line empty
7 changes: 5 additions & 2 deletions language/fr_FR/admin.lang.php
Expand Up @@ -1261,7 +1261,7 @@
$lang['action successfully performed.'] = 'action effectuée avec succès.';
$lang['%s lines'] = "%s lignes";
$lang['%s line'] = "%s ligne";
$lang['Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'] = 'Les albums vérrouillés sont désactivé pour maintenance. Seul les administrateurs peuvent les voir dans la gallerie. Vérrouiller cet album vérouillera aussi ses sous-albums';
$lang['Locked albums are disabled for maintenance. Only administrators can view them in the gallery. Lock this album will also lock his Sub-albums'] = 'Les albums verrouillés sont désactivés pour maintenance. Seuls les administrateurs peuvent les voir dans la galerie. Verrouiller cet album verrouillera aussi ses sous-albums.';
$lang['Webmaster status required'] = 'Statut Webmaster nécéssaire';
$lang['%s plugins found'] = '<b>%s</b> plugins trouvés';
$lang['%s plugin found'] = '<b>%s</b> plugin trouvé';
Expand Down Expand Up @@ -1314,7 +1314,7 @@
$lang['Picture to associate formats with'] = 'Photo à associer avec les formats';
$lang['The original picture will be detected with the filename (without extension).'] = 'La photo originale sera détectée en comparant les noms des fichiers (sans extension).';
$lang['Delete %s format ?'] = 'Supprimer le format %s ?';
$lang['Unlocked album'] = 'Album dévérouillé';
$lang['Unlocked album'] = 'Album déverouillé';
$lang['Created'] = 'Créé';
$lang['Modified'] = 'Modifié';
$lang['%d including sub-albums'] = '%d en incluant les sous-albums';
Expand Down Expand Up @@ -1342,4 +1342,7 @@
$lang['Comments disallowed for sub-albums'] = 'Commentaires interdit pour tous les sous-albums';
$lang['Put at the root'] = 'Placer à la racine';
$lang['or'] = 'ou';
$lang['Locked album'] = 'Album verrouillé';
$lang['This album is currently locked, visible only to administrators.'] = 'Cet album est actuellement verrouillé, visible uniquement par les administrateurs.';
$lang['Unlock it'] = 'Le déverrouiller';
// Leave this line empty
2 changes: 2 additions & 0 deletions ws.php
Expand Up @@ -854,6 +854,8 @@ function ws_addDefaultMethods( $arr )
'status' => array('default'=>null,
'flags'=>WS_PARAM_OPTIONAL,
'info'=>'public, private'),
'visible' => array('default'=>null,
'flags'=>WS_PARAM_OPTIONAL),
'commentable' => array('default'=>true,
'flags'=>WS_PARAM_OPTIONAL,
'info'=>'Boolean, effective if configuration variable activate_comments is set to true'),
Expand Down

0 comments on commit 4e899b5

Please sign in to comment.