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;
|
2014-06-24 18:39:32 +02:00
|
|
|
private $headerColor;
|
2014-01-10 18:17:37 +01:00
|
|
|
private $formErrors = null;
|
|
|
|
private $formSaved = false;
|
2015-03-07 02:03:18 +01:00
|
|
|
private $infoView;
|
2013-08-26 20:53:11 +02:00
|
|
|
private $form;
|
2013-09-19 00:31:58 +02:00
|
|
|
private $validationException;
|
2013-09-29 00:55:38 +02:00
|
|
|
private $header;
|
|
|
|
private $flush;
|
2014-01-09 17:51:57 +01:00
|
|
|
private $id;
|
2014-04-18 15:44:45 +02:00
|
|
|
private $sigils = array();
|
|
|
|
private $metadata;
|
2015-01-12 16:24:35 +01:00
|
|
|
private $actionListID;
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
private $objectList;
|
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();
|
|
|
|
|
2014-04-18 15:44:45 +02:00
|
|
|
public function addSigil($sigil) {
|
|
|
|
$this->sigils[] = $sigil;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMetadata(array $metadata) {
|
|
|
|
$this->metadata = $metadata;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
public function addPropertyList(
|
|
|
|
PHUIPropertyListView $property_list,
|
2013-10-19 21:08:06 +02:00
|
|
|
$tab = null) {
|
2013-10-19 21:07:50 +02:00
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
if (!($tab instanceof PHUIListItemView) &&
|
|
|
|
($tab !== null)) {
|
|
|
|
assert_stringlike($tab);
|
|
|
|
$tab = id(new PHUIListItemView())->setName($tab);
|
2013-10-19 21:07:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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 (empty($this->tabs[$key])) {
|
|
|
|
$tab->addSigil('phui-object-box-tab');
|
|
|
|
$tab->setMetadata(
|
|
|
|
array(
|
|
|
|
'tabKey' => $key,
|
|
|
|
));
|
|
|
|
|
|
|
|
if (!$tab->getHref()) {
|
|
|
|
$tab->setHref('#');
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
if (!$tab->getType()) {
|
|
|
|
$tab->setType(PHUIListItemView::TYPE_LINK);
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
$this->tabs[$key] = $tab;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->propertyLists[$key][] = $property_list;
|
|
|
|
|
2015-01-12 16:24:35 +01:00
|
|
|
$action_list = $property_list->getActionList();
|
|
|
|
if ($action_list) {
|
|
|
|
$this->actionListID = celerity_generate_unique_node_id();
|
|
|
|
$action_list->setId($this->actionListID);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-06-24 18:39:32 +02:00
|
|
|
public function setHeaderColor($color) {
|
|
|
|
$this->headerColor = $color;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-01-10 18:17:37 +01:00
|
|
|
public function setFormErrors(array $errors, $title = null) {
|
2014-10-10 01:58:26 +02:00
|
|
|
if ($errors) {
|
2015-03-01 23:45:56 +01:00
|
|
|
$this->formErrors = id(new PHUIInfoView())
|
2014-01-10 18:17:37 +01:00
|
|
|
->setTitle($title)
|
|
|
|
->setErrors($errors);
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFormSaved($saved, $text = null) {
|
|
|
|
if (!$text) {
|
|
|
|
$text = pht('Changes saved.');
|
|
|
|
}
|
|
|
|
if ($saved) {
|
2015-03-01 23:45:56 +01:00
|
|
|
$save = id(new PHUIInfoView())
|
|
|
|
->setSeverity(PHUIInfoView::SEVERITY_NOTICE)
|
2014-01-10 18:17:37 +01:00
|
|
|
->appendChild($text);
|
|
|
|
$this->formSaved = $save;
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2015-03-07 02:03:18 +01:00
|
|
|
public function setInfoView(PHUIInfoView $view) {
|
|
|
|
$this->infoView = $view;
|
2013-08-26 20:53:11 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-01-09 17:51:57 +01:00
|
|
|
public function setID($id) {
|
|
|
|
$this->id = $id;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2014-06-24 18:39:32 +02:00
|
|
|
public function setHeader($header) {
|
2013-09-29 00:55:38 +02:00
|
|
|
$this->header = $header;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setFlush($flush) {
|
|
|
|
$this->flush = $flush;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
public function setObjectList($list) {
|
|
|
|
$this->objectList = $list;
|
|
|
|
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');
|
|
|
|
|
2015-05-18 19:00:15 +02:00
|
|
|
$header_color = null;
|
2014-06-24 18:39:32 +02:00
|
|
|
if ($this->headerColor) {
|
|
|
|
$header_color = $this->headerColor;
|
|
|
|
}
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
if ($this->header) {
|
|
|
|
$header = $this->header;
|
2014-06-24 18:39:32 +02:00
|
|
|
$header->setHeaderColor($header_color);
|
2013-09-29 00:55:38 +02:00
|
|
|
} else {
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader($this->headerText)
|
2014-06-24 18:39:32 +02:00
|
|
|
->setHeaderColor($header_color);
|
2013-09-29 00:55:38 +02:00
|
|
|
}
|
2013-08-26 20:53:11 +02:00
|
|
|
|
2015-01-12 16:24:35 +01:00
|
|
|
if ($this->actionListID) {
|
|
|
|
$icon_id = celerity_generate_unique_node_id();
|
|
|
|
$icon = id(new PHUIIconView())
|
|
|
|
->setIconFont('fa-bars');
|
|
|
|
$meta = array(
|
|
|
|
'map' => array(
|
|
|
|
$this->actionListID => 'phabricator-action-list-toggle',
|
2015-01-12 17:21:17 +01:00
|
|
|
$icon_id => 'phuix-dropdown-open',
|
2015-04-05 14:29:39 +02:00
|
|
|
),
|
|
|
|
);
|
2015-01-12 16:24:35 +01:00
|
|
|
$mobile_menu = id(new PHUIButtonView())
|
|
|
|
->setTag('a')
|
|
|
|
->setText(pht('Actions'))
|
|
|
|
->setHref('#')
|
|
|
|
->setIcon($icon)
|
|
|
|
->addClass('phui-mobile-menu')
|
|
|
|
->setID($icon_id)
|
2015-01-12 17:21:17 +01:00
|
|
|
->addSigil('jx-toggle-class')
|
|
|
|
->setMetadata($meta);
|
2015-01-12 16:24:35 +01:00
|
|
|
$header->addActionLink($mobile_menu);
|
|
|
|
}
|
|
|
|
|
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) {
|
2015-03-01 23:45:56 +01:00
|
|
|
$exception_errors = id(new PHUIInfoView())
|
2013-09-19 00:31:58 +02:00
|
|
|
->setErrors($messages);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
$tab_lists = array();
|
2013-10-19 21:07:50 +02:00
|
|
|
$property_lists = array();
|
|
|
|
$tab_map = array();
|
2013-10-19 21:08:06 +02:00
|
|
|
|
|
|
|
$default_key = 'tab.default';
|
|
|
|
|
|
|
|
// Find the selected tab, or select the first tab if none are selected.
|
|
|
|
if ($this->tabs) {
|
|
|
|
$selected_tab = null;
|
|
|
|
foreach ($this->tabs as $key => $tab) {
|
|
|
|
if ($tab->getSelected()) {
|
|
|
|
$selected_tab = $key;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($selected_tab === null) {
|
|
|
|
head($this->tabs)->setSelected(true);
|
|
|
|
$selected_tab = head_key($this->tabs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:07:50 +02:00
|
|
|
foreach ($this->propertyLists as $key => $list) {
|
|
|
|
$group = new PHUIPropertyGroupView();
|
2013-11-04 17:52:46 +01:00
|
|
|
$i = 0;
|
2013-10-19 21:07:50 +02:00
|
|
|
foreach ($list as $item) {
|
|
|
|
$group->addPropertyList($item);
|
2013-11-04 17:52:46 +01:00
|
|
|
if ($i > 0) {
|
|
|
|
$item->addClass('phui-property-list-section-noninitial');
|
|
|
|
}
|
|
|
|
$i++;
|
2013-10-19 21:07:50 +02:00
|
|
|
}
|
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
if ($this->tabs && $key != $default_key) {
|
2013-10-19 21:07:50 +02:00
|
|
|
$tab_id = celerity_generate_unique_node_id();
|
|
|
|
$tab_map[$key] = $tab_id;
|
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
if ($key === $selected_tab) {
|
2013-10-19 21:07:50 +02:00
|
|
|
$style = null;
|
|
|
|
} else {
|
|
|
|
$style = 'display: none';
|
|
|
|
}
|
|
|
|
|
2013-10-19 21:08:06 +02:00
|
|
|
$tab_lists[] = phutil_tag(
|
2013-10-19 21:07:50 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'style' => $style,
|
|
|
|
'id' => $tab_id,
|
|
|
|
),
|
|
|
|
$group);
|
|
|
|
} else {
|
2013-10-19 21:08:06 +02:00
|
|
|
if ($this->tabs) {
|
|
|
|
$group->addClass('phui-property-group-noninitial');
|
|
|
|
}
|
2013-10-19 21:07:50 +02:00
|
|
|
$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,
|
2015-03-07 02:03:18 +01:00
|
|
|
$this->infoView,
|
2014-01-10 18:17:37 +01:00
|
|
|
$this->formErrors,
|
|
|
|
$this->formSaved,
|
2013-09-19 00:31:58 +02:00
|
|
|
$exception_errors,
|
|
|
|
$this->form,
|
2013-10-19 21:07:50 +02:00
|
|
|
$tabs,
|
2013-10-19 21:08:06 +02:00
|
|
|
$tab_lists,
|
2013-10-19 21:07:50 +02:00
|
|
|
$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)
|
2014-01-09 17:51:57 +01:00
|
|
|
->setID($this->id)
|
2013-08-26 20:53:11 +02:00
|
|
|
->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
|
|
|
|
2014-06-24 18:39:32 +02:00
|
|
|
$content->addClass('phui-object-box-'.$header_color);
|
|
|
|
|
2014-04-18 15:44:45 +02:00
|
|
|
foreach ($this->sigils as $sigil) {
|
|
|
|
$content->addSigil($sigil);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->metadata !== null) {
|
|
|
|
$content->setMetadata($this->metadata);
|
|
|
|
}
|
|
|
|
|
[Redesign] New PHUIObjectItemListView
Summary:
New, cleaner, ObjectItemLists. Lots of minor style tweaks, basic overview:
- Remove FootIcons
- Remove Stackable
- Remove Plain List
- Add StatusIcon
- Add setting ObjectList to an ObjectBox
- Minor retouches to Headers
Mostly, this should give us an idea of life with the new Object Lists. I'll take another application by application pass down the road. This mostly looks at implementation in Maniphest, Differential, Audit, Workboards. Checked a few other areas and dialogs while testing, and everything looks square.
Test Plan: Maniphest, Differential, Homepage, Audit, People, and other applications. Drag reorder, etc.
Reviewers: btrahan, epriestley
Reviewed By: epriestley
Subscribers: Korvin, epriestley
Differential Revision: https://secure.phabricator.com/D12865
2015-05-15 22:28:59 +02:00
|
|
|
if ($this->objectList) {
|
|
|
|
$content->appendChild($this->objectList);
|
|
|
|
}
|
|
|
|
|
2013-09-29 00:55:38 +02:00
|
|
|
return $content;
|
2013-08-26 20:53:11 +02:00
|
|
|
}
|
|
|
|
}
|