mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
a97968b9ff
Summary: adds ye olde people widget. Features include - handle-based display, so we get status for free. (Note less pretty than M14 would have it!) - can add a person - can remove a person - can see the people already in the conpherence Test Plan: added and removed people and noted they joined / re-added as appropriate. Tried to add someone already in the conpherence and got a "transaction has no effect" message Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2399 Differential Revision: https://secure.phabricator.com/D5466
110 lines
2.8 KiB
PHP
110 lines
2.8 KiB
PHP
<?php
|
|
/**
|
|
* @group conpherence
|
|
*/
|
|
final class ConpherencePeopleWidgetView extends ConpherenceWidgetView {
|
|
|
|
public function render() {
|
|
$conpherence = $this->getConpherence();
|
|
$widget_data = $conpherence->getWidgetData();
|
|
$user = $this->getUser();
|
|
$conpherence = $this->getConpherence();
|
|
$participants = $conpherence->getParticipants();
|
|
$handles = $conpherence->getHandles();
|
|
|
|
// ye olde add people widget
|
|
$add_widget = phabricator_form(
|
|
$user,
|
|
array(
|
|
'method' => 'POST',
|
|
'action' => $this->getUpdateURI(),
|
|
),
|
|
array(
|
|
id(new AphrontFormTokenizerControl())
|
|
->setPlaceholder(pht('Add a person...'))
|
|
->setName('add_person')
|
|
->setUser($user)
|
|
->setDatasource('/typeahead/common/users/')
|
|
->setLimit(1),
|
|
javelin_tag(
|
|
'button',
|
|
array(
|
|
'sigil' => 'add-person',
|
|
'class' => 'people-add-button',
|
|
'meta' => array(
|
|
'action' => 'add_person',
|
|
'latest_transaction_id' => $this->getLatestTransactionID()
|
|
)
|
|
),
|
|
pht('Add'))
|
|
));
|
|
$header = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'people-widget-header'
|
|
),
|
|
array(
|
|
phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'add-people-widget',
|
|
),
|
|
$add_widget),
|
|
phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'divider'
|
|
),
|
|
'')
|
|
));
|
|
|
|
$body = array();
|
|
// future proof by using participants to iterate through handles;
|
|
// we may have non-people handles sooner or later
|
|
foreach ($participants as $user_phid => $participant) {
|
|
$handle = $handles[$user_phid];
|
|
$remove_html = '';
|
|
if ($user_phid == $user->getPHID()) {
|
|
$remove_html = javelin_tag(
|
|
'a',
|
|
array(
|
|
'class' => 'remove',
|
|
'sigil' => 'remove-person',
|
|
'meta' => array(
|
|
'remove_person' => $handle->getPHID(),
|
|
'action' => 'remove_person',
|
|
'latest_transaction_id' => $this->getLatestTransactionID()
|
|
)
|
|
),
|
|
phutil_tag(
|
|
'span',
|
|
array(
|
|
'class' => 'icon'
|
|
),
|
|
'x'));
|
|
}
|
|
$body[] = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'person-entry'
|
|
),
|
|
array(
|
|
phutil_tag(
|
|
'a',
|
|
array(
|
|
'class' => 'pic',
|
|
),
|
|
phutil_tag(
|
|
'img',
|
|
array(
|
|
'src' => $handle->getImageURI()
|
|
),
|
|
'')),
|
|
$handle->renderLink(),
|
|
$remove_html));
|
|
}
|
|
|
|
return array($header, $body);
|
|
|
|
}
|
|
}
|