Skip to content

Commit b4e038d

Browse files
committed
Add similiar questions sidebar to Ponder
Summary: Ref T9099. Testing out a two column layout in Ponder, with the main idea being creating a more browsable, discoverable product. I'd like the side column though to be a little smarter and provide project based searching. Ideally, if I'm reading Resolved Maniphest questions, other Resolved Maniphest questions are likely interesting. Another scenario is if I'm answering questions, in which case browsing more Open questions would also be interesting. Ponder "Main Column" still needs to be redesigned. Test Plan: Browse open questions, resolved questions. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Maniphest Tasks: T9099 Differential Revision: https://secure.phabricator.com/D13849
1 parent efa8855 commit b4e038d

File tree

6 files changed

+149
-12
lines changed

6 files changed

+149
-12
lines changed

resources/celerity/map.php

+2
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
'rsrc/css/phui/phui-tag-view.css' => '402691cc',
149149
'rsrc/css/phui/phui-text.css' => 'cf019f54',
150150
'rsrc/css/phui/phui-timeline-view.css' => 'f1bccf73',
151+
'rsrc/css/phui/phui-two-column-view.css' => 'add0a7d1',
151152
'rsrc/css/phui/phui-workboard-view.css' => '6704d68d',
152153
'rsrc/css/phui/phui-workpanel-view.css' => 'adec7699',
153154
'rsrc/css/sprite-login.css' => '1ebb9bf9',
@@ -801,6 +802,7 @@
801802
'phui-text-css' => 'cf019f54',
802803
'phui-theme-css' => '6b451f24',
803804
'phui-timeline-view-css' => 'f1bccf73',
805+
'phui-two-column-view-css' => 'add0a7d1',
804806
'phui-workboard-view-css' => '6704d68d',
805807
'phui-workpanel-view-css' => 'adec7699',
806808
'phuix-action-list-view' => 'b5c256b8',

src/__phutil_library_map__.php

+2
Original file line numberDiff line numberDiff line change
@@ -1406,6 +1406,7 @@
14061406
'PHUITimelineEventView' => 'view/phui/PHUITimelineEventView.php',
14071407
'PHUITimelineExample' => 'applications/uiexample/examples/PHUITimelineExample.php',
14081408
'PHUITimelineView' => 'view/phui/PHUITimelineView.php',
1409+
'PHUITwoColumnView' => 'view/phui/PHUITwoColumnView.php',
14091410
'PHUITypeaheadExample' => 'applications/uiexample/examples/PHUITypeaheadExample.php',
14101411
'PHUIWorkboardView' => 'view/phui/PHUIWorkboardView.php',
14111412
'PHUIWorkpanelView' => 'view/phui/PHUIWorkpanelView.php',
@@ -5183,6 +5184,7 @@
51835184
'PHUITimelineEventView' => 'AphrontView',
51845185
'PHUITimelineExample' => 'PhabricatorUIExample',
51855186
'PHUITimelineView' => 'AphrontView',
5187+
'PHUITwoColumnView' => 'AphrontTagView',
51865188
'PHUITypeaheadExample' => 'PhabricatorUIExample',
51875189
'PHUIWorkboardView' => 'AphrontTagView',
51885190
'PHUIWorkpanelView' => 'AphrontTagView',

src/applications/ponder/constants/PonderQuestionStatus.php

+10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ public static function getQuestionStatusFullName($status) {
2626
return idx($map, $status, pht('Unknown'));
2727
}
2828

29+
public static function getQuestionStatusName($status) {
30+
$map = array(
31+
self::STATUS_OPEN => pht('Open'),
32+
self::STATUS_CLOSED_RESOLVED => pht('Resolved'),
33+
self::STATUS_CLOSED_OBSOLETE => pht('Obsolete'),
34+
self::STATUS_CLOSED_DUPLICATE => pht('Duplicate'),
35+
);
36+
return idx($map, $status, pht('Unknown'));
37+
}
38+
2939
public static function getQuestionStatusDescription($status) {
3040
$map = array(
3141
self::STATUS_OPEN =>

src/applications/ponder/controller/PonderQuestionViewController.php

+54-12
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public function handleRequest(AphrontRequest $request) {
1010
->setViewer($viewer)
1111
->withIDs(array($id))
1212
->needAnswers(true)
13+
->needProjectPHIDs(true)
1314
->executeOne();
1415
if (!$question) {
1516
return new Aphront404Response();
@@ -51,6 +52,7 @@ public function handleRequest(AphrontRequest $request) {
5152

5253
$actions = $this->buildActionListView($question);
5354
$properties = $this->buildPropertyListView($question, $actions);
55+
$sidebar = $this->buildSidebar($question);
5456

5557
$object_box = id(new PHUIObjectBoxView())
5658
->setHeader($header)
@@ -59,21 +61,19 @@ public function handleRequest(AphrontRequest $request) {
5961
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
6062
$crumbs->addTextCrumb('Q'.$id, '/Q'.$id);
6163

62-
$ponder_view = phutil_tag(
63-
'div',
64-
array(
65-
'class' => 'ponder-question-view',
66-
),
67-
array(
68-
$crumbs,
69-
$object_box,
70-
$question_xactions,
71-
$answers,
72-
$answer_add_panel,
73-
));
64+
$ponder_view = id(new PHUITwoColumnView())
65+
->setMainColumn(array(
66+
$object_box,
67+
$question_xactions,
68+
$answers,
69+
$answer_add_panel,
70+
))
71+
->setSideColumn($sidebar)
72+
->addClass('ponder-question-view');
7473

7574
return $this->buildApplicationPage(
7675
array(
76+
$crumbs,
7777
$ponder_view,
7878
),
7979
array(
@@ -410,4 +410,46 @@ private function wrapComments($n, $stuff) {
410410
return array($show, $hide);
411411
}
412412

413+
private function buildSidebar(PonderQuestion $question) {
414+
$viewer = $this->getViewer();
415+
$status = $question->getStatus();
416+
$id = $question->getID();
417+
418+
$questions = id(new PonderQuestionQuery())
419+
->setViewer($viewer)
420+
->withStatuses(array($status))
421+
->withEdgeLogicPHIDs(
422+
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
423+
PhabricatorQueryConstraint::OPERATOR_OR,
424+
$question->getProjectPHIDs())
425+
->setLimit(10)
426+
->execute();
427+
428+
$list = id(new PHUIObjectItemListView())
429+
->setUser($viewer)
430+
->setNoDataString(pht('No similar questions found.'));
431+
432+
foreach ($questions as $question) {
433+
if ($id == $question->getID()) {
434+
continue;
435+
}
436+
$item = new PHUIObjectItemView();
437+
$item->setObjectName('Q'.$question->getID());
438+
$item->setHeader($question->getTitle());
439+
$item->setHref('/Q'.$question->getID());
440+
$item->setObject($question);
441+
442+
$item->addAttribute(
443+
pht('%d Answer(s)', $question->getAnswerCount()));
444+
445+
$list->addItem($item);
446+
}
447+
448+
$box = id(new PHUIObjectBoxView())
449+
->setHeaderText(pht('Similar Questions'))
450+
->setObjectList($list);
451+
452+
return $box;
453+
}
454+
413455
}

src/view/phui/PHUITwoColumnView.php

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
final class PHUITwoColumnView extends AphrontTagView {
4+
5+
private $mainColumn;
6+
private $sideColumn;
7+
8+
public function setMainColumn($main) {
9+
$this->mainColumn = $main;
10+
return $this;
11+
}
12+
13+
public function setSideColumn($side) {
14+
$this->sideColumn = $side;
15+
return $this;
16+
}
17+
18+
protected function getTagAttributes() {
19+
return array(
20+
'class' => 'phui-two-column-view grouped',
21+
);
22+
}
23+
24+
protected function getTagContent() {
25+
require_celerity_resource('phui-two-column-view-css');
26+
27+
$main = phutil_tag(
28+
'div',
29+
array(
30+
'class' => 'phui-main-column',
31+
),
32+
$this->mainColumn);
33+
34+
$side = phutil_tag(
35+
'div',
36+
array(
37+
'class' => 'phui-side-column',
38+
),
39+
$this->sideColumn);
40+
41+
return phutil_tag_div(
42+
'phui-two-column-row',
43+
array(
44+
$main,
45+
$side,
46+
));
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* @provides phui-two-column-view-css
3+
*/
4+
5+
.phui-two-column-view {
6+
display: table;
7+
width: 100%;
8+
}
9+
10+
.phui-two-column-row {
11+
display: table-row;
12+
}
13+
14+
.device-desktop .phui-two-column-view .phui-main-column {
15+
display: table-cell;
16+
vertical-align: top;
17+
}
18+
19+
.device-desktop .phui-two-column-view .phui-side-column {
20+
width: 320px;
21+
display: table-cell;
22+
vertical-align: top;
23+
}
24+
25+
.device-desktop .phui-two-column-view
26+
.phui-main-column .phui-object-box:first-child {
27+
margin: 0 16px 0 16px;
28+
}
29+
30+
.device-desktop .phui-two-column-view
31+
.phui-side-column .phui-object-box:first-child {
32+
margin: 0 16px 16px 0;
33+
}

0 commit comments

Comments
 (0)