1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Show saved inline comments

Summary: Saved inline comments are now shown for images.

Test Plan: Verified that inline comments are loaded and shown.

Reviewers: epriestley

CC: aran, Korvin

Maniphest Tasks: T2446

Differential Revision: https://secure.phabricator.com/D4866
This commit is contained in:
Lauri-Henrik Jalonen 2013-02-08 07:24:17 -08:00 committed by epriestley
parent 7063ee638e
commit bed728f23e
5 changed files with 75 additions and 3 deletions

View file

@ -1410,6 +1410,7 @@ phutil_register_library_map(array(
'PholioController' => 'applications/pholio/controller/PholioController.php',
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
'PholioInlineController' => 'applications/pholio/controller/PholioInlineController.php',
'PholioInlineSaveController' => 'applications/pholio/controller/PholioInlineSaveController.php',
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
@ -2829,6 +2830,7 @@ phutil_register_library_map(array(
0 => 'PholioDAO',
1 => 'PhabricatorMarkupInterface',
),
'PholioInlineController' => 'PholioController',
'PholioInlineSaveController' => 'PholioController',
'PholioMock' =>
array(

View file

@ -43,7 +43,8 @@ final class PhabricatorApplicationPholio extends PhabricatorApplication {
'new/' => 'PholioMockEditController',
'edit/(?P<id>\d+)/' => 'PholioMockEditController',
'comment/(?P<id>\d+)/' => 'PholioMockCommentController',
'inline/(?P<id>\d+)/' => 'PholioInlineSaveController',
'inline/(?P<id>\d+)/' => 'PholioInlineController',
'inline/save/' => 'PholioInlineSaveController',
),
);
}

View file

@ -0,0 +1,38 @@
<?php
/**
* @group pholio
*/
final class PholioInlineController extends PholioController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$inline_comments = id(new PholioTransactionComment())->loadAllWhere(
'imageid = %d AND transactionphid IS NOT NULL',
$this->id
);
$inlines = array();
foreach ($inline_comments as $inline_comment) {
$inlines[] = array(
'phid' => $inline_comment->getPHID(),
'imageID' => $inline_comment->getImageID(),
'x' => $inline_comment->getX(),
'y' => $inline_comment->getY(),
'width' => $inline_comment->getWidth(),
'height' => $inline_comment->getHeight(),
'content' => $inline_comment->getContent());
}
return id(new AphrontAjaxResponse())->setContent($inlines);
}
}

View file

@ -24,7 +24,7 @@ final class PholioMockImagesView extends AphrontView {
$main_image = head($this->mock->getImages());
$main_image_tag = javelin_render_tag(
$main_image_tag = javelin_render_tag(
'img',
array(
'id' => $main_image_id,

View file

@ -35,6 +35,7 @@ JX.behavior('pholio-mock-view', function(config) {
main.src = data.fullSizeURI;
JX.DOM.setContent(wrapper,main);
load_inline_comments();
});
@ -123,7 +124,7 @@ JX.behavior('pholio-mock-view', function(config) {
selection_fill.title = comment;
var saveURL = "/pholio/inline/" + imageData['imageID'] + "/";
var saveURL = "/pholio/inline/save/";
var inlineComment = new JX.Request(saveURL, function(r) {
@ -144,6 +145,36 @@ JX.behavior('pholio-mock-view', function(config) {
});
function load_inline_comments() {
var data = JX.Stratcom.getData(JX.$(config.mainID));
var inline_comments_url = "/pholio/inline/" + data['imageID'] + "/";
var inline_comments = new JX.Request(inline_comments_url, function(r) {
if (r.length > 0) {
for(i=0; i < r.length; i++) {
var inlineSelection = JX.$N(
'div',
{
id: r[i].phid,
className: 'pholio-mock-select-border',
title: r[i].content
});
JX.DOM.appendContent(wrapper, inlineSelection);
JX.$V(r[i].x, r[i].y).setPos(inlineSelection);
JX.$V(r[i].width, r[i].height)
.setDim(inlineSelection);
}
}
});
inline_comments.send();
}
load_inline_comments();
});