1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 08:42: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/aphlict/behavior-aphlict-listen.js' => '845731b8',
'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18', 'rsrc/js/application/auth/behavior-persona-login.js' => '9414ff18',
'rsrc/js/application/config/behavior-reorder-fields.js' => '69bb5094', '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-pontificate.js' => '53f6f2dd',
'rsrc/js/application/conpherence/behavior-widget-pane.js' => 'd8ef8659', 'rsrc/js/application/conpherence/behavior-widget-pane.js' => 'd8ef8659',
'rsrc/js/application/countdown/timer.js' => '8454ce4f', 'rsrc/js/application/countdown/timer.js' => '8454ce4f',
@ -531,7 +531,7 @@ return array(
'javelin-behavior-audit-preview' => 'be81801d', 'javelin-behavior-audit-preview' => 'be81801d',
'javelin-behavior-balanced-payment-form' => '3b3e1664', 'javelin-behavior-balanced-payment-form' => '3b3e1664',
'javelin-behavior-config-reorder-fields' => '69bb5094', 'javelin-behavior-config-reorder-fields' => '69bb5094',
'javelin-behavior-conpherence-menu' => '872bc8ff', 'javelin-behavior-conpherence-menu' => '7ff0b011',
'javelin-behavior-conpherence-pontificate' => '53f6f2dd', 'javelin-behavior-conpherence-pontificate' => '53f6f2dd',
'javelin-behavior-conpherence-widget-pane' => 'd8ef8659', 'javelin-behavior-conpherence-widget-pane' => 'd8ef8659',
'javelin-behavior-countdown-timer' => '8454ce4f', 'javelin-behavior-countdown-timer' => '8454ce4f',
@ -1291,6 +1291,18 @@ return array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
1 => 'javelin-history', 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' => '828a2eed' =>
array( array(
0 => 'javelin-behavior', 0 => 'javelin-behavior',
@ -1348,17 +1360,6 @@ return array(
1 => 'javelin-dom', 1 => 'javelin-dom',
2 => 'javelin-stratcom', 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' => '89889fe7' =>
array( array(
0 => 'javelin-install', 0 => 'javelin-install',

View file

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

View file

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

View file

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

View file

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

View file

@ -8,6 +8,7 @@
* javelin-behavior-device * javelin-behavior-device
* javelin-history * javelin-history
* javelin-vector * javelin-vector
* phabricator-shaped-request
*/ */
JX.behavior('conpherence-menu', function(config) { JX.behavior('conpherence-menu', function(config) {
@ -527,4 +528,23 @@ JX.behavior('conpherence-menu', function(config) {
handleThreadScrollers 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);
}); });