Skip to content

Commit

Permalink
Re-write project filters using classes (#109)
Browse files Browse the repository at this point in the history
For project filters, save serialized data and construct SQL from
the data instead of storing SQL. This enables better control
for translated genres and makes for more powerful language
selectors.

Update the project filters UI with some javascript to hide language
selection mode when 'any' is selected and automate the difficulty
checkboxes.
  • Loading branch information
70ray authored and cpeel committed Aug 1, 2019
1 parent 4131862 commit 4b43b0b
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 404 deletions.
1 change: 0 additions & 1 deletion activity_hub.php
Expand Up @@ -439,7 +439,6 @@ function summarize_stage($stage, $desired_states, $show_filtered_projects=FALSE,
if($load_filtered_projects)
{
$display_filter = get_project_filter_display($pguser, $filter_type);
$display_filter = preg_replace(array("/^<br>/","/<br>/"),array(""," | "),$display_filter);
$display_filter = sprintf(_('<a href="%1$s">Filter</a>: %2$s'), $filter_link, $display_filter);
}
else
Expand Down
732 changes: 335 additions & 397 deletions pinc/filter_project_list.inc

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions scripts/filter_project.js
@@ -0,0 +1,26 @@
/*global $*/
$(function () {
"use strict";
var langSelector = $("#language");
var langMatch = $("#lang-match");
var diffAll = $("#diff-all");
var diffOpt = $(".diff-opt");

function showMatcher() {
langMatch.css("visibility", (0 === langSelector.prop("selectedIndex") ? "hidden" : "visible"));
}

langSelector.change(function () {
showMatcher();
});

diffAll.change(function () {
diffOpt.prop("checked", false);
});

diffOpt.change(function () {
diffAll.prop("checked", false);
});

showMatcher();
});
1 change: 0 additions & 1 deletion styles/layout.css
Expand Up @@ -201,7 +201,6 @@ div.calloutheader {
/* ------------------------------------------------------------------------ */
/* Round and Pool filter table */
#filter_form {
border: 1px solid gray;
padding: 0 0.5em 0.5em 0.5em;
}
table.filter {
Expand Down
1 change: 0 additions & 1 deletion styles/layout.less
Expand Up @@ -210,7 +210,6 @@ div.calloutheader {
/* ------------------------------------------------------------------------ */
/* Round and Pool filter table */
#filter_form {
border: 1px solid gray;
padding: 0 0.5em 0.5em 0.5em;
}

Expand Down
3 changes: 2 additions & 1 deletion tools/pool.php
Expand Up @@ -14,8 +14,9 @@
$pool_id = get_enumerated_param($_GET, 'pool_id', null, array_keys($Pool_for_id_));

$pool = get_Pool_for_id($pool_id);
$header_args = ["js_files" => ["$code_url/scripts/filter_project.js"]];

output_header("$pool->id: $pool->name");
output_header("$pool->id: $pool->name", SHOW_STATSBAR, $header_args);

global $pguser;
$userSettings =& Settings::get_Settings($pguser);
Expand Down
5 changes: 3 additions & 2 deletions tools/post_proofers/smooth_reading.php
Expand Up @@ -24,9 +24,10 @@
// Tell RSS feed readers which RSS feed is connected to this page
$rss_title = _("Smooth Reading E-Texts");
$attr_safe_rss_title = attr_safe($rss_title);
$extra_args = array(
$extra_args = [
"js_files" => ["$code_url/scripts/filter_project.js"],
"head_data" => "<link rel='alternate' type='application/rss+xml' href='$code_url/feeds/backend.php?content=smoothreading&type=rss' title='$attr_safe_rss_title' />",
);
];

// we show more columns when user is logged in, so we don't have room for the stats bar
output_header($header_text, $logged_in ? NO_STATSBAR : SHOW_STATSBAR, $extra_args);
Expand Down
3 changes: 2 additions & 1 deletion tools/proofers/round.php
Expand Up @@ -19,8 +19,9 @@

$round_id = get_enumerated_param($_GET, 'round_id', null, array_keys($Round_for_round_id_));
$round = get_Round_for_round_id($round_id);
$header_args = ["js_files" => ["$code_url/scripts/filter_project.js"]];

output_header("$round->id: $round->name");
output_header("$round->id: $round->name", SHOW_STATSBAR, $header_args);

$uao = $round->user_access( $pguser );

Expand Down

0 comments on commit 4b43b0b

Please sign in to comment.