Skip to content

Commit

Permalink
PaperList knows how to compute has(tags) and has(authors).
Browse files Browse the repository at this point in the history
And pre-computes it even without an explicit `tags` column.
As a result, we can remove "authors" and "tags" from the default
lists of folded columns.
  • Loading branch information
kohler committed Jul 25, 2020
1 parent 2e50b42 commit a6ecd87
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 40 deletions.
6 changes: 3 additions & 3 deletions manualassign.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,14 @@ function show_ass_elements($pl) {
if (!empty($hlsearch)) {
$search->set_field_highlighter_query(join(" OR ", $hlsearch));
}
$pl = new PaperList("reviewAssignment", $search, ["sort" => true, "display" => "show:topics show:reviewers"], $Qreq);
echo Ht::form($Conf->hoturl_post("manualassign", ["reviewer" => $reviewer->email, "sort" => $Qreq->sort]), ["class" => "has-fold " . ($pl->showing("au") || $pl->showing("anonau") ? "fold10o" : "fold10c") . " assignpc ignore-diff"]),
$pl = new PaperList("reviewAssignment", $search, ["sort" => true], $Qreq);
echo Ht::form($Conf->hoturl_post("manualassign", ["reviewer" => $reviewer->email, "sort" => $Qreq->sort]), ["class" => "assignpc ignore-diff"]),
Ht::hidden("t", $Qreq->t),
Ht::hidden("q", $Qreq->q);
$rev_rounds = $Conf->round_selector_options(false);
$expected_round = $Conf->assignment_round_option(false);

echo '<div id="searchform">';
echo '<div id="searchform" class="has-fold fold10', $pl->showing("authors") ? "o" : "c", '">';
if (count($rev_rounds) > 1) {
echo '<div class="entryi"><label for="assrevround">Review round</label><div class="entry">',
Ht::select("rev_round", $rev_rounds, $Qreq->rev_round ? : $expected_round, ["id" => "assrevround", "class" => "ignore-diff"]), ' <span class="barsep">·</span> ';
Expand Down
8 changes: 4 additions & 4 deletions src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -3202,16 +3202,16 @@ function submission_blindness() {
return $this->settings["sub_blind"];
}
function subBlindAlways() {
return $this->settings["sub_blind"] == self::BLIND_ALWAYS;
return $this->settings["sub_blind"] === self::BLIND_ALWAYS;
}
function subBlindNever() {
return $this->settings["sub_blind"] == self::BLIND_NEVER;
return $this->settings["sub_blind"] === self::BLIND_NEVER;
}
function subBlindOptional() {
return $this->settings["sub_blind"] == self::BLIND_OPTIONAL;
return $this->settings["sub_blind"] === self::BLIND_OPTIONAL;
}
function subBlindUntilReview() {
return $this->settings["sub_blind"] == self::BLIND_UNTILREVIEW;
return $this->settings["sub_blind"] === self::BLIND_UNTILREVIEW;
}

function is_review_blind($rrow) {
Expand Down
7 changes: 3 additions & 4 deletions src/papercolumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function content(PaperList $pl, PaperInfo $row) {
. $pl->_contentDownload($row);

if ($this->has_decoration && (string) $row->paperTags !== "") {
if ($pl->row_tags_overridable
if ($pl->row_tags_overridable !== ""
&& ($deco = $pl->tagger->unparse_decoration_html($pl->row_tags_overridable))) {
$decx = $pl->tagger->unparse_decoration_html($pl->row_tags);
if ($deco !== $decx) {
Expand All @@ -230,7 +230,7 @@ function content(PaperList $pl, PaperInfo $row) {
} else {
$t .= $deco;
}
} else if ($pl->row_tags) {
} else if ($pl->row_tags !== "") {
$t .= $pl->tagger->unparse_decoration_html($pl->row_tags);
}
}
Expand Down Expand Up @@ -739,7 +739,6 @@ function prepare(PaperList $pl, $visible) {
if ($visible && $this->editable) {
$pl->has_editable_tags = true;
}
$pl->need_tag_attr = true;
return true;
}
function field_json(PaperList $pl) {
Expand All @@ -757,7 +756,7 @@ function content(PaperList $pl, PaperInfo $row) {
if ($this->editable) {
$pl->row_attr["data-tags-editable"] = 1;
}
if ($this->editable || $pl->row_tags || $pl->row_tags_overridable) {
if ($this->editable || $pl->row_tags !== "" || $pl->row_tags_overridable !== "") {
$pl->need_render = true;
return '<span class="need-tags"></span>';
} else {
Expand Down
1 change: 0 additions & 1 deletion src/papercolumns/pc_tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function prepare(PaperList $pl, $visible) {
}
$this->className = ($this->editable ? "pl_edit" : "pl_")
. ($this->is_value ? "tagval" : "tag");
$pl->need_tag_attr = true;
return true;
}
function completion_name() {
Expand Down
68 changes: 40 additions & 28 deletions src/paperlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class PaperListTableRender {
public $table_start;
public $thead;
public $tbody_class;
/** @var list<string> */
public $rows;
public $tfoot;
public $table_end;
Expand Down Expand Up @@ -133,6 +134,7 @@ class PaperList {
public $user;
/** @var PaperSearch */
public $search;
/** @var Qrequest */
private $qreq;
/** @var Contact */
private $_reviewer_user;
Expand Down Expand Up @@ -164,6 +166,7 @@ class PaperList {
/** @var array<string,list<PaperColumn>> */
private $_columns_by_name;
private $_column_errors_by_name = [];
/** @var ?string */
private $_current_find_column;
/** @var list<ListSorter> */
private $_sorters = [];
Expand All @@ -177,13 +180,16 @@ class PaperList {
public $table_attr;
public $row_attr;
public $row_overridable;
/** @var string */
public $row_tags;
/** @var string */
public $row_tags_overridable;
public $need_render;
public $has_editable_tags = false;
public $check_format;

// collected during render and exported to caller
/** @var int */
public $count; // also exported to columns access: 1 more than row index
private $_has;
public $error_html = array();
Expand Down Expand Up @@ -606,19 +612,26 @@ private function _compute_has($key) {
&& $this->rowset()->any(function ($row) {
return $row->abstract_text() !== "";
});
} else if ($key === "openau") {
return $this->has("authors")
&& (!$this->user->is_manager()
|| $this->rowset()->any(function ($row) {
return $this->user->can_view_authors($row);
}));
} else if ($key === "authors") {
return $this->rowset()->any(function ($row) {
return $this->user->allow_view_authors($row);
});
} else if ($key === "anonau") {
return $this->has("authors")
&& $this->user->is_manager()
&& $this->rowset()->any(function ($row) {
return $this->user->allow_view_authors($row)
&& !$this->user->can_view_authors($row);
});
} else if ($key === "tags") {
$overrides = $this->user->add_overrides(Contact::OVERRIDE_CONFLICT);
$answer = $this->user->can_view_tags(null)
&& $this->rowset()->any(function ($row) {
return $this->user->can_view_tags($row)
&& $row->sorted_viewable_tags($this->user) !== "";
});
$this->user->set_overrides($overrides);
return $answer;
} else if ($key === "lead") {
return $this->conf->has_any_lead_or_shepherd()
&& $this->rowset()->any(function ($row) {
Expand Down Expand Up @@ -652,7 +665,7 @@ private function _compute_has($key) {
&& $row->timeFinalSubmitted <= 0;
});
} else {
if (!in_array($key, ["sel", "need_review", "authors", "tags"], true)) {
if (!in_array($key, ["sel", "need_review"], true)) {
error_log("unexpected PaperList::_compute_has({$key})");
}
return false;
Expand Down Expand Up @@ -894,18 +907,18 @@ private function _list_columns() {
$this->_default_linkto("finishreview");
return "id title revtype status";
case "pl":
return "sel id title revtype revstat status authors tags";
return "sel id title revtype revstat status";
case "reqrevs":
return "id title revdelegation revstat status authors tags";
return "id title revdelegation revstat status";
case "reviewAssignment":
$this->_default_linkto("assign");
return "id title mypref topicscore desirability assignment authors potentialconflict tags";
return "id title mypref topicscore desirability assignment potentialconflict topics reviewers";
case "conflictassign":
$this->_default_linkto("assign");
return "id title authors potentialconflict revtype editconf tags";
return "id title authors potentialconflict revtype editconf";
case "pf":
$this->_default_linkto("paper");
return "sel id title topicscore revtype editmypref authors tags";
return "sel id title topicscore revtype editmypref";
case "reviewers":
$this->_default_linkto("assign");
return "selon id title status";
Expand Down Expand Up @@ -1001,7 +1014,7 @@ private function _row_setup(PaperInfo $row) {
$this->row_attr = [];
$this->row_overridable = $this->user->has_overridable_conflict($row);

$this->row_tags = $this->row_tags_overridable = null;
$this->row_tags = $this->row_tags_overridable = "";
if (isset($row->paperTags) && $row->paperTags !== "") {
if ($this->row_overridable) {
$overrides = $this->user->add_overrides(Contact::OVERRIDE_CONFLICT);
Expand All @@ -1013,6 +1026,7 @@ private function _row_setup(PaperInfo $row) {
$this->row_tags = $row->sorted_viewable_tags($this->user);
}
}
$this->mark_has("tags", $this->row_tags !== "" || $this->row_tags_overridable !== "");
}

static private function _prepend_row_header($content, $ch) {
Expand Down Expand Up @@ -1090,21 +1104,19 @@ private function _row_content($rstate, PaperInfo $row, $fieldDef) {
}

// tags
if ($this->need_tag_attr) {
if ($this->row_tags_overridable
&& $this->row_tags_overridable !== $this->row_tags) {
$this->row_attr["data-tags"] = trim($this->row_tags_overridable);
$this->row_attr["data-tags-conflicted"] = trim($this->row_tags);
} else {
$this->row_attr["data-tags"] = trim($this->row_tags);
}
if ($this->row_tags_overridable !== ""
&& $this->row_tags_overridable !== $this->row_tags) {
$this->row_attr["data-tags"] = trim($this->row_tags_overridable);
$this->row_attr["data-tags-conflicted"] = trim($this->row_tags);
} else if ($this->row_tags !== "") {
$this->row_attr["data-tags"] = trim($this->row_tags);
}

// row classes
$trclass = [];
$cc = "";
if ($row->paperTags ?? null) {
if ($this->row_tags_overridable
if ($this->row_tags_overridable !== ""
&& ($cco = $row->conf->tags()->color_classes($this->row_tags_overridable))) {
$ccx = $row->conf->tags()->color_classes($this->row_tags);
if ($cco !== $ccx) {
Expand All @@ -1114,7 +1126,7 @@ private function _row_content($rstate, PaperInfo $row, $fieldDef) {
}
$cc = $this->_view_force ? $cco : $ccx;
$rstate->hascolors = $rstate->hascolors || str_ends_with($cco, " tagbg");
} else if ($this->row_tags) {
} else if ($this->row_tags !== "") {
$cc = $row->conf->tags()->color_classes($this->row_tags);
}
}
Expand Down Expand Up @@ -1254,9 +1266,8 @@ private function _analyze_folds($rstate, $fieldDef) {
}
}
// authorship requires special handling
if ($this->has("anonau")) {
$classes[] = "fold2" . ($this->showing("anonau") ? "o" : "c");
}
$classes[] = "fold2" . ($this->showing("anonau") ? "o" : "c");
$classes[] = "fold4" . ($this->showing("aufull") ? "o" : "c");
// row number folding
if ($has_sel) {
$classes[] = "fold6" . ($this->showing("rownum") ? "o" : "c");
Expand Down Expand Up @@ -1568,7 +1579,7 @@ private function _table_render($options) {
// get field array
$fieldDef = array();
$ncol = $titlecol = 0;
// folds: au:1, anonau:2, fullrow:3, aufull:4, force:5, rownum:6, statistics:7,
// folds: anonau:2, fullrow:3, aufull:4, force:5, rownum:6, statistics:7,
// statistics-exist:8, [fields]
$next_fold = 9;
foreach ($field_list as $fdef) {
Expand Down Expand Up @@ -1620,7 +1631,8 @@ private function _table_render($options) {
if ($options["fold_session_prefix"] ?? false) {
$this->table_attr["data-fold-session-prefix"] = $options["fold_session_prefix"];
$this->table_attr["data-fold-session"] = json_encode_browser([
"2" => "anonau", "5" => "force", "6" => "rownum", "7" => "statistics"
"2" => "anonau", "4" => "aufull", "5" => "force",
"6" => "rownum", "7" => "statistics"
]);
}
if ($this->search->is_order_anno) {
Expand Down

0 comments on commit a6ecd87

Please sign in to comment.