1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 22:40:55 +01:00

'Create Document' pre-fills with current slug

Summary:
Fixes T2667

The 'Create Document' link up in the application crumbs now prefills with the slug of the current document - if available, that is

Test Plan: verified that nothing crashed, that the correct slug was pre-filled, and that pages could be created

Reviewers: alexshtuk, epriestley

CC: aran, Korvin

Maniphest Tasks: T2667

Differential Revision: https://secure.phabricator.com/D5273
This commit is contained in:
Anh Nhan Nguyen 2013-03-07 08:12:00 -08:00 committed by epriestley
parent 90d0e8a322
commit b42b1f6817
3 changed files with 17 additions and 3 deletions

View file

@ -52,7 +52,7 @@ abstract class PhrictionController extends PhabricatorController {
$crumbs->addAction( $crumbs->addAction(
id(new PhabricatorMenuItemView()) id(new PhabricatorMenuItemView())
->setName(pht('Create Document')) ->setName(pht('Create Document'))
->setHref('/phriction/new/') ->setHref('/phriction/new/?slug='.$this->getDocumentSlug())
->setWorkflow(true) ->setWorkflow(true)
->setIcon('create')); ->setIcon('create'));
@ -98,4 +98,8 @@ abstract class PhrictionController extends PhabricatorController {
return $breadcrumbs; return $breadcrumbs;
} }
protected function getDocumentSlug() {
return '';
}
} }

View file

@ -403,4 +403,8 @@ final class PhrictionDocumentController
return $item; return $item;
} }
protected function getDocumentSlug() {
return $this->slug;
}
} }

View file

@ -9,22 +9,28 @@ final class PhrictionNewController extends PhrictionController {
$request = $this->getRequest(); $request = $this->getRequest();
$user = $request->getUser(); $user = $request->getUser();
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
if ($request->isFormPost()) { if ($request->isFormPost()) {
$slug = PhabricatorSlug::normalize($request->getStr('slug'));
$uri = '/phriction/edit/?slug='.$slug; $uri = '/phriction/edit/?slug='.$slug;
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($uri); ->setURI($uri);
} }
if ($slug == '/') {
$slug = '';
}
$view = id(new AphrontFormLayoutView()) $view = id(new AphrontFormLayoutView())
->appendChild(id(new AphrontFormTextControl()) ->appendChild(id(new AphrontFormTextControl())
->setLabel('/w/') ->setLabel('/w/')
->setValue($slug)
->setName('slug')); ->setName('slug'));
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle(pht('New Document')) ->setTitle(pht('New Document'))
->setSubmitURI('/phriction/new/')
->appendChild(phutil_tag('p', ->appendChild(phutil_tag('p',
array(), array(),
pht('Create a new document at'))) pht('Create a new document at')))