3 final class NuancePhabricatorFormSourceDefinition
4 extends NuanceSourceDefinition
{
6 public function getName() {
7 return pht('Phabricator Form');
10 public function getSourceDescription() {
11 return pht('Create a web form that submits into a Nuance queue.');
14 public function getSourceTypeConstant() {
15 return 'phabricator-form';
18 public function getSourceViewActions(AphrontRequest
$request) {
21 $actions[] = id(new PhabricatorActionView())
22 ->setName(pht('View Form'))
23 ->setIcon('fa-align-justify')
24 ->setHref($this->getActionURI());
29 public function handleActionRequest(AphrontRequest
$request) {
30 $viewer = $request->getViewer();
32 // TODO: As above, this would eventually be driven by custom logic.
34 if ($request->isFormPost()) {
36 'complaint' => (string)$request->getStr('complaint'),
39 $content_source = PhabricatorContentSource
::newFromRequest($request);
41 $item = $this->newItemFromProperties(
42 NuanceFormItemType
::ITEMTYPE
,
47 $uri = $item->getURI();
48 return id(new AphrontRedirectResponse())->setURI($uri);
51 $form = id(new AphrontFormView())
53 ->appendRemarkupInstructions(
54 pht('IMPORTANT: This is a very rough prototype.'))
55 ->appendRemarkupInstructions(
56 pht('Got a complaint? Complain here! We love complaints.'))
58 id(new AphrontFormTextAreaControl())
59 ->setName('complaint')
60 ->setLabel(pht('Complaint')))
62 id(new AphrontFormSubmitControl())
63 ->setValue(pht('Submit Complaint')));
65 $box = id(new PHUIObjectBoxView())
66 ->setHeaderText(pht('Complaint Form'))
72 public function renderItemEditProperties(
73 PhabricatorUser
$viewer,
75 PHUIPropertyListView
$view) {
76 $this->renderItemCommonProperties($viewer, $item, $view);
79 private function renderItemCommonProperties(
80 PhabricatorUser
$viewer,
82 PHUIPropertyListView
$view) {
84 $complaint = $item->getItemProperty('complaint');
85 $complaint = new PHUIRemarkupView($viewer, $complaint);
86 $view->addSectionHeader(
87 pht('Complaint'), 'fa-exclamation-circle');
88 $view->addTextContent($complaint);