2013-08-26 20:53:11 +02:00
|
|
|
<?php
|
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
final class PHUIObjectBoxView extends AphrontView {
|
2013-08-26 20:53:11 +02:00
|
|
|
|
|
|
|
private $headerText;
|
|
|
|
private $formError = null;
|
|
|
|
private $form;
|
2013-09-19 00:31:58 +02:00
|
|
|
private $validationException;
|
2013-09-29 00:55:38 +02:00
|
|
|
private $header;
|
|
|
|
private $flush;
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
private $tabs = array();
|
|
|
|
private $propertyLists = array();
|
|
|
|
private $selectedTab;
|
|
|
|
|
|
|
|
public function addPropertyList(
|
|
|
|
PHUIPropertyListView $property_list,
|
|
|
|
PHUIListItemView $tab = null) {
|
|
|
|
|
|
|
|
if ($this->propertyLists) {
|
|
|
|
$already_has_tabs = (bool)$this->tabs;
|
|
|
|
$adding_new_tab = (bool)$tab;
|
|
|
|
|
|
|
|
if ($already_has_tabs xor $adding_new_tab) {
|
|
|
|
throw new Exception(
|
|
|
|
"You can not mix tabbed and un-tabbed property lists in the same ".
|
|
|
|
"BoxView.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($tab) {
|
|
|
|
if ($tab->getKey()) {
|
|
|
|
$key = $tab->getKey();
|
|
|
|
} else {
|
|
|
|
$key = 'tab.default.'.spl_object_hash($tab);
|
|
|
|
$tab->setKey($key);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$key = 'tab.default';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($tab) {
|
|
|
|
if (!$this->tabs) {
|
|
|
|
$this->selectedTab = $key;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($this->tabs[$key])) {
|
|
|
|
$tab->addSigil('phui-object-box-tab');
|
|
|
|
$tab->setMetadata(
|
|
|
|
array(
|
|
|
|
'tabKey' => $key,
|
|
|
|
));
|
|
|
|
|
|
|
|
if (!$tab->getHref()) {
|
|
|
|
$tab->setHref('#');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->tabs[$key] = $tab;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->propertyLists[$key][] = $property_list;
|
|
|
|
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
return $this;
|
|
|
|
}
|
2013-08-26 20:53:11 +02:00
|
|
|
|
|
|
|
public function setHeaderText($text) {
|
|
|
|
$this->headerText = $text;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFormError($error) {
|
|
|
|
$this->formError = $error;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-08-27 00:45:58 +02:00
|
|
|
public function setForm($form) {
|
2013-08-26 20:53:11 +02:00
|
|
|
$this->form = $form;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
public function setHeader(PHUIHeaderView $header) {
|
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFlush($flush) {
|
|
|
|
$this->flush = $flush;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-09-19 00:31:58 +02:00
|
|
|
public function setValidationException(
|
|
|
|
PhabricatorApplicationTransactionValidationException $ex = null) {
|
|
|
|
$this->validationException = $ex;
|
|
|
|
return $this;
|
|
|
|
}
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2013-09-19 00:31:58 +02:00
|
|
|
public function render() {
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
require_celerity_resource('phui-object-box-css');
|
|
|
|
|
|
|
|
if ($this->header) {
|
|
|
|
$header = $this->header;
|
|
|
|
$header->setGradient(PhabricatorActionHeaderView::HEADER_LIGHTBLUE);
|
|
|
|
} else {
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader($this->headerText)
|
|
|
|
->setGradient(PhabricatorActionHeaderView::HEADER_LIGHTBLUE);
|
|
|
|
}
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2013-09-19 00:31:58 +02:00
|
|
|
$ex = $this->validationException;
|
|
|
|
$exception_errors = null;
|
|
|
|
if ($ex) {
|
|
|
|
$messages = array();
|
|
|
|
foreach ($ex->getErrors() as $error) {
|
|
|
|
$messages[] = $error->getMessage();
|
|
|
|
}
|
|
|
|
if ($messages) {
|
|
|
|
$exception_errors = id(new AphrontErrorView())
|
|
|
|
->setErrors($messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
$property_lists = array();
|
|
|
|
$tab_map = array();
|
|
|
|
foreach ($this->propertyLists as $key => $list) {
|
|
|
|
$group = new PHUIPropertyGroupView();
|
|
|
|
foreach ($list as $item) {
|
|
|
|
$group->addPropertyList($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->tabs) {
|
|
|
|
$tab_id = celerity_generate_unique_node_id();
|
|
|
|
$tab_map[$key] = $tab_id;
|
|
|
|
|
|
|
|
if ($key === $this->selectedTab) {
|
|
|
|
$style = null;
|
|
|
|
} else {
|
|
|
|
$style = 'display: none';
|
|
|
|
}
|
|
|
|
|
|
|
|
$property_lists[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'style' => $style,
|
|
|
|
'id' => $tab_id,
|
|
|
|
),
|
|
|
|
$group);
|
|
|
|
} else {
|
|
|
|
$property_lists[] = $group;
|
2013-10-11 16:53:56 +02:00
|
|
|
}
|
2013-10-06 20:12:00 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
$tabs = null;
|
|
|
|
if ($this->tabs) {
|
|
|
|
$tabs = id(new PHUIListView())
|
|
|
|
->setType(PHUIListView::NAVBAR_LIST);
|
|
|
|
foreach ($this->tabs as $tab) {
|
|
|
|
$tabs->addMenuItem($tab);
|
|
|
|
}
|
|
|
|
|
|
|
|
Javelin::initBehavior('phui-object-box-tabs');
|
|
|
|
}
|
|
|
|
|
2013-08-26 20:53:11 +02:00
|
|
|
$content = id(new PHUIBoxView())
|
2013-09-19 00:31:58 +02:00
|
|
|
->appendChild(
|
|
|
|
array(
|
|
|
|
$header,
|
|
|
|
$this->formError,
|
|
|
|
$exception_errors,
|
|
|
|
$this->form,
|
2013-10-19 21:07:50 +02:00
|
|
|
$tabs,
|
|
|
|
$property_lists,
|
Provide more structure to PHUIObjectBoxView
Summary:
Three changes here.
- Add `setActionList()`, and use that to set the action list.
- Add `setPropertyList()`, and use that to set the property list.
These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors.
- Replace `addContent()` with `appendChild()`.
This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing.
Test Plan:
- Viewed "All Config".
- Viewed a countdown.
- Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history).
- Viewed Diffusion (browse, change, history, repository, lint).
- Viewed Drydock (resource, lease).
- Viewed Files.
- Viewed Herald.
- Viewed Legalpad.
- Viewed macro (edit, edit audio, view).
- Viewed Maniphest.
- Viewed Applications.
- Viewed Paste.
- Viewed People.
- Viewed Phulux.
- Viewed Pholio.
- Viewed Phame (blog, post).
- Viewed Phortune (account, product).
- Viewed Ponder (questions, answers, comments).
- Viewed Releeph.
- Viewed Projects.
- Viewed Slowvote.
NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose?
NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff.
Reviewers: chad
Reviewed By: chad
CC: aran
Differential Revision: https://secure.phabricator.com/D7174
2013-09-30 18:36:04 +02:00
|
|
|
$this->renderChildren(),
|
2013-09-19 00:31:58 +02:00
|
|
|
))
|
2013-08-26 20:53:11 +02:00
|
|
|
->setBorder(true)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE_TOP)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE_LEFT)
|
|
|
|
->addMargin(PHUI::MARGIN_LARGE_RIGHT)
|
2013-09-25 20:23:29 +02:00
|
|
|
->addClass('phui-object-box');
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
if ($this->tabs) {
|
|
|
|
$content->addSigil('phui-object-box');
|
|
|
|
$content->setMetadata(
|
|
|
|
array(
|
|
|
|
'tabMap' => $tab_map,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
if ($this->flush) {
|
|
|
|
$content->addClass('phui-object-box-flush');
|
|
|
|
}
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
return $content;
|
2013-08-26 20:53:11 +02:00
|
|
|
}
|
|
|
|
}
|