mirror of
https://we.phorge.it/source/phorge.git
synced 2025-03-28 20:18:13 +01:00
Select portions from mock
Summary: Comment draft is now saved Test Plan: Verified that draft is saved Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, chad Maniphest Tasks: T2446 Differential Revision: https://secure.phabricator.com/D4831
This commit is contained in:
parent
1188876ea9
commit
57c001f522
5 changed files with 78 additions and 6 deletions
|
@ -1404,6 +1404,7 @@ phutil_register_library_map(array(
|
||||||
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
'PholioController' => 'applications/pholio/controller/PholioController.php',
|
||||||
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
|
||||||
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
|
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
|
||||||
|
'PholioInlineSaveController' => 'applications/pholio/controller/PholioInlineSaveController.php',
|
||||||
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
|
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
|
||||||
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
|
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
|
||||||
'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php',
|
'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php',
|
||||||
|
@ -2816,6 +2817,7 @@ phutil_register_library_map(array(
|
||||||
0 => 'PholioDAO',
|
0 => 'PholioDAO',
|
||||||
1 => 'PhabricatorMarkupInterface',
|
1 => 'PhabricatorMarkupInterface',
|
||||||
),
|
),
|
||||||
|
'PholioInlineSaveController' => 'PholioController',
|
||||||
'PholioMock' =>
|
'PholioMock' =>
|
||||||
array(
|
array(
|
||||||
0 => 'PholioDAO',
|
0 => 'PholioDAO',
|
||||||
|
|
|
@ -43,6 +43,7 @@ final class PhabricatorApplicationPholio extends PhabricatorApplication {
|
||||||
'new/' => 'PholioMockEditController',
|
'new/' => 'PholioMockEditController',
|
||||||
'edit/(?P<id>\d+)/' => 'PholioMockEditController',
|
'edit/(?P<id>\d+)/' => 'PholioMockEditController',
|
||||||
'comment/(?P<id>\d+)/' => 'PholioMockCommentController',
|
'comment/(?P<id>\d+)/' => 'PholioMockCommentController',
|
||||||
|
'inline/(?P<id>\d+)/' => 'PholioInlineSaveController',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group pholio
|
||||||
|
*/
|
||||||
|
final class PholioInlineSaveController extends PholioController {
|
||||||
|
|
||||||
|
public function processRequest() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$user = $request->getUser();
|
||||||
|
|
||||||
|
$mock = id(new PholioMockQuery())
|
||||||
|
->setViewer($user)
|
||||||
|
->requireCapabilities(
|
||||||
|
array(
|
||||||
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
PhabricatorPolicyCapability::CAN_EDIT,
|
||||||
|
))
|
||||||
|
->withIDs(array($request->getInt('mockID')))
|
||||||
|
->executeOne();
|
||||||
|
|
||||||
|
if (!$mock) {
|
||||||
|
return new Aphront404Response();
|
||||||
|
}
|
||||||
|
|
||||||
|
$draft = id(new PholioTransactionComment());
|
||||||
|
$draft->setImageID($request->getInt('imageID'));
|
||||||
|
$draft->setX($request->getInt('startX'));
|
||||||
|
$draft->setY($request->getInt('startY'));
|
||||||
|
|
||||||
|
$draft->setCommentVersion(1);
|
||||||
|
$draft->setAuthorPHID($user->getPHID());
|
||||||
|
$draft->setEditPolicy($user->getPHID());
|
||||||
|
$draft->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC);
|
||||||
|
|
||||||
|
$content_source = PhabricatorContentSource::newForSource(
|
||||||
|
PhabricatorContentSource::SOURCE_WEB,
|
||||||
|
array(
|
||||||
|
'ip' => $request->getRemoteAddr(),
|
||||||
|
));
|
||||||
|
|
||||||
|
$draft->setContentSource($content_source);
|
||||||
|
|
||||||
|
$draft->setWidth($request->getInt('endX') - $request->getInt('startX'));
|
||||||
|
$draft->setHeight($request->getInt('endY') - $request->getInt('startY'));
|
||||||
|
|
||||||
|
$draft->setContent($request->getStr('comment'));
|
||||||
|
|
||||||
|
$draft->save();
|
||||||
|
|
||||||
|
return id(new AphrontAjaxResponse())->setContent(array());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,9 @@ final class PholioMockImagesView extends AphrontView {
|
||||||
|
|
||||||
$main_image_id = celerity_generate_unique_node_id();
|
$main_image_id = celerity_generate_unique_node_id();
|
||||||
require_celerity_resource('javelin-behavior-pholio-mock-view');
|
require_celerity_resource('javelin-behavior-pholio-mock-view');
|
||||||
$config = array('mainID' => $main_image_id);
|
$config = array(
|
||||||
|
'mainID' => $main_image_id,
|
||||||
|
'mockID' => $this->mock->getID());
|
||||||
Javelin::initBehavior('pholio-mock-view', $config);
|
Javelin::initBehavior('pholio-mock-view', $config);
|
||||||
|
|
||||||
$mockview = "";
|
$mockview = "";
|
||||||
|
|
|
@ -113,11 +113,24 @@ JX.behavior('pholio-mock-view', function(config) {
|
||||||
|
|
||||||
selection.title = comment;
|
selection.title = comment;
|
||||||
|
|
||||||
console.log("ImageID: " + imageData['imageID'] +
|
var saveURL = "/pholio/inline/" + imageData['imageID'] + "/";
|
||||||
", coords: (" + Math.min(startPos.x, endPos.x) + "," +
|
|
||||||
Math.min(startPos.y, endPos.y) + ") -> (" +
|
var inlineComment = new JX.Request(saveURL, function(r) {
|
||||||
Math.max(startPos.x,endPos.x) + "," + Math.max(startPos.y,endPos.y) +
|
|
||||||
"), comment: " + comment);
|
});
|
||||||
|
|
||||||
|
var commentToAdd = {
|
||||||
|
mockID: config.mockID,
|
||||||
|
imageID: imageData['imageID'],
|
||||||
|
startX: Math.min(startPos.x, endPos.x),
|
||||||
|
startY: Math.min(startPos.y, endPos.y),
|
||||||
|
endX: Math.max(startPos.x,endPos.x),
|
||||||
|
endY: Math.max(startPos.y,endPos.y),
|
||||||
|
comment: comment};
|
||||||
|
|
||||||
|
|
||||||
|
inlineComment.addData(commentToAdd);
|
||||||
|
inlineComment.send();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue