1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-26 07:20:57 +01:00

Allow PhabricatorPropertyListView to have associated content

Summary:
Some objects (like PhamePost and ManiphestTask) have a block of text/remarkup which serves as a description or core piece of content for the object.

Accommodate this in PhabricatorPropertyListView.

(This is primarily to let me do a reasonable first pass on this in Phame.)

Test Plan: Made example, will attach screenshot.

Reviewers: btrahan, chad

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T1373

Differential Revision: https://secure.phabricator.com/D3699
This commit is contained in:
epriestley 2012-10-15 14:50:53 -07:00
parent 0e07ef8d56
commit 5fbb46df1c
5 changed files with 91 additions and 3 deletions

View file

@ -2630,7 +2630,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-property-list-view-css' => 'phabricator-property-list-view-css' =>
array( array(
'uri' => '/res/ff5d093d/rsrc/css/layout/phabricator-property-list-view.css', 'uri' => '/res/a853b8df/rsrc/css/layout/phabricator-property-list-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(

View file

@ -956,6 +956,7 @@ phutil_register_library_map(array(
'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php', 'PhabricatorProjectTransaction' => 'applications/project/storage/PhabricatorProjectTransaction.php',
'PhabricatorProjectTransactionType' => 'applications/project/constants/PhabricatorProjectTransactionType.php', 'PhabricatorProjectTransactionType' => 'applications/project/constants/PhabricatorProjectTransactionType.php',
'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php', 'PhabricatorProjectUpdateController' => 'applications/project/controller/PhabricatorProjectUpdateController.php',
'PhabricatorPropertyListExample' => 'applications/uiexample/examples/PhabricatorPropertyListExample.php',
'PhabricatorPropertyListView' => 'view/layout/PhabricatorPropertyListView.php', 'PhabricatorPropertyListView' => 'view/layout/PhabricatorPropertyListView.php',
'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php', 'PhabricatorQuery' => 'infrastructure/query/PhabricatorQuery.php',
'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php', 'PhabricatorRedirectController' => 'applications/base/controller/PhabricatorRedirectController.php',
@ -2102,6 +2103,7 @@ phutil_register_library_map(array(
'PhabricatorProjectTransaction' => 'PhabricatorProjectDAO', 'PhabricatorProjectTransaction' => 'PhabricatorProjectDAO',
'PhabricatorProjectTransactionType' => 'PhabricatorProjectConstants', 'PhabricatorProjectTransactionType' => 'PhabricatorProjectConstants',
'PhabricatorProjectUpdateController' => 'PhabricatorProjectController', 'PhabricatorProjectUpdateController' => 'PhabricatorProjectController',
'PhabricatorPropertyListExample' => 'PhabricatorUIExample',
'PhabricatorPropertyListView' => 'AphrontView', 'PhabricatorPropertyListView' => 'AphrontView',
'PhabricatorRedirectController' => 'PhabricatorController', 'PhabricatorRedirectController' => 'PhabricatorController',
'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController', 'PhabricatorRefreshCSRFController' => 'PhabricatorAuthController',

View file

@ -0,0 +1,56 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorPropertyListExample extends PhabricatorUIExample {
public function getName() {
return 'Property List';
}
public function getDescription() {
return 'Use <tt>PhabricatorPropertyListView</tt> to render object '.
'properties.';
}
public function renderExample() {
$request = $this->getRequest();
$user = $request->getUser();
$view = new PhabricatorPropertyListView();
$view->addProperty(
pht('Color'),
pht('Yellow'));
$view->addProperty(
pht('Size'),
pht('Mouse'));
$view->addProperty(
pht('Element'),
pht('Electric'));
$view->addTextContent(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '.
'Quisque rhoncus tempus massa, sit amet faucibus lectus bibendum '.
'viverra. Nunc tempus tempor quam id iaculis. Maecenas lectus '.
'velit, aliquam et consequat quis, tincidunt id dolor.');
return $view;
}
}

View file

@ -18,13 +18,23 @@
final class PhabricatorPropertyListView extends AphrontView { final class PhabricatorPropertyListView extends AphrontView {
private $properties; private $properties = array();
public function addProperty($key, $value) { public function addProperty($key, $value) {
$this->properties[$key] = $value; $this->properties[$key] = $value;
return $this; return $this;
} }
public function addTextContent($content) {
return $this->appendChild(
phutil_render_tag(
'div',
array(
'class' => 'phabricator-property-list-text-content',
),
$content));
}
public function render() { public function render() {
require_celerity_resource('phabricator-property-list-view-css'); require_celerity_resource('phabricator-property-list-view-css');
@ -50,6 +60,16 @@ final class PhabricatorPropertyListView extends AphrontView {
), ),
$this->renderSingleView($items)); $this->renderSingleView($items));
$content = $this->renderChildren();
if (strlen($content)) {
$content = phutil_render_tag(
'div',
array(
'class' => 'phabricator-property-list-content',
),
$content);
}
return phutil_render_tag( return phutil_render_tag(
'div', 'div',
array( array(
@ -60,7 +80,8 @@ final class PhabricatorPropertyListView extends AphrontView {
// sure the property list is taller than the action list for objects with // sure the property list is taller than the action list for objects with
// few properties but many actions. Otherwise, the action list may // few properties but many actions. Otherwise, the action list may
// obscure the document content. // obscure the document content.
'<div class="phabriator-property-list-view-end"></div>'); '<div class="phabriator-property-list-view-end"></div>').
$content;
} }

View file

@ -57,3 +57,12 @@
padding-left: 1.5em; padding-left: 1.5em;
margin-bottom: .5em; margin-bottom: .5em;
} }
.phabricator-property-list-content {
background: #fdfdfd;
border-bottom: 1px solid #dbdbdb;
}
.phabricator-property-list-text-content {
padding: 12px 18px;
}