mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 00:42:41 +01:00
Create a "New Document" button in phriction
Summary: gives user a dialogue and they can fill out what comes after /w/ Test Plan: made some new wiki docs. played with garbage data and edit scenarios as well as vanilla create -- good ish Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1360 Differential Revision: https://secure.phabricator.com/D3946
This commit is contained in:
parent
8ee6cbe1d4
commit
4a8ce1699b
4 changed files with 55 additions and 6 deletions
|
@ -1217,6 +1217,7 @@ phutil_register_library_map(array(
|
|||
'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php',
|
||||
'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php',
|
||||
'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php',
|
||||
'PhrictionNewController' => 'applications/phriction/controller/PhrictionNewController.php',
|
||||
'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php',
|
||||
'PonderAddCommentView' => 'applications/ponder/view/PonderAddCommentView.php',
|
||||
'PonderAnswer' => 'applications/ponder/storage/PonderAnswer.php',
|
||||
|
@ -2395,6 +2396,7 @@ phutil_register_library_map(array(
|
|||
'PhrictionEditController' => 'PhrictionController',
|
||||
'PhrictionHistoryController' => 'PhrictionController',
|
||||
'PhrictionListController' => 'PhrictionController',
|
||||
'PhrictionNewController' => 'PhrictionController',
|
||||
'PonderAddAnswerView' => 'AphrontView',
|
||||
'PonderAddCommentView' => 'AphrontView',
|
||||
'PonderAnswer' =>
|
||||
|
|
|
@ -38,6 +38,7 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication {
|
|||
|
||||
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'PhrictionEditController',
|
||||
'delete/(?P<id>[1-9]\d*)/' => 'PhrictionDeleteController',
|
||||
'new/' => 'PhrictionNewController',
|
||||
|
||||
'preview/' => 'PhrictionDocumentPreviewController',
|
||||
'diff/(?P<id>[1-9]\d*)/' => 'PhrictionDiffController',
|
||||
|
|
|
@ -159,24 +159,32 @@ final class PhrictionDocumentController
|
|||
'<div class="phriction-content">'.
|
||||
$byline.
|
||||
$core_content.
|
||||
'</div>';
|
||||
'</div>';
|
||||
|
||||
$create_button = javelin_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/phriction/new/',
|
||||
'class' => 'button green',
|
||||
'sigil' => 'workflow',
|
||||
),
|
||||
pht('New Document'));
|
||||
$edit_button = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => '/phriction/edit/'.$document->getID().'/',
|
||||
'href' => '/phriction/edit/'.$document->getID().'/',
|
||||
'class' => 'button',
|
||||
),
|
||||
'Edit Document');
|
||||
pht('Edit Document'));
|
||||
$history_button = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => PhrictionDocument::getSlugURI($slug, 'history'),
|
||||
'href' => PhrictionDocument::getSlugURI($slug, 'history'),
|
||||
'class' => 'button grey',
|
||||
),
|
||||
'View History');
|
||||
pht('View History'));
|
||||
// these float right so history_button which is right most goes first
|
||||
$buttons = $history_button.$edit_button;
|
||||
$buttons = $history_button.$edit_button.$create_button;
|
||||
}
|
||||
|
||||
if ($version_note) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @group phriction
|
||||
*/
|
||||
final class PhrictionNewController extends PhrictionController {
|
||||
|
||||
public function processRequest() {
|
||||
|
||||
$request = $this->getRequest();
|
||||
$user = $request->getUser();
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
|
||||
$uri = '/phriction/edit/?slug='.$slug;
|
||||
return id(new AphrontRedirectResponse())
|
||||
->setURI($uri);
|
||||
}
|
||||
|
||||
$view = id(new AphrontFormLayoutView())
|
||||
->appendChild(id(new AphrontFormTextControl())
|
||||
->setLabel('/w/')
|
||||
->setName('slug'));
|
||||
|
||||
$dialog = id(new AphrontDialogView())
|
||||
->setUser($user)
|
||||
->setTitle(pht('New Document'))
|
||||
->appendChild(phutil_render_tag('p',
|
||||
array(),
|
||||
pht('Create a new document at')))
|
||||
->appendChild($view)
|
||||
->addSubmitButton(pht('Create'))
|
||||
->addCancelButton($request->getRequestURI());
|
||||
|
||||
return id(new AphrontDialogResponse())->setDialog($dialog);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue