From 5ba5cb567565ebb522728c5f1dd6105e674d5846 Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 1 Apr 2013 12:52:30 -0700 Subject: [PATCH] Add "thread" role and allow threads to render without thread lists Summary: The actual layout on mobile is a bit silly since the thread ends up being like 5px tall for now, but it technically works. Ref T2644. Test Plan: {F38106} Reviewers: btrahan Reviewed By: btrahan CC: aran, chad Maniphest Tasks: T2421 Differential Revision: https://secure.phabricator.com/D5506 --- .../controller/ConpherenceController.php | 77 +++++++++---------- .../ConpherenceUpdateController.php | 16 ++-- .../controller/ConpherenceViewController.php | 24 +++++- .../view/ConpherenceLayoutView.php | 25 +++++- .../view/ConpherenceThreadListView.php | 18 +++-- .../application/conpherence/header-pane.css | 9 --- .../rsrc/css/application/conpherence/menu.css | 18 +++++ 7 files changed, 119 insertions(+), 68 deletions(-) diff --git a/src/applications/conpherence/controller/ConpherenceController.php b/src/applications/conpherence/controller/ConpherenceController.php index 34c2f11694..b4dc1f267b 100644 --- a/src/applications/conpherence/controller/ConpherenceController.php +++ b/src/applications/conpherence/controller/ConpherenceController.php @@ -92,45 +92,44 @@ abstract class ConpherenceController extends PhabricatorController { $edit_href = $this->getApplicationURI('update/'.$conpherence->getID().'/'); $class_mod = $display_data['image_class']; - $header = - phutil_tag( - 'div', - array( - 'class' => 'upload-photo' - ), - pht('Drop photo here to change this Conpherence photo.')). - javelin_tag( - 'a', - array( - 'class' => 'edit', - 'href' => $edit_href, - 'sigil' => 'conpherence-edit-metadata', - 'meta' => array( - 'action' => 'metadata' - ) - ), - ''). - phutil_tag( - 'div', - array( - 'class' => $class_mod.'header-image', - 'style' => 'background-image: url('.$display_data['image'].');' - ), - ''). - phutil_tag( - 'div', - array( - 'class' => $class_mod.'title', - ), - $display_data['title']). - phutil_tag( - 'div', - array( - 'class' => $class_mod.'subtitle', - ), - $display_data['subtitle']); - - return $header; + return array( + phutil_tag( + 'div', + array( + 'class' => 'upload-photo' + ), + pht('Drop photo here to change this Conpherence photo.')), + javelin_tag( + 'a', + array( + 'class' => 'edit', + 'href' => $edit_href, + 'sigil' => 'conpherence-edit-metadata', + 'meta' => array( + 'action' => 'metadata' + ) + ), + ''), + phutil_tag( + 'div', + array( + 'class' => $class_mod.'header-image', + 'style' => 'background-image: url('.$display_data['image'].');' + ), + ''), + phutil_tag( + 'div', + array( + 'class' => $class_mod.'title', + ), + $display_data['title']), + phutil_tag( + 'div', + array( + 'class' => $class_mod.'subtitle', + ), + $display_data['subtitle']), + ); } protected function renderConpherenceTransactions( diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 60a995551a..1e464353c6 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -3,8 +3,8 @@ /** * @group conpherence */ -final class ConpherenceUpdateController extends - ConpherenceController { +final class ConpherenceUpdateController + extends ConpherenceController { private $conpherenceID; @@ -265,10 +265,10 @@ final class ConpherenceUpdateController extends $rendered_transactions = $data['transactions']; $new_latest_transaction_id = $data['latest_transaction_id']; - $selected = true; - $nav_item = $this->buildConpherenceMenuItem( - $conpherence, - $selected); + $nav_item = id(new ConpherenceThreadListView()) + ->setUser($user) + ->setBaseURI($this->getApplicationURI()) + ->renderSingleThread($conpherence); $header = $this->buildHeaderPaneContent($conpherence); @@ -281,9 +281,9 @@ final class ConpherenceUpdateController extends $content = array( 'transactions' => $rendered_transactions, 'latest_transaction_id' => $new_latest_transaction_id, - 'nav_item' => $nav_item->render(), + 'nav_item' => hsprintf('%s', $nav_item), 'conpherence_phid' => $conpherence->getPHID(), - 'header' => $header, + 'header' => hsprintf('%s', $header), 'file_widget' => $file_widget->render() ); return $content; diff --git a/src/applications/conpherence/controller/ConpherenceViewController.php b/src/applications/conpherence/controller/ConpherenceViewController.php index 0219d5f330..2b7a8c0e24 100644 --- a/src/applications/conpherence/controller/ConpherenceViewController.php +++ b/src/applications/conpherence/controller/ConpherenceViewController.php @@ -54,14 +54,32 @@ final class ConpherenceViewController extends $header = $this->renderHeaderPaneContent(); $messages = $this->renderMessagePaneContent(); $content = $header + $messages; - return id(new AphrontAjaxResponse())->setContent($content); + + if ($request->isAjax()) { + return id(new AphrontAjaxResponse())->setContent($content); + } + + $layout = id(new ConpherenceLayoutView()) + ->setBaseURI($this->getApplicationURI()) + ->setThread($conpherence) + ->setHeader($header) + ->setMessages($messages['messages']) + ->setReplyForm($messages['form']) + ->setRole('thread'); + + return $this->buildApplicationPage( + $layout, + array( + 'title' => $conpherence->getTitle(), + 'device' => true, + )); } private function renderHeaderPaneContent() { require_celerity_resource('conpherence-header-pane-css'); $conpherence = $this->getConpherence(); $header = $this->buildHeaderPaneContent($conpherence); - return array('header' => $header); + return array('header' => hsprintf('%s', $header)); } @@ -107,7 +125,7 @@ final class ConpherenceViewController extends pht('Show Older Messages')); return array( - 'messages' => $scrollbutton.$transactions, + 'messages' => hsprintf('%s%s', $scrollbutton, $transactions), 'form' => $form ); diff --git a/src/applications/conpherence/view/ConpherenceLayoutView.php b/src/applications/conpherence/view/ConpherenceLayoutView.php index 56aa32100c..94d4a9b087 100644 --- a/src/applications/conpherence/view/ConpherenceLayoutView.php +++ b/src/applications/conpherence/view/ConpherenceLayoutView.php @@ -6,6 +6,24 @@ final class ConpherenceLayoutView extends AphrontView { private $baseURI; private $threadView; private $role; + private $header; + private $messages; + private $replyForm; + + public function setMessages($messages) { + $this->messages = $messages; + return $this; + } + + public function setReplyForm($reply_form) { + $this->replyForm = $reply_form; + return $this; + } + + public function setHeader($header) { + $this->header = $header; + return $this; + } public function setRole($role) { $this->role = $role; @@ -32,6 +50,7 @@ final class ConpherenceLayoutView extends AphrontView { } public function render() { + require_celerity_resource('conpherence-menu-css'); Javelin::initBehavior('conpherence-menu', array( @@ -87,7 +106,7 @@ final class ConpherenceLayoutView extends AphrontView { 'id' => 'conpherence-header-pane', 'sigil' => 'conpherence-header', ), - ''), + nonempty($this->header, '')), phutil_tag( 'div', array( @@ -109,13 +128,13 @@ final class ConpherenceLayoutView extends AphrontView { 'id' => 'conpherence-messages', 'sigil' => 'conpherence-messages', ), - ''), + nonempty($this->messages, '')), phutil_tag( 'div', array( 'id' => 'conpherence-form' ), - '') + nonempty($this->replyForm, '')) )), )), )); diff --git a/src/applications/conpherence/view/ConpherenceThreadListView.php b/src/applications/conpherence/view/ConpherenceThreadListView.php index cf204c9d20..1fe47f4336 100644 --- a/src/applications/conpherence/view/ConpherenceThreadListView.php +++ b/src/applications/conpherence/view/ConpherenceThreadListView.php @@ -46,6 +46,16 @@ final class ConpherenceThreadListView extends AphrontView { return $menu; } + public function renderSingleThread(ConpherenceThread $thread) { + return $this->renderThread($thread); + } + + private function renderThreadItem(ConpherenceThread $thread) { + return id(new PhabricatorMenuItemView()) + ->setType(PhabricatorMenuItemView::TYPE_CUSTOM) + ->setName($this->renderThread($thread)); + } + private function renderThread(ConpherenceThread $thread) { $user = $this->getUser(); @@ -58,7 +68,7 @@ final class ConpherenceThreadListView extends AphrontView { $image = $data['image']; $snippet = $data['snippet']; - $item = id(new ConpherenceMenuItemView()) + return id(new ConpherenceMenuItemView()) ->setUser($user) ->setTitle($title) ->setSubtitle($subtitle) @@ -73,10 +83,6 @@ final class ConpherenceThreadListView extends AphrontView { array( 'id' => $thread->getID(), )); - - return id(new PhabricatorMenuItemView()) - ->setType(PhabricatorMenuItemView::TYPE_CUSTOM) - ->setName($item); } private function addThreadsToMenu( @@ -85,7 +91,7 @@ final class ConpherenceThreadListView extends AphrontView { $read = false) { foreach ($conpherences as $conpherence) { - $item = $this->renderThread($conpherence); + $item = $this->renderThreadItem($conpherence); $menu->addMenuItem($item); } diff --git a/webroot/rsrc/css/application/conpherence/header-pane.css b/webroot/rsrc/css/application/conpherence/header-pane.css index 611bf0b307..80e4c6cfcb 100644 --- a/webroot/rsrc/css/application/conpherence/header-pane.css +++ b/webroot/rsrc/css/application/conpherence/header-pane.css @@ -8,15 +8,6 @@ width: 100%; } -.device .conpherence-header-pane { - position: fixed; - top: 44px; -} - -.device-phone .conpherence-header-pane { - display: none; -} - .conpherence-header-pane .edit { float: right; margin: 16px 16px 0px 0px; diff --git a/webroot/rsrc/css/application/conpherence/menu.css b/webroot/rsrc/css/application/conpherence/menu.css index 9b87c65a5d..0da340fe41 100644 --- a/webroot/rsrc/css/application/conpherence/menu.css +++ b/webroot/rsrc/css/application/conpherence/menu.css @@ -38,6 +38,24 @@ div.conpherence-layout .phabricator-nav-column-background { display: none; } +.device .conpherence-role-thread .conpherence-menu-pane, +.device .conpherence-role-thread .phabricator-nav-column-background, +.device .conpherence-role-thread .conpherence-widget-pane { + display: none; +} + +.device .conpherence-role-thread .conpherence-content-pane { + margin-left: 0; +} + +.device .conpherence-role-thread .conpherence-message-pane, +.device .conpherence-role-thread .conpherence-messages, +.device .conpherence-role-thread .phabricator-form-view { + left: 0; + right: 0; + width: 100%; +} + .conpherence-menu .conpherence-menu-item-view { display: block;