1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 15:22:41 +01:00

Pholio - finish off history view

Summary:
...bsasically add a "view mode" and play with that throughout the stack. Differences are...

 - normal mode has comments; history mode does not
 - normal mode has inline comments; history mode does not
 - page uris are correct with respect to either mode

 ...and that's about it. I played around (wasted too much time) trying to make this cuter. I think just jamming this mode in here is the easiest / cleanest thing at the end. Feel free to tell me otherwise!

This largely gets even better via T3612. However, this fixes T3572.

Test Plan: played around with a mock with some history. noted correct uris on images. noted no errors in js console.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T3572

Differential Revision: https://secure.phabricator.com/D6638
This commit is contained in:
Bob Trahan 2013-08-01 13:59:37 -07:00
parent 75e56cb25d
commit 1663dc32c9
3 changed files with 54 additions and 20 deletions

View file

@ -27,7 +27,7 @@ final class PholioImageHistoryController extends PholioController {
// note while we have a mock object, its missing images we need to show // note while we have a mock object, its missing images we need to show
// the history of what's happened here. // the history of what's happened here.
// fetch the real deal // fetch the real deal
//
$mock = id(new PholioMockQuery()) $mock = id(new PholioMockQuery())
->setViewer($user) ->setViewer($user)
->needImages(true) ->needImages(true)
@ -44,7 +44,6 @@ final class PholioImageHistoryController extends PholioController {
$images = $mock->getImageHistorySet($this->imageID); $images = $mock->getImageHistorySet($this->imageID);
// TODO - this is a hack until we specialize the view object
$mock->attachImages($images); $mock->attachImages($images);
$latest_image = last($images); $latest_image = last($images);
@ -59,13 +58,14 @@ final class PholioImageHistoryController extends PholioController {
require_celerity_resource('pholio-css'); require_celerity_resource('pholio-css');
require_celerity_resource('pholio-inline-comments-css'); require_celerity_resource('pholio-inline-comments-css');
$comment_form_id = celerity_generate_unique_node_id(); $comment_form_id = null;
$output = id(new PholioMockImagesView()) $output = id(new PholioMockImagesView())
->setRequestURI($request->getRequestURI()) ->setRequestURI($request->getRequestURI())
->setCommentFormID($comment_form_id) ->setCommentFormID($comment_form_id)
->setUser($user) ->setUser($user)
->setMock($mock) ->setMock($mock)
->setImageID($this->imageID); ->setImageID($this->imageID)
->setViewMode('history');
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs $crumbs

View file

@ -9,6 +9,20 @@ final class PholioMockImagesView extends AphrontView {
private $imageID; private $imageID;
private $requestURI; private $requestURI;
private $commentFormID; private $commentFormID;
private $viewMode = 'normal';
/**
* Supports normal (/MX, /MX/Y/) and history (/pholio/image/history/Y/)
* modes. The former has handy dandy commenting functionality and the
* latter does not.
*/
public function setViewMode($view_mode) {
$this->viewMode = $view_mode;
return $this;
}
public function getViewMode() {
return $this->viewMode;
}
public function setCommentFormID($comment_form_id) { public function setCommentFormID($comment_form_id) {
$this->commentFormID = $comment_form_id; $this->commentFormID = $comment_form_id;
@ -66,15 +80,17 @@ final class PholioMockImagesView extends AphrontView {
$x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH); $x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH);
$y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT); $y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT);
$history_uri = '/pholio/image/history/'.$image->getID().'/';
$images[] = array( $images[] = array(
'id' => $image->getID(), 'id' => $image->getID(),
'fullURI' => $image->getFile()->getBestURI(), 'fullURI' => $file->getBestURI(),
'pageURI' => '/M'.$mock->getID().'/'.$image->getID().'/', 'pageURI' => $this->getImagePageURI($image, $mock),
'historyURI' => '/pholio/image/history/'.$image->getID().'/', 'historyURI' => $history_uri,
'width' => $x, 'width' => $x,
'height' => $y, 'height' => $y,
'title' => $image->getName(), 'title' => $image->getName(),
'desc' => $image->getDescription(), 'desc' => $image->getDescription(),
'isObsolete' => (bool) $image->getIsObsolete(),
); );
} }
@ -88,7 +104,8 @@ final class PholioMockImagesView extends AphrontView {
'images' => $images, 'images' => $images,
'selectedID' => $selected_id, 'selectedID' => $selected_id,
'loggedIn' => $this->getUser()->isLoggedIn(), 'loggedIn' => $this->getUser()->isLoggedIn(),
'logInLink' => (string) $login_uri 'logInLink' => (string) $login_uri,
'viewMode' => $this->getViewMode()
); );
Javelin::initBehavior('pholio-mock-view', $config); Javelin::initBehavior('pholio-mock-view', $config);
@ -146,7 +163,7 @@ final class PholioMockImagesView extends AphrontView {
array( array(
'sigil' => 'mock-thumbnail', 'sigil' => 'mock-thumbnail',
'class' => 'pholio-mock-carousel-thumb-item', 'class' => 'pholio-mock-carousel-thumb-item',
'href' => '/M'.$mock->getID().'/'.$image->getID().'/', 'href' => $this->getImagePageURI($image, $mock),
'meta' => array( 'meta' => array(
'imageID' => $image->getID(), 'imageID' => $image->getID(),
), ),
@ -173,4 +190,13 @@ final class PholioMockImagesView extends AphrontView {
return $mockview; return $mockview;
} }
private function getImagePageURI(PholioImage $image, PholioMock $mock) {
if ($this->getViewMode() == 'normal') {
$uri = '/M'.$mock->getID().'/'.$image->getID().'/';
} else {
$uri = '/pholio/image/history/'.$image->getID().'/';
}
return $uri;
}
} }

View file

@ -264,6 +264,10 @@ JX.behavior('pholio-mock-view', function(config) {
return; return;
} }
if (config.viewMode == 'history') {
return;
}
if (drag_begin) { if (drag_begin) {
return; return;
} }
@ -631,7 +635,7 @@ JX.behavior('pholio-mock-view', function(config) {
} }
load_inline_comments(); load_inline_comments();
if (config.loggedIn) { if (config.loggedIn && config.commentFormID) {
JX.DOM.invoke(JX.$(config.commentFormID), 'shouldRefresh'); JX.DOM.invoke(JX.$(config.commentFormID), 'shouldRefresh');
} }
@ -683,12 +687,14 @@ JX.behavior('pholio-mock-view', function(config) {
image.desc); image.desc);
info.push(desc); info.push(desc);
if (!image.isObsolete) {
var embed = JX.$N( var embed = JX.$N(
'div', 'div',
{className: 'pholio-image-embedding'}, {className: 'pholio-image-embedding'},
JX.$H('Embed this image:<br />{M' + config.mockID + JX.$H('Embed this image:<br />{M' + config.mockID +
', image=' + image.id + '}')); ', image=' + image.id + '}'));
info.push(embed); info.push(embed);
}
// Render image dimensions and visible size. If we have this infomation // Render image dimensions and visible size. If we have this infomation
// from the server we can display some of it immediately; otherwise, we need // from the server we can display some of it immediately; otherwise, we need
@ -728,11 +734,13 @@ JX.behavior('pholio-mock-view', function(config) {
'View Full Image'); 'View Full Image');
info.push(full_link); info.push(full_link);
if (config.viewMode != 'history') {
var history_link = JX.$N( var history_link = JX.$N(
'a', 'a',
{ href: image.historyURI }, { href: image.historyURI },
'View Image History'); 'View Image History');
info.push(history_link); info.push(history_link);
}
for (var ii = 0; ii < info.length; ii++) { for (var ii = 0; ii < info.length; ii++) {