Skip to content

Commit d3de577

Browse files
author
epriestley
committed
Add a "Header" standard custom field
Summary: Ref T418. This is the last of the Maniphest field types, although I have a few more capabilities/options to port over. Test Plan: See screenshots. Reviewers: btrahan Reviewed By: btrahan CC: chad, aran Maniphest Tasks: T418 Differential Revision: https://secure.phabricator.com/D7018
1 parent 52e65f3 commit d3de577

File tree

5 files changed

+115
-44
lines changed

5 files changed

+115
-44
lines changed

src/__celerity_resource_map__.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3765,7 +3765,7 @@
37653765
),
37663766
'phui-form-view-css' =>
37673767
array(
3768-
'uri' => '/res/ddb55dac/rsrc/css/phui/phui-form-view.css',
3768+
'uri' => '/res/5786628c/rsrc/css/phui/phui-form-view.css',
37693769
'type' => 'css',
37703770
'requires' =>
37713771
array(
@@ -4171,7 +4171,7 @@
41714171
), array(
41724172
'packages' =>
41734173
array(
4174-
'2c60f04c' =>
4174+
'a9a10c76' =>
41754175
array(
41764176
'name' => 'core.pkg.css',
41774177
'symbols' =>
@@ -4218,7 +4218,7 @@
42184218
39 => 'phabricator-property-list-view-css',
42194219
40 => 'phabricator-tag-view-css',
42204220
),
4221-
'uri' => '/res/pkg/2c60f04c/core.pkg.css',
4221+
'uri' => '/res/pkg/a9a10c76/core.pkg.css',
42224222
'type' => 'css',
42234223
),
42244224
'8977e356' =>
@@ -4409,15 +4409,15 @@
44094409
),
44104410
'reverse' =>
44114411
array(
4412-
'aphront-dialog-view-css' => '2c60f04c',
4413-
'aphront-error-view-css' => '2c60f04c',
4414-
'aphront-list-filter-view-css' => '2c60f04c',
4415-
'aphront-pager-view-css' => '2c60f04c',
4416-
'aphront-panel-view-css' => '2c60f04c',
4417-
'aphront-table-view-css' => '2c60f04c',
4418-
'aphront-tokenizer-control-css' => '2c60f04c',
4419-
'aphront-tooltip-css' => '2c60f04c',
4420-
'aphront-typeahead-control-css' => '2c60f04c',
4412+
'aphront-dialog-view-css' => 'a9a10c76',
4413+
'aphront-error-view-css' => 'a9a10c76',
4414+
'aphront-list-filter-view-css' => 'a9a10c76',
4415+
'aphront-pager-view-css' => 'a9a10c76',
4416+
'aphront-panel-view-css' => 'a9a10c76',
4417+
'aphront-table-view-css' => 'a9a10c76',
4418+
'aphront-tokenizer-control-css' => 'a9a10c76',
4419+
'aphront-tooltip-css' => 'a9a10c76',
4420+
'aphront-typeahead-control-css' => 'a9a10c76',
44214421
'differential-changeset-view-css' => '44bfe40c',
44224422
'differential-core-view-css' => '44bfe40c',
44234423
'differential-inline-comment-editor' => '5e9e5c4e',
@@ -4431,7 +4431,7 @@
44314431
'differential-table-of-contents-css' => '44bfe40c',
44324432
'diffusion-commit-view-css' => 'c8ce2d88',
44334433
'diffusion-icons-css' => 'c8ce2d88',
4434-
'global-drag-and-drop-css' => '2c60f04c',
4434+
'global-drag-and-drop-css' => 'a9a10c76',
44354435
'inline-comment-summary-css' => '44bfe40c',
44364436
'javelin-aphlict' => '8977e356',
44374437
'javelin-behavior' => 'f32597c9',
@@ -4504,55 +4504,55 @@
45044504
'javelin-util' => 'f32597c9',
45054505
'javelin-vector' => 'f32597c9',
45064506
'javelin-workflow' => 'f32597c9',
4507-
'lightbox-attachment-css' => '2c60f04c',
4507+
'lightbox-attachment-css' => 'a9a10c76',
45084508
'maniphest-task-summary-css' => '36d5d071',
45094509
'maniphest-transaction-detail-css' => '36d5d071',
4510-
'phabricator-action-list-view-css' => '2c60f04c',
4511-
'phabricator-application-launch-view-css' => '2c60f04c',
4510+
'phabricator-action-list-view-css' => 'a9a10c76',
4511+
'phabricator-application-launch-view-css' => 'a9a10c76',
45124512
'phabricator-busy' => '8977e356',
45134513
'phabricator-content-source-view-css' => '44bfe40c',
4514-
'phabricator-core-css' => '2c60f04c',
4515-
'phabricator-crumbs-view-css' => '2c60f04c',
4514+
'phabricator-core-css' => 'a9a10c76',
4515+
'phabricator-crumbs-view-css' => 'a9a10c76',
45164516
'phabricator-drag-and-drop-file-upload' => '5e9e5c4e',
45174517
'phabricator-dropdown-menu' => '8977e356',
45184518
'phabricator-file-upload' => '8977e356',
4519-
'phabricator-filetree-view-css' => '2c60f04c',
4520-
'phabricator-flag-css' => '2c60f04c',
4519+
'phabricator-filetree-view-css' => 'a9a10c76',
4520+
'phabricator-flag-css' => 'a9a10c76',
45214521
'phabricator-hovercard' => '8977e356',
4522-
'phabricator-jump-nav' => '2c60f04c',
4522+
'phabricator-jump-nav' => 'a9a10c76',
45234523
'phabricator-keyboard-shortcut' => '8977e356',
45244524
'phabricator-keyboard-shortcut-manager' => '8977e356',
4525-
'phabricator-main-menu-view' => '2c60f04c',
4525+
'phabricator-main-menu-view' => 'a9a10c76',
45264526
'phabricator-menu-item' => '8977e356',
4527-
'phabricator-nav-view-css' => '2c60f04c',
4527+
'phabricator-nav-view-css' => 'a9a10c76',
45284528
'phabricator-notification' => '8977e356',
4529-
'phabricator-notification-css' => '2c60f04c',
4530-
'phabricator-notification-menu-css' => '2c60f04c',
4529+
'phabricator-notification-css' => 'a9a10c76',
4530+
'phabricator-notification-menu-css' => 'a9a10c76',
45314531
'phabricator-object-selector-css' => '44bfe40c',
45324532
'phabricator-phtize' => '8977e356',
45334533
'phabricator-prefab' => '8977e356',
45344534
'phabricator-project-tag-css' => '36d5d071',
4535-
'phabricator-property-list-view-css' => '2c60f04c',
4536-
'phabricator-remarkup-css' => '2c60f04c',
4535+
'phabricator-property-list-view-css' => 'a9a10c76',
4536+
'phabricator-remarkup-css' => 'a9a10c76',
45374537
'phabricator-shaped-request' => '5e9e5c4e',
4538-
'phabricator-side-menu-view-css' => '2c60f04c',
4539-
'phabricator-standard-page-view' => '2c60f04c',
4540-
'phabricator-tag-view-css' => '2c60f04c',
4538+
'phabricator-side-menu-view-css' => 'a9a10c76',
4539+
'phabricator-standard-page-view' => 'a9a10c76',
4540+
'phabricator-tag-view-css' => 'a9a10c76',
45414541
'phabricator-textareautils' => '8977e356',
45424542
'phabricator-tooltip' => '8977e356',
4543-
'phabricator-transaction-view-css' => '2c60f04c',
4544-
'phabricator-zindex-css' => '2c60f04c',
4545-
'phui-button-css' => '2c60f04c',
4546-
'phui-form-css' => '2c60f04c',
4547-
'phui-form-view-css' => '2c60f04c',
4548-
'phui-header-view-css' => '2c60f04c',
4549-
'phui-icon-view-css' => '2c60f04c',
4550-
'phui-object-item-list-view-css' => '2c60f04c',
4551-
'phui-spacing-css' => '2c60f04c',
4552-
'sprite-apps-large-css' => '2c60f04c',
4553-
'sprite-gradient-css' => '2c60f04c',
4554-
'sprite-icons-css' => '2c60f04c',
4555-
'sprite-menu-css' => '2c60f04c',
4556-
'syntax-highlighting-css' => '2c60f04c',
4543+
'phabricator-transaction-view-css' => 'a9a10c76',
4544+
'phabricator-zindex-css' => 'a9a10c76',
4545+
'phui-button-css' => 'a9a10c76',
4546+
'phui-form-css' => 'a9a10c76',
4547+
'phui-form-view-css' => 'a9a10c76',
4548+
'phui-header-view-css' => 'a9a10c76',
4549+
'phui-icon-view-css' => 'a9a10c76',
4550+
'phui-object-item-list-view-css' => 'a9a10c76',
4551+
'phui-spacing-css' => 'a9a10c76',
4552+
'sprite-apps-large-css' => 'a9a10c76',
4553+
'sprite-gradient-css' => 'a9a10c76',
4554+
'sprite-icons-css' => 'a9a10c76',
4555+
'sprite-menu-css' => 'a9a10c76',
4556+
'syntax-highlighting-css' => 'a9a10c76',
45574557
),
45584558
));

src/__phutil_library_map__.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,6 +1639,7 @@
16391639
'PhabricatorStandardCustomField' => 'infrastructure/customfield/standard/PhabricatorStandardCustomField.php',
16401640
'PhabricatorStandardCustomFieldBool' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php',
16411641
'PhabricatorStandardCustomFieldDate' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php',
1642+
'PhabricatorStandardCustomFieldHeader' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldHeader.php',
16421643
'PhabricatorStandardCustomFieldInt' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php',
16431644
'PhabricatorStandardCustomFieldInterface' => 'infrastructure/customfield/interface/PhabricatorStandardCustomFieldInterface.php',
16441645
'PhabricatorStandardCustomFieldPHIDs' => 'infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php',
@@ -3795,6 +3796,7 @@
37953796
'PhabricatorStandardCustomField' => 'PhabricatorCustomField',
37963797
'PhabricatorStandardCustomFieldBool' => 'PhabricatorStandardCustomField',
37973798
'PhabricatorStandardCustomFieldDate' => 'PhabricatorStandardCustomField',
3799+
'PhabricatorStandardCustomFieldHeader' => 'PhabricatorStandardCustomField',
37983800
'PhabricatorStandardCustomFieldInt' => 'PhabricatorStandardCustomField',
37993801
'PhabricatorStandardCustomFieldPHIDs' => 'PhabricatorStandardCustomField',
38003802
'PhabricatorStandardCustomFieldRemarkup' => 'PhabricatorStandardCustomField',

src/infrastructure/customfield/field/PhabricatorCustomFieldList.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ public function appendFieldsToPropertyList(
100100
$style = $field->getStyleForPropertyView();
101101
switch ($style) {
102102
case 'property':
103+
case 'header':
103104
$head[$key] = $field;
104105
break;
105106
case 'block':
@@ -113,12 +114,39 @@ public function appendFieldsToPropertyList(
113114
}
114115
$fields = $head + $tail;
115116

117+
$add_header = null;
118+
116119
foreach ($fields as $field) {
117120
$label = $field->renderPropertyViewLabel();
118121
$value = $field->renderPropertyViewValue();
119122
if ($value !== null) {
120123
switch ($field->getStyleForPropertyView()) {
124+
case 'header':
125+
// We want to hide headers if the fields the're assciated with
126+
// don't actually produce any visible properties. For example, in a
127+
// list like this:
128+
//
129+
// Header A
130+
// Prop A: Value A
131+
// Header B
132+
// Prop B: Value B
133+
//
134+
// ...if the "Prop A" field returns `null` when rendering its
135+
// property value and we rendered naively, we'd get this:
136+
//
137+
// Header A
138+
// Header B
139+
// Prop B: Value B
140+
//
141+
// This is silly. Instead, we hide "Header A".
142+
$add_header = $value;
143+
break;
121144
case 'property':
145+
if ($add_header !== null) {
146+
// Add the most recently seen header.
147+
$view->addSectionHeader($add_header);
148+
$add_header = null;
149+
}
122150
$view->addProperty($label, $value);
123151
break;
124152
case 'block':
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
final class PhabricatorStandardCustomFieldHeader
4+
extends PhabricatorStandardCustomField {
5+
6+
public function getFieldType() {
7+
return 'header';
8+
}
9+
10+
public function renderEditControl() {
11+
$header = phutil_tag(
12+
'div',
13+
array(
14+
'class' => 'phabricator-standard-custom-field-header',
15+
),
16+
$this->getFieldName());
17+
return id(new AphrontFormStaticControl())
18+
->setValue($header);
19+
}
20+
21+
public function shouldUseStorage() {
22+
return false;
23+
}
24+
25+
public function getStyleForPropertyView() {
26+
return 'header';
27+
}
28+
29+
public function renderPropertyViewValue() {
30+
return $this->getFieldName();
31+
}
32+
33+
}

webroot/rsrc/css/phui/phui-form-view.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,11 @@ table.aphront-form-control-checkbox-layout th {
439439
.phui-form-box .aphront-error-view {
440440
margin-bottom: 0;
441441
}
442+
443+
.phabricator-standard-custom-field-header {
444+
font-size: 16px;
445+
color: {$bluetext};
446+
border-bottom: 1px solid {$lightbluetext};
447+
padding: 16px 0 4px;
448+
margin-bottom: 4px;
449+
}

0 commit comments

Comments
 (0)