mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-04 20:52:43 +01:00
7f13e8a5c5
Summary: Fixes T4914. We currently have a finite limit on column displays which caused T4914. This fixes T4914 by no longer using a fluid layout. Rather, we use a fixed column width layout which does not have a 7 column limit. Future work - see T4054 for an example - will likely make the fluid layout thing work with infinite columns, and / or other work may re-jigger project workboards directly. Test Plan: had a project like in T4914 that wouldn't load and it loaded post this change! added more columns and using javascript inspector noted proper width being set Reviewers: epriestley, chad Reviewed By: epriestley Subscribers: joshuaspence, epriestley, Korvin Maniphest Tasks: T4054, T4914 Differential Revision: https://secure.phabricator.com/D8942
127 lines
3 KiB
PHP
127 lines
3 KiB
PHP
<?php
|
|
|
|
final class AphrontMultiColumnView extends AphrontView {
|
|
|
|
const GUTTER_SMALL = 'msr';
|
|
const GUTTER_MEDIUM = 'mmr';
|
|
const GUTTER_LARGE = 'mlr';
|
|
|
|
private $columns = array();
|
|
private $fluidLayout = false;
|
|
private $fluidishLayout = false;
|
|
private $gutter;
|
|
private $border;
|
|
|
|
public function addColumn($column) {
|
|
$this->columns[] = $column;
|
|
return $this;
|
|
}
|
|
|
|
public function setFluidlayout($layout) {
|
|
$this->fluidLayout = $layout;
|
|
return $this;
|
|
}
|
|
|
|
public function setFluidishLayout($layout) {
|
|
$this->fluidLayout = true;
|
|
$this->fluidishLayout = $layout;
|
|
return $this;
|
|
}
|
|
|
|
public function setGutter($gutter) {
|
|
$this->gutter = $gutter;
|
|
return $this;
|
|
}
|
|
|
|
public function setBorder($border) {
|
|
$this->border = $border;
|
|
return $this;
|
|
}
|
|
|
|
public function render() {
|
|
require_celerity_resource('aphront-multi-column-view-css');
|
|
|
|
$classes = array();
|
|
$classes[] = 'aphront-multi-column-inner';
|
|
$classes[] = 'grouped';
|
|
|
|
if ($this->fluidishLayout || $this->fluidLayout) {
|
|
// we only support seven columns for now for fluid views; see T4054
|
|
if (count($this->columns) > 7) {
|
|
throw new Exception("No more than 7 columns per view.");
|
|
}
|
|
}
|
|
|
|
$classes[] = 'aphront-multi-column-'.count($this->columns).'-up';
|
|
|
|
$columns = array();
|
|
$column_class = array();
|
|
$column_class[] = 'aphront-multi-column-column';
|
|
$outer_class = array();
|
|
$outer_class[] = 'aphront-multi-column-column-outer';
|
|
if ($this->gutter) {
|
|
$column_class[] = $this->gutter;
|
|
}
|
|
$i = 0;
|
|
foreach ($this->columns as $column) {
|
|
if (++$i === count($this->columns)) {
|
|
$column_class[] = 'aphront-multi-column-column-last';
|
|
$outer_class[] = 'aphront-multi-colum-column-outer-last';
|
|
}
|
|
$column_inner = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $column_class)
|
|
),
|
|
$column);
|
|
$columns[] = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $outer_class)
|
|
),
|
|
$column_inner);
|
|
}
|
|
|
|
$view = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $classes),
|
|
),
|
|
array(
|
|
$columns,
|
|
));
|
|
|
|
$classes = array();
|
|
$classes[] = 'aphront-multi-column-outer';
|
|
if ($this->fluidLayout) {
|
|
$classes[] = 'aphront-multi-column-fluid';
|
|
if ($this->fluidishLayout) {
|
|
$classes[] = 'aphront-multi-column-fluidish';
|
|
}
|
|
} else {
|
|
$classes[] = 'aphront-multi-column-fixed';
|
|
}
|
|
|
|
$board = phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $classes)
|
|
),
|
|
$view);
|
|
|
|
if ($this->border) {
|
|
$board = id(new PHUIBoxView())
|
|
->setBorder(true)
|
|
->appendChild($board)
|
|
->addPadding(PHUI::PADDING_MEDIUM_TOP)
|
|
->addPadding(PHUI::PADDING_MEDIUM_BOTTOM);
|
|
}
|
|
|
|
return phutil_tag(
|
|
'div',
|
|
array(
|
|
'class' => 'aphront-multi-column-view'
|
|
),
|
|
$board);
|
|
}
|
|
}
|