Inset view controller for inset elements of forms.

Summary:
T937 suggests 'inset' could have its own view controller.

It has the following methods:
 - setTitle         for title
 - setRightbutton   if you have to place something (preferably a button)
                    on the right side of the form
 - setDescription   if you want to describe what it does
 - setContent       for the main content
 - addDivAttributes REALLY not sure about this one but it had to be included
                    because of a single controller (see owners/controller/edit/PhabricatorOwnersEditController.php:238)
 - appendChild      works as usual if your form is complex but you still want to remove
                    ->appendChild('<div class..') ->appendChild('</div>');

It might be an overkill so maybe some could be dropped:
 - addDivAttributes() and just rewrite how PhabricatorOwnersEditController.php works
 - setContent() and use appendChild for the main content?

Test Plan:
 - Looked at the controllers in phabricator
 - Changed the controller
 - Opened the page in another tab
 - If something didnd't look the same I fixed it.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1926
This commit is contained in:
Hafsteinn Baldvinsson
2012-03-15 17:10:19 -07:00
committed by epriestley
parent 7c67b5e600
commit fffc1e51d0
13 changed files with 243 additions and 123 deletions

View File

@@ -258,11 +258,9 @@ final class PhabricatorProjectProfileEditController
->setError($e_image)
->setCaption('Supported formats: '.implode(', ', $supported_formats)))
->appendChild(
'<h1>Resources</h1>'.
'<input type="hidden" name="resources" id="resources" />'.
'<div class="aphront-form-inset">'.
'<div style="float: right;">'.
javelin_render_tag(
id(new AphrontFormInsetView())
->setTitle('Resources')
->setRightButton(javelin_render_tag(
'a',
array(
'href' => '#',
@@ -270,18 +268,15 @@ final class PhabricatorProjectProfileEditController
'sigil' => 'add-resource',
'mustcapture' => true,
),
'Add New Resource').
'</div>'.
'<p></p>'.
'<div style="clear: both;"></div>'.
javelin_render_tag(
'Add New Resource'))
->addHiddenInput('resources', 'resources')
->setContent(javelin_render_tag(
'table',
array(
'sigil' => 'resources',
'class' => 'project-resource-table',
),
'').
'</div>')
'')))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton('/project/view/'.$project->getID().'/')

View File

@@ -31,6 +31,7 @@ phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/form/control/tokenizer');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/form/inset');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');