mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
Create button should be a dropdown with public and private options
Summary: Ref T8026, Create button should be a dropdown with public and private options Test Plan: Create both a public and private event. Confirm view policies apply correctly. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T8026 Differential Revision: https://secure.phabricator.com/D13033
This commit is contained in:
parent
ebb7ca8cbd
commit
50240eda03
5 changed files with 40 additions and 4 deletions
|
@ -5,11 +5,23 @@ abstract class PhabricatorCalendarController extends PhabricatorController {
|
|||
protected function buildApplicationCrumbs() {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
$actions = id(new PhabricatorActionListView())
|
||||
->setUser($this->getViewer())
|
||||
->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Create Private Event'))
|
||||
->setHref('/calendar/event/create/?mode=private'))
|
||||
->addAction(
|
||||
id(new PhabricatorActionView())
|
||||
->setName(pht('Create Public Event'))
|
||||
->setHref('/calendar/event/create/?mode=public'));
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PHUIListItemView())
|
||||
->setName(pht('Create Event'))
|
||||
->setHref($this->getApplicationURI().'event/create/')
|
||||
->setIcon('fa-plus-square'));
|
||||
->setIcon('fa-plus-square')
|
||||
->setDropdownMenu($actions));
|
||||
|
||||
return $crumbs;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,10 @@ final class PhabricatorCalendarEventEditController
|
|||
$uri_query = $request->getStr('query');
|
||||
|
||||
if ($this->isCreate()) {
|
||||
$event = PhabricatorCalendarEvent::initializeNewCalendarEvent($viewer);
|
||||
$mode = $request->getStr('mode');
|
||||
$event = PhabricatorCalendarEvent::initializeNewCalendarEvent(
|
||||
$viewer,
|
||||
$mode);
|
||||
|
||||
$create_start_year = $request->getInt('year');
|
||||
$create_start_month = $request->getInt('month');
|
||||
|
|
|
@ -28,18 +28,26 @@ final class PhabricatorCalendarEvent extends PhabricatorCalendarDAO
|
|||
private $invitees = self::ATTACHABLE;
|
||||
private $appliedViewer;
|
||||
|
||||
public static function initializeNewCalendarEvent(PhabricatorUser $actor) {
|
||||
public static function initializeNewCalendarEvent(
|
||||
PhabricatorUser $actor,
|
||||
$mode) {
|
||||
$app = id(new PhabricatorApplicationQuery())
|
||||
->setViewer($actor)
|
||||
->withClasses(array('PhabricatorCalendarApplication'))
|
||||
->executeOne();
|
||||
|
||||
if ($mode == 'public') {
|
||||
$view_policy = PhabricatorPolicies::getMostOpenPolicy();
|
||||
} else {
|
||||
$view_policy = $actor->getPHID();
|
||||
}
|
||||
|
||||
return id(new PhabricatorCalendarEvent())
|
||||
->setUserPHID($actor->getPHID())
|
||||
->setIsCancelled(0)
|
||||
->setIsAllDay(0)
|
||||
->setIcon(self::DEFAULT_ICON)
|
||||
->setViewPolicy($actor->getPHID())
|
||||
->setViewPolicy($view_policy)
|
||||
->setEditPolicy($actor->getPHID())
|
||||
->attachInvitees(array())
|
||||
->applyViewerTimezone($actor);
|
||||
|
|
|
@ -84,6 +84,7 @@ final class PHUICrumbsView extends AphrontView {
|
|||
'class' => implode(' ', $action_classes),
|
||||
'sigil' => implode(' ', $action_sigils),
|
||||
'style' => $action->getStyle(),
|
||||
'meta' => $action->getMetadata(),
|
||||
),
|
||||
array(
|
||||
$icon,
|
||||
|
|
|
@ -29,6 +29,18 @@ final class PHUIListItemView extends AphrontTagView {
|
|||
private $aural;
|
||||
private $profileImage;
|
||||
|
||||
public function setDropdownMenu(PhabricatorActionListView $actions) {
|
||||
Javelin::initBehavior('phui-dropdown-menu');
|
||||
|
||||
$this->addSigil('phui-dropdown-menu');
|
||||
$this->setMetadata(
|
||||
array(
|
||||
'items' => $actions,
|
||||
));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setAural($aural) {
|
||||
$this->aural = $aural;
|
||||
return $this;
|
||||
|
|
Loading…
Reference in a new issue