related to #1931 & #1946 Added Posted date filter

This commit is contained in:
MatthieuLP
2023-07-25 16:47:25 +02:00
parent 87c4fad23e
commit b5dc413b40
5 changed files with 121 additions and 27 deletions
+1 -1
View File
@@ -834,7 +834,7 @@ SELECT id
if (isset($params['date_posted']))
{
if (!preg_match('/^(7d|30d|6m|1y)$/', $params['date_posted']))
if (!preg_match('/^(7d|30d|6m|1y|)$/', $params['date_posted']))
{
return new PwgError(WS_ERR_INVALID_PARAM, 'Invalid parameter date_posted');
}
+5
View File
@@ -429,4 +429,9 @@ $lang['Clear'] = 'Clear';
$lang['Fill in the filters to start a search'] = 'Fill in the filters to start a search';
$lang['Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.'] = 'Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.';
$lang['Empty filters'] = 'Empty filters';
$lang['last 7 days'] = 'Last 7 days';
$lang['last 30 days'] = 'Last 30 days';
$lang['last 6 months'] = 'Last 6 months';
$lang['last year'] = 'Last year';
$lang['Unknown time period'] = 'Unknown time period';
?>
+5
View File
@@ -434,3 +434,8 @@ $lang['Clear'] = 'Vider';
$lang['Fill in the filters to start a search'] = 'Complétez les filtres pour lancer une recherche';
$lang['Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.'] = 'Des filtres préétablis vous sont proposés, mais vous pouvez aussi en ajouter ou en retirer grâce au bouton "Choisir les filtres".';
$lang['Empty filters'] = 'Vider les filtres';
$lang['last 7 days'] = '7 derniers jours';
$lang['last 30 days'] = '30 derniers jours';
$lang['last 6 months'] = '6 derniers mois';
$lang['last year'] = 'Dernière année';
$lang['Unknown time period'] = 'Période inconnue';
+56 -12
View File
@@ -122,6 +122,43 @@ $(document).ready(function () {
empty_filters_list.push(PS_params.tags);
}
// Setup Date post filter
if (global_params.fields.hasOwnProperty('date_posted')) {
$(".filter-date_post").css("display", "flex");
$(".filter-manager-controller.date_post").prop("checked", true);
if (global_params.fields.date_posted != null && global_params.fields.date_posted != "") {
$("#date_post-" + global_params.fields.date_posted).prop("checked", true);
switch (global_params.fields.date_posted) {
case "7d":
date_posted_str = str_date_post_7d;
break;
case "30d":
date_posted_str = str_date_post_30d;
break;
case "6m":
date_posted_str = str_date_post_6m;
break;
case "1y":
date_posted_str = str_date_post_1y;
break;
default:
date_posted_str = str_date_post_u;
break;
}
$(".filter-date_post").addClass("filter-filled");
$(".filter.filter-date_post .search-words").text(date_posted_str);
}
$(".filter-date_post .filter-actions .clear").on('click', function () {
$(".date_post-option input").prop('checked', false);
});
PS_params.date_posted = global_params.fields.date_posted.length > 0 ? global_params.fields.date_posted : '';
empty_filters_list.push(PS_params.date_posted);
}
// Setup album filter
if (global_params.fields.cat) {
$(".filter-album").css("display", "flex");
@@ -421,28 +458,35 @@ $(document).ready(function () {
});
/**
* Filter Date
* Filter Date posted
*/
$(".filter-date").on("click", function (e) {
$(".filter-date_post").on("click", function (e) {
if ($(".filter-form").has(e.target).length != 0 ||
$(e.target).hasClass("filter-form")) {
return;
}
$(".filter-date-form").toggle(0, function () {
$(".filter-date_post-form").toggle(0, function () {
if ($(this).is(':visible')) {
$(".filter-date").addClass("show-filter-dropdown");
$(".filter-date_post").addClass("show-filter-dropdown");
} else {
$(".filter-date").removeClass("show-filter-dropdown");
performSearch(PS_params, true);
$(".filter-date_post").removeClass("show-filter-dropdown");
global_params.fields.date_posted = $(".date_post-option input:checked").val();
PS_params.date_posted = $(".date_post-option input:checked").length > 0 ? $(".date_post-option input:checked").val() : "";
}
});
});
$(".filter-date .filter-actions .delete").on("click", function () {
updateFilters('date', 'del');
performSearch(PS_params, $(".filter-date").hasClass("filter-filled"));
if (!$(".filter-date").hasClass("filter-filled")) {
$(".filter-date").hide();
$(".filter-date_post .filter-validate").on("click", function () {
$(".filter-date_post").trigger("click");
performSearch(PS_params, true);
});
$(".filter-date_post .filter-actions .delete").on("click", function () {
updateFilters('date_posted', 'del');
performSearch(PS_params, $(".filter-date_post").hasClass("filter-filled"));
if (!$(".filter-date_post").hasClass("filter-filled")) {
$(".filter-date_post").hide();
$(".filter-manager-controller.date").prop("checked", false);
}
});
+54 -14
View File
@@ -25,6 +25,12 @@ str_author_widget_label = "{'Author'|@translate|escape:javascript}";
str_added_by_widget_label = "{'Added by'|@translate|escape:javascript}";
str_filetypes_widget_label = "{'File type'|@translate|escape:javascript}";
str_date_post_7d = "{'last 7 days'|@translate|escape:javascript}";
str_date_post_30d = "{'last 30 days'|@translate|escape:javascript}";
str_date_post_6m = "{'last 6 months'|@translate|escape:javascript}";
str_date_post_1y = "{'last year'|@translate|escape:javascript}";
str_date_post_u = "{'Unknown time period'|@translate|escape:javascript}";
str_empty_search_top_alt = "{'Fill in the filters to start a search'|@translate|escape:javascript}";
str_empty_search_bot_alt = "{'Pre-established filters are proposed, but you can add or remove them using the "Choose filters" button.'|@translate|escape:javascript}";
@@ -212,6 +218,10 @@ str_empty_search_bot_alt = "{'Pre-established filters are proposed, but you can
<input data-wid='tag' class="filter-manager-controller tags" type="checkbox"/>
<span class="mcs-icon pwg-icon-tag">{'Tag'|@translate}</span>
</label>
<label>
<input data-wid='date_posted' class="filter-manager-controller date_post" type="checkbox"/>
<span class="mcs-icon pwg-icon-calendar-plus">{'Post date'|@translate}</span>
</label>
<label>
<input data-wid='album' class="filter-manager-controller album" type="checkbox"/>
<span class="mcs-icon pwg-icon-album">{'Album'|@translate}</span>
@@ -331,24 +341,54 @@ str_empty_search_bot_alt = "{'Pre-established filters are proposed, but you can
</div>
</div>
</div>
{* <div class="filter filter-date">
<span class="mcs-icon pwg-icon-calendar"></span>Date: <span class="search-words">Balloon</span><span class="filter-arrow pwg-icon-up-open"></span>
<div class="filter filter-date_post">
<span class="mcs-icon pwg-icon-calendar-plus filter-icon"></span>
<span class="search-words">{'Post date'|@translate}</span>
<span class="filter-arrow pwg-icon-up-open"></span>
<div class="filter-form filter-date-form">
// Still in porgress
<div class="row">
<div class="col-sm-12" id="htmlTarget">
<label for="datetimepicker1Input" class="form-label">Picker</label>
<div class="input-group log-event" id="datetimepicker1" data-td-target-input="nearest" data-td-target-toggle="nearest">
<input id="datetimepicker1Input" type="text" class="form-control" data-td-target="#datetimepicker1">
<span class="input-group-text" data-td-target="#datetimepicker1" data-td-toggle="datetimepicker">
<i class="fas fa-calendar">blavvla</i>
</span>
</div>
<div class="filter-form filter-date_post-form">
<div class="filter-form-title">{'Post date'|@translate}</div>
<div class="filter-actions">
<span class="delete mcs-icon pwg-icon-trash" title="{'Delete'|@translate}"></span>
<span class="clear mcs-icon pwg-icon-broom" title="{'Clear'|@translate}"></span>
</div>
<div class="date_post-option-container">
<div class="date_post-option">
<input type="radio" id="date_post-7d" value="7d" name="date_post-period">
<label for="date_post-7d">
<span class="mcs-icon pwg-icon-checkmark checked-icon"></span>
<span class="date-period">{'last 7 days'|@translate}</span>
</label>
</div>
<div class="date_post-option">
<input type="radio" id="date_post-30d" value="30d" name="date_post-period">
<label for="date_post-30d">
<span class="mcs-icon pwg-icon-checkmark checked-icon"></span>
<span class="date-period">{'last 30 days'|@translate}</span>
</label>
</div>
<div class="date_post-option">
<input type="radio" id="date_post-6m" value="6m" name="date_post-period">
<label for="date_post-6m">
<span class="mcs-icon pwg-icon-checkmark checked-icon"></span>
<span class="date-period">{'last 6 months'|@translate}</span>
</label>
</div>
<div class="date_post-option">
<input type="radio" id="date_post-1y" value="1y" name="date_post-period">
<label for="date_post-1y">
<span class="mcs-icon pwg-icon-checkmark checked-icon"></span>
<span class="date-period">{'last year'|@translate}</span>
</label>
</div>
</div>
<div class="filter-validate">
<i class="loading pwg-icon-spin6 animate-spin"></i>
<span class="validate-text">{'Validate'|@translate}</span>
</div>
</div>
</div> *}
</div>
<div class="filter filter-album">
<span class="mcs-icon pwg-icon-album filter-icon"></span>
<span class="search-words"></span>