Differential D21845 Diff 52065 src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/slowvote/controller/PhabricatorSlowvoteEditController.php
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | if ($is_new) { | ||||
if ($ii == 0) { | if ($ii == 0) { | ||||
$response->setError($e_response); | $response->setError($e_response); | ||||
} | } | ||||
$form->appendChild($response); | $form->appendChild($response); | ||||
} | } | ||||
} | } | ||||
$poll_type_options = array( | $vote_type_map = SlowvotePollVotingMethod::getAll(); | ||||
PhabricatorSlowvotePoll::METHOD_PLURALITY => | $vote_type_options = mpull($vote_type_map, 'getNameForEdit'); | ||||
pht('Plurality (Single Choice)'), | |||||
PhabricatorSlowvotePoll::METHOD_APPROVAL => | $method = $poll->getMethod(); | ||||
pht('Approval (Multiple Choice)'), | if (!isset($vote_type_options[$method])) { | ||||
); | $method_object = | ||||
SlowvotePollVotingMethod::newVotingMethodObject( | |||||
$method); | |||||
$vote_type_options = array( | |||||
$method => $method_object->getNameForEdit(), | |||||
) + $vote_type_options; | |||||
} | |||||
$response_type_map = SlowvotePollResponseVisibility::getAll(); | $response_type_map = SlowvotePollResponseVisibility::getAll(); | ||||
$response_type_options = mpull($response_type_map, 'getNameForEdit'); | $response_type_options = mpull($response_type_map, 'getNameForEdit'); | ||||
$visibility = $poll->getResponseVisibility(); | $visibility = $poll->getResponseVisibility(); | ||||
if (!isset($response_type_options[$visibility])) { | if (!isset($response_type_options[$visibility])) { | ||||
$visibility_object = | $visibility_object = | ||||
SlowvotePollResponseVisibility::newResponseVisibilityObject( | SlowvotePollResponseVisibility::newResponseVisibilityObject( | ||||
$visibility); | $visibility); | ||||
$response_type_options = array( | $response_type_options = array( | ||||
$visibility => $visibility_object->getNameForEdit(), | $visibility => $visibility_object->getNameForEdit(), | ||||
) + $response_type_options; | ) + $response_type_options; | ||||
} | } | ||||
if ($is_new) { | if ($is_new) { | ||||
$form->appendChild( | $form->appendChild( | ||||
id(new AphrontFormSelectControl()) | id(new AphrontFormSelectControl()) | ||||
->setLabel(pht('Vote Type')) | ->setLabel(pht('Vote Type')) | ||||
->setName('method') | ->setName('method') | ||||
->setValue($poll->getMethod()) | ->setValue($poll->getMethod()) | ||||
->setOptions($poll_type_options)); | ->setOptions($vote_type_options)); | ||||
} else { | } else { | ||||
$form->appendChild( | $form->appendChild( | ||||
id(new AphrontFormStaticControl()) | id(new AphrontFormStaticControl()) | ||||
->setLabel(pht('Vote Type')) | ->setLabel(pht('Vote Type')) | ||||
->setValue(idx($poll_type_options, $poll->getMethod()))); | ->setValue(idx($vote_type_options, $poll->getMethod()))); | ||||
} | } | ||||
if ($is_new) { | if ($is_new) { | ||||
$title = pht('Create Slowvote'); | $title = pht('Create Slowvote'); | ||||
$button = pht('Create'); | $button = pht('Create'); | ||||
$cancel_uri = $this->getApplicationURI(); | $cancel_uri = $this->getApplicationURI(); | ||||
$header_icon = 'fa-plus-square'; | $header_icon = 'fa-plus-square'; | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |