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:
parent
90d0e8a322
commit
b42b1f6817
3 changed files with 17 additions and 3 deletions
|
@ -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 '';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,4 +403,8 @@ final class PhrictionDocumentController
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getDocumentSlug() {
|
||||||
|
return $this->slug;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,25 +9,31 @@ 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')))
|
||||||
->appendChild($view)
|
->appendChild($view)
|
||||||
->addSubmitButton(pht('Create'))
|
->addSubmitButton(pht('Create'))
|
||||||
->addCancelButton('/w/');
|
->addCancelButton('/w/');
|
||||||
|
|
Loading…
Reference in a new issue