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

Conpherence - add draft support

Summary: Fixes T3497.

Test Plan: on conpherence 1, typed some stuff. clicked conpherence 2 - observed some stuff gone. clicked conpherence 1 - stuff came back! submitted conpherence 1 and reloaded - stuff did not come back.  (Generally played around a bunch like this)

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, epriestley, aran

Maniphest Tasks: T3497

Differential Revision: https://secure.phabricator.com/D8266
This commit is contained in:
Bob Trahan 2014-02-17 15:57:13 -08:00
parent d016cac915
commit e4d60bbc15
6 changed files with 58 additions and 23 deletions

View file

@ -344,7 +344,7 @@ return array(
'rsrc/js/application/aphlict/behavior-aphlict-listen.js' => '845731b8',
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/config/behavior-reorder-fields.js' => '69bb5094',
'rsrc/js/application/conpherence/behavior-menu.js' => '872bc8ff',
'rsrc/js/application/conpherence/behavior-menu.js' => '7ff0b011',
'rsrc/js/application/conpherence/behavior-pontificate.js' => '53f6f2dd',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => 'd8ef8659',
'rsrc/js/application/countdown/timer.js' => '8454ce4f',
@ -531,7 +531,7 @@ return array(
'javelin-behavior-audit-preview' => 'be81801d',
'javelin-behavior-balanced-payment-form' => '3b3e1664',
'javelin-behavior-config-reorder-fields' => '69bb5094',
'javelin-behavior-conpherence-menu' => '872bc8ff',
'javelin-behavior-conpherence-menu' => '7ff0b011',
'javelin-behavior-conpherence-pontificate' => '53f6f2dd',
'javelin-behavior-conpherence-widget-pane' => 'd8ef8659',
'javelin-behavior-countdown-timer' => '8454ce4f',
@ -1291,6 +1291,18 @@ return array(
0 => 'javelin-behavior',
1 => 'javelin-history',
),
'7ff0b011' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-util',
3 => 'javelin-stratcom',
4 => 'javelin-workflow',
5 => 'javelin-behavior-device',
6 => 'javelin-history',
7 => 'javelin-vector',
8 => 'phabricator-shaped-request',
),
'828a2eed' =>
array(
0 => 'javelin-behavior',
@ -1348,17 +1360,6 @@ return array(
1 => 'javelin-dom',
2 => 'javelin-stratcom',
),
'872bc8ff' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-dom',
2 => 'javelin-util',
3 => 'javelin-stratcom',
4 => 'javelin-workflow',
5 => 'javelin-behavior-device',
6 => 'javelin-history',
7 => 'javelin-vector',
),
'89889fe7' =>
array(
0 => 'javelin-install',

View file

@ -4,6 +4,7 @@ final class ConpherenceUpdateActions extends ConpherenceConstants {
const METADATA = 'metadata';
const MESSAGE = 'message';
const DRAFT = 'draft';
const ADD_PERSON = 'add_person';
const REMOVE_PERSON = 'remove_person';
const NOTIFICATIONS = 'notifications';

View file

@ -1,8 +1,5 @@
<?php
/**
* @group conpherence
*/
final class ConpherenceUpdateController
extends ConpherenceController {
@ -39,6 +36,7 @@ final class ConpherenceUpdateController
$error_view = null;
$e_file = array();
$errors = array();
$delete_draft = false;
if ($request->isFormPost()) {
$editor = id(new ConpherenceEditor())
->setContinueOnNoEffect($request->isContinueRequest())
@ -46,11 +44,19 @@ final class ConpherenceUpdateController
->setActor($user);
switch ($action) {
case ConpherenceUpdateActions::DRAFT:
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->setDraft($request->getStr('text'));
$draft->replaceOrDelete();
break;
case ConpherenceUpdateActions::MESSAGE:
$message = $request->getStr('text');
$xactions = $editor->generateTransactionsFromText(
$conpherence,
$message);
$delete_draft = true;
break;
case ConpherenceUpdateActions::ADD_PERSON:
$xactions = array();
@ -116,6 +122,12 @@ final class ConpherenceUpdateController
if ($xactions) {
try {
$xactions = $editor->applyTransactions($conpherence, $xactions);
if ($delete_draft) {
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$draft->delete();
}
} catch (PhabricatorApplicationTransactionNoEffectException $ex) {
return id(new PhabricatorApplicationTransactionNoEffectResponse())
->setCancelURI($this->getApplicationURI($conpherence_id.'/'))

View file

@ -1,8 +1,5 @@
<?php
/**
* @group conpherence
*/
final class ConpherenceViewController extends
ConpherenceController {
@ -130,9 +127,12 @@ final class ConpherenceViewController extends
$conpherence = $this->getConpherence();
$user = $this->getRequest()->getUser();
$draft = PhabricatorDraft::newFromUserAndKey(
$user,
$conpherence->getPHID());
$update_uri = $this->getApplicationURI('update/'.$conpherence->getID().'/');
Javelin::initBehavior('conpherence-pontificate');
$this->initBehavior('conpherence-pontificate');
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
$form =
@ -145,7 +145,8 @@ final class ConpherenceViewController extends
->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($user)
->setName('text'))
->setName('text')
->setValue($draft->getDraft()))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(

View file

@ -62,7 +62,7 @@ final class ConpherenceLayoutView extends AphrontView {
$selected_id = $this->thread->getPHID() . '-nav-item';
$selected_thread_id = $this->thread->getID();
}
Javelin::initBehavior('conpherence-menu',
$this->initBehavior('conpherence-menu',
array(
'baseURI' => $this->baseURI,
'layoutID' => $layout_id,
@ -74,7 +74,7 @@ final class ConpherenceLayoutView extends AphrontView {
'hasWidgets' => false,
));
Javelin::initBehavior(
$this->initBehavior(
'conpherence-widget-pane',
array(
'widgetBaseUpdateURI' => $this->baseURI . 'update/',

View file

@ -8,6 +8,7 @@
* javelin-behavior-device
* javelin-history
* javelin-vector
* phabricator-shaped-request
*/
JX.behavior('conpherence-menu', function(config) {
@ -527,4 +528,23 @@ JX.behavior('conpherence-menu', function(config) {
handleThreadScrollers
);
var onkeydownDraft = function (e) {
var form = e.getNode('tag:form');
var uri = config.baseURI + 'update/' + _thread.selected + '/';
var draftRequest = new JX.PhabricatorShapedRequest(
uri,
JX.bag,
function () {
var data = JX.DOM.convertFormToDictionary(form);
data.action = 'draft';
return data;
});
draftRequest.start();
};
JX.Stratcom.listen(
['keydown'],
'conpherence-pontificate',
onkeydownDraft);
});