diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php index f473b3f6cd..c1088cbdd3 100644 --- a/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php +++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php @@ -1,75 +1,71 @@ getArr($this->getFieldKey().'_name'); - $panels = $request->getArr($this->getFieldKey().'_panelID'); + $panel_ids = $request->getArr($this->getFieldKey().'_panelID'); + $panels = array(); + foreach ($panel_ids as $panel_id) { + $panels[] = $panel_id[0]; + } foreach ($names as $idx => $name) { $panel_id = idx($panels, $idx); if (strlen($name) && $panel_id) { $value[] = array( 'name' => $name, 'panelID' => $panel_id, ); } } $this->setFieldValue($value); } public function renderEditControl(array $handles) { // NOTE: This includes archived panels so we don't mutate the tabs // when saving a tab panel that includes archied panels. This whole UI is // hopefully temporary anyway. - $panels = id(new PhabricatorDashboardPanelQuery()) - ->setViewer($this->getViewer()) - ->execute(); - - $panel_map = array(); - foreach ($panels as $panel) { - $panel_map[$panel->getID()] = pht( - '%s %s', - $panel->getMonogram(), - $panel->getName()); - } - $panel_map = array( - '' => pht('(None)'), - ) + $panel_map; - $value = $this->getFieldValue(); if (!is_array($value)) { $value = array(); } $out = array(); for ($ii = 1; $ii <= 6; $ii++) { $tab = idx($value, ($ii - 1), array()); + $panel = idx($tab, 'panelID', null); + $panel_id = array(); + if ($panel) { + $panel_id[] = $panel; + } $out[] = id(new AphrontFormTextControl()) ->setName($this->getFieldKey().'_name[]') ->setValue(idx($tab, 'name')) ->setLabel(pht('Tab %d Name', $ii)); - $out[] = id(new AphrontFormSelectControl()) + $out[] = id(new AphrontFormTokenizerControl()) + ->setUser($this->getViewer()) + ->setDatasource(new PhabricatorDashboardPanelDatasource()) ->setName($this->getFieldKey().'_panelID[]') - ->setValue(idx($tab, 'panelID')) - ->setOptions($panel_map) + ->setValue($panel_id) + ->setLimit(1) ->setLabel(pht('Tab %d Panel', $ii)); } return $out; } }