1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Conpherence - make adding participants be a little dialogue.

Summary: and now you can add more than one at a time! Also adds the 'add participants' and 'new calendar event' options to mobile view. Fixes T3251. Ref T3253.

Test Plan: loaded up these "adders" on both desktop and device-ish views and it went well!

Reviewers: epriestley, chad

Reviewed By: chad

CC: chad, aran, Korvin

Maniphest Tasks: T3251, T3253

Differential Revision: https://secure.phabricator.com/D6075
This commit is contained in:
Bob Trahan 2013-05-29 17:21:07 -07:00
parent 4cbac3fa06
commit 38e6961cbd
8 changed files with 125 additions and 102 deletions

View file

@ -945,7 +945,7 @@ celerity_register_resource_map(array(
), ),
'conpherence-widget-pane-css' => 'conpherence-widget-pane-css' =>
array( array(
'uri' => '/res/e06804b6/rsrc/css/application/conpherence/widget-pane.css', 'uri' => '/res/40be33e2/rsrc/css/application/conpherence/widget-pane.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -1325,7 +1325,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-conpherence-widget-pane' => 'javelin-behavior-conpherence-widget-pane' =>
array( array(
'uri' => '/res/3b06849a/rsrc/js/application/conpherence/behavior-widget-pane.js', 'uri' => '/res/440f5bdf/rsrc/js/application/conpherence/behavior-widget-pane.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(

View file

@ -13,6 +13,22 @@ abstract class ConpherenceController extends PhabricatorController {
pht('New Message'), pht('New Message'),
$this->getApplicationURI('new/')); $this->getApplicationURI('new/'));
$nav->addMenuItem(
id(new PhabricatorMenuItemView())
->setName(pht('Add Participants'))
->setType(PhabricatorMenuItemView::TYPE_LINK)
->setHref('#')
->addSigil('conpherence-widget-adder')
->setMetadata(array('widget' => 'widgets-people')));
$nav->addMenuItem(
id(new PhabricatorMenuItemView())
->setName(pht('New Calendar Item'))
->setType(PhabricatorMenuItemView::TYPE_LINK)
->setHref('/calendar/status/create/')
->addSigil('conpherence-widget-adder')
->setMetadata(array('widget' => 'widgets-calendar')));
return $nav; return $nav;
} }

View file

@ -54,13 +54,12 @@ final class ConpherenceUpdateController
break; break;
case ConpherenceUpdateActions::ADD_PERSON: case ConpherenceUpdateActions::ADD_PERSON:
$xactions = array(); $xactions = array();
$person_tokenizer = $request->getArr('add_person'); $person_phids = $request->getArr('add_person');
$person_phid = reset($person_tokenizer); if (!empty($person_phids)) {
if ($person_phid) {
$xactions[] = id(new ConpherenceTransaction()) $xactions[] = id(new ConpherenceTransaction())
->setTransactionType( ->setTransactionType(
ConpherenceTransactionType::TYPE_PARTICIPANTS) ConpherenceTransactionType::TYPE_PARTICIPANTS)
->setNewValue(array('+' => array($person_phid))); ->setNewValue(array('+' => $person_phids));
} }
break; break;
case ConpherenceUpdateActions::REMOVE_PERSON: case ConpherenceUpdateActions::REMOVE_PERSON:
@ -153,6 +152,9 @@ final class ConpherenceUpdateController
} }
switch ($action) { switch ($action) {
case ConpherenceUpdateActions::ADD_PERSON:
$dialogue = $this->renderAddPersonDialogue($conpherence);
break;
case ConpherenceUpdateActions::REMOVE_PERSON: case ConpherenceUpdateActions::REMOVE_PERSON:
$dialogue = $this->renderRemovePersonDialogue($conpherence); $dialogue = $this->renderRemovePersonDialogue($conpherence);
break; break;
@ -172,6 +174,27 @@ final class ConpherenceUpdateController
} }
private function renderAddPersonDialogue(
ConpherenceThread $conpherence) {
$request = $this->getRequest();
$user = $request->getUser();
$add_person = $request->getStr('add_person');
$body = id(new AphrontFormTokenizerControl())
->setPlaceholder(pht('Add participants...'))
->setName('add_person')
->setUser($user)
->setDatasource('/typeahead/common/users/')
->setLimit(1);
require_celerity_resource('conpherence-update-css');
return id(new AphrontDialogView())
->setTitle(pht('Update Conpherence Participants'))
->addHiddenInput('action', 'add_person')
->appendChild($body);
}
private function renderRemovePersonDialogue( private function renderRemovePersonDialogue(
ConpherenceThread $conpherence) { ConpherenceThread $conpherence) {

View file

@ -69,6 +69,7 @@ final class ConpherenceWidgetController extends
->setSpriteSheet(PHUIIconView::SPRITE_ACTIONS) ->setSpriteSheet(PHUIIconView::SPRITE_ACTIONS)
->setSpriteIcon('new-grey') ->setSpriteIcon('new-grey')
->setHref($this->getWidgetURI()) ->setHref($this->getWidgetURI())
->setMetadata(array('widget' => null))
->addSigil('conpherence-widget-adder'); ->addSigil('conpherence-widget-adder');
$widgets[] = phutil_tag( $widgets[] = phutil_tag(
'div', 'div',

View file

@ -77,7 +77,7 @@ final class ConpherenceLayoutView extends AphrontView {
Javelin::initBehavior( Javelin::initBehavior(
'conpherence-widget-pane', 'conpherence-widget-pane',
array( array(
'selectChar' => "\xE2\x96\xBC", 'widgetBaseUpdateURI' => $this->baseURI . 'update/',
'widgetRegistry' => array( 'widgetRegistry' => array(
'conpherence-message-pane' => array( 'conpherence-message-pane' => array(
'name' => pht('Thread'), 'name' => pht('Thread'),
@ -87,7 +87,12 @@ final class ConpherenceLayoutView extends AphrontView {
'widgets-people' => array( 'widgets-people' => array(
'name' => pht('Participants'), 'name' => pht('Participants'),
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => false 'hasCreate' => true,
'createData' => array(
'refreshFromResponse' => true,
'action' => ConpherenceUpdateActions::ADD_PERSON,
'customHref' => null
)
), ),
'widgets-files' => array( 'widgets-files' => array(
'name' => pht('Files'), 'name' => pht('Files'),
@ -98,7 +103,11 @@ final class ConpherenceLayoutView extends AphrontView {
'name' => pht('Calendar'), 'name' => pht('Calendar'),
'deviceOnly' => false, 'deviceOnly' => false,
'hasCreate' => true, 'hasCreate' => true,
'createHref' => '/calendar/status/create/' 'createData' => array(
'refreshFromResponse' => false,
'action' => ConpherenceUpdateActions::ADD_STATUS,
'customHref' => '/calendar/status/create/'
)
), ),
'widgets-settings' => array( 'widgets-settings' => array(
'name' => pht('Settings'), 'name' => pht('Settings'),

View file

@ -12,46 +12,6 @@ final class ConpherencePeopleWidgetView extends ConpherenceWidgetView {
$participants = $conpherence->getParticipants(); $participants = $conpherence->getParticipants();
$handles = $conpherence->getHandles(); $handles = $conpherence->getHandles();
// ye olde add people widget
$add_widget = phabricator_form(
$user,
array(
'method' => 'POST',
'action' => $this->getUpdateURI(),
'sigil' => 'add-person',
'meta' => array(
'action' => 'add_person'
)
),
array(
id(new AphrontFormTokenizerControl())
->setPlaceholder(pht('Add a person...'))
->setName('add_person')
->setUser($user)
->setDatasource('/typeahead/common/users/')
->setLimit(1),
phutil_tag(
'button',
array(
'type' => 'submit',
'class' => 'people-add-button',
),
pht('Add'))
));
$header = phutil_tag(
'div',
array(
'class' => 'people-widget-header'
),
array(
phutil_tag(
'div',
array(
'class' => 'add-people-widget',
),
$add_widget)
));
$body = array(); $body = array();
// future proof by using participants to iterate through handles; // future proof by using participants to iterate through handles;
// we may have non-people handles sooner or later // we may have non-people handles sooner or later
@ -97,6 +57,6 @@ final class ConpherencePeopleWidgetView extends ConpherenceWidgetView {
$remove_html)); $remove_html));
} }
return array($header, $body); return $body;
} }
} }

View file

@ -344,7 +344,7 @@
.conpherence-widget-pane .person-entry { .conpherence-widget-pane .person-entry {
clear: both; clear: both;
padding: 5px 0 0 10px; padding: 10px 0px 0px 10px;
} }
.conpherence-widget-pane .person-entry a { .conpherence-widget-pane .person-entry a {

View file

@ -229,66 +229,81 @@ JX.behavior('conpherence-widget-pane', function(config) {
'conpherence-widget-adder', 'conpherence-widget-adder',
function (e) { function (e) {
e.kill(); e.kill();
var widgets = config.widgetRegistry; var widgets = config.widgetRegistry;
var active_widget = null; // the widget key might be in node data, but otherwise use the
var href = null; // selected widget
var event_data = e.getNodeData('conpherence-widget-adder');
var widget_key = _selectedWidgetName;
if (event_data.widget) {
widget_key = widgets[event_data.widget].name;
}
var widget_to_update = null;
var create_data = null;
for (var widget in widgets) { for (var widget in widgets) {
if (widgets[widget].name == _selectedWidgetName) { if (widgets[widget].name == widget_key) {
href = widgets[widget].createHref; create_data = widgets[widget].createData;
active_widget = widget; widget_to_update = widget;
break; break;
} }
} }
new JX.Workflow(href, {}) // this should be impossible, but hey
.setHandler(function () { if (!widget_to_update) {
JX.Stratcom.invoke( return;
'conpherence-reload-widget',
null,
{
threadID : _loadedWidgetsID,
widget : active_widget
} }
); var href = config.widgetBaseUpdateURI + _loadedWidgetsID + '/';
}) if (create_data.customHref) {
.start(); href = create_data.customHref;
} }
);
/* people widget */ var root = JX.DOM.find(document, 'div', 'conpherence-layout');
JX.Stratcom.listen(
['submit', 'didSyntheticSubmit'],
'add-person',
function (e) {
e.kill();
var root = e.getNode('conpherence-layout');
var form = e.getNode('tag:form');
var data = e.getNodeData('add-person');
var people_root = e.getNode('widgets-people');
var messages = null;
try {
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
} catch (ex) {
}
var latest_transaction_data = JX.Stratcom.getData( var latest_transaction_data = JX.Stratcom.getData(
JX.DOM.find( JX.DOM.find(
root, root,
'input', 'input',
'latest-transaction-id' 'latest-transaction-id'
)); ));
data.latest_transaction_id = latest_transaction_data.id; var data = {
JX.Workflow.newFromForm(form, data) latest_transaction_id : latest_transaction_data.id,
.setHandler(JX.bind(this, function (r) { action : create_data.action
};
new JX.Workflow(href, data)
.setHandler(function (r) {
if (create_data.refreshFromResponse) {
var messages = null;
try {
messages = JX.DOM.find(root, 'div', 'conpherence-messages');
} catch (ex) {
}
if (messages) { if (messages) {
JX.DOM.appendContent(messages, JX.$H(r.transactions)); JX.DOM.appendContent(messages, JX.$H(r.transactions));
messages.scrollTop = messages.scrollHeight; messages.scrollTop = messages.scrollHeight;
} }
if (r.people_widget) {
try {
var people_root = JX.DOM.find(root, 'div', 'widgets-people');
// update the people widget // update the people widget
JX.DOM.setContent( JX.DOM.setContent(
people_root, people_root,
JX.$H(r.people_widget) JX.$H(r.people_widget));
); } catch (ex) {
})) }
}
// otherwise let's redraw the widget somewhat lazily
} else {
JX.Stratcom.invoke(
'conpherence-reload-widget',
null,
{
threadID : _loadedWidgetsID,
widget : widget_to_update
});
}
})
.start(); .start();
} }
); );
@ -297,11 +312,10 @@ JX.behavior('conpherence-widget-pane', function(config) {
['touchstart', 'mousedown'], ['touchstart', 'mousedown'],
'remove-person', 'remove-person',
function (e) { function (e) {
var people_root = e.getNode('widgets-people'); var href = config.widgetBaseUpdateURI + _loadedWidgetsID + '/';
var form = JX.DOM.find(peopleRoot, 'form');
var data = e.getNodeData('remove-person'); var data = e.getNodeData('remove-person');
// we end up re-directing to conpherence home // we end up re-directing to conpherence home
JX.Workflow.newFromForm(form, data) new JX.Workflow(href, data)
.start(); .start();
} }
); );