Skip to content

Commit

Permalink
UI/Table: move Column::withIsInitiallyVisible to ::withIsOptional (#3…
Browse files Browse the repository at this point in the history
…8070)
  • Loading branch information
klees committed Oct 26, 2023
1 parent e49f115 commit c9763cd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/UI/Component/Table/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public function getTitle(): string;
public function getType(): string;
public function withIsSortable(bool $flag): self;
public function isSortable(): bool;
public function withIsOptional(bool $flag): self;
public function withIsOptional(bool $is_optional, bool $is_initially_visible = true): self;
public function isOptional(): bool;
public function withIsInitiallyVisible(bool $flag): self;
public function isInitiallyVisible(): bool;
}
12 changes: 3 additions & 9 deletions src/UI/Implementation/Component/Table/Column/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public function isSortable(): bool
return $this->sortable;
}

public function withIsOptional(bool $flag): self
public function withIsOptional(bool $is_optional, bool $is_initially_visible = true): self
{
$clone = clone $this;
$clone->optional = $flag;
$clone->optional = $is_optional;
$clone->initially_visible = $is_initially_visible;
return $clone;
}

Expand All @@ -73,13 +74,6 @@ public function isOptional(): bool
return $this->optional;
}

public function withIsInitiallyVisible(bool $flag): self
{
$clone = clone $this;
$clone->initially_visible = $flag;
return $clone;
}

public function isInitiallyVisible(): bool
{
return $this->initially_visible;
Expand Down
3 changes: 1 addition & 2 deletions src/UI/examples/Table/Data/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ function base()
->withUnit('£', I\Column\Number::UNIT_POSITION_FORE),
'failure_txt' => $f->table()->column()->status("failure")
->withIsSortable(false)
->withIsOptional(true)
->withIsInitiallyVisible(false),
->withIsOptional(true, false),
];

/**
Expand Down
3 changes: 1 addition & 2 deletions src/UI/examples/Table/Data/repo_implementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ protected function getColumsForRepresentation(): array
->withUnit('£', I\Column\Number::UNIT_POSITION_FORE),
'failure_txt' => $f->table()->column()->status("failure")
->withIsSortable(false)
->withIsOptional(true)
->withIsInitiallyVisible(false),
->withIsOptional(true, false),
'sql_order' => $f->table()->column()->text("sql order part")
->withIsSortable(false)
->withIsOptional(true),
Expand Down
4 changes: 2 additions & 2 deletions tests/UI/Component/Table/Column/ColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function testDataTableColumnsAttributes(): void
$this->assertFalse($col->withIsOptional(false)->isOptional());

$this->assertTrue($col->isInitiallyVisible());
$this->assertFalse($col->withIsInitiallyVisible(false)->isInitiallyVisible());
$this->assertTrue($col->withIsInitiallyVisible(true)->isInitiallyVisible());
$this->assertFalse($col->withIsOptional(true, false)->isInitiallyVisible());
$this->assertTrue($col->withIsOptional(true, true)->isInitiallyVisible());

$this->assertFalse($col->isHighlighted());
$this->assertTrue($col->withHighlight(true)->isHighlighted());
Expand Down
15 changes: 7 additions & 8 deletions tests/UI/Component/Table/DataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public function getRows(
): \Generator {
yield $row_builder->buildStandardRow('', []);
}
public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
): ?int {
return null;
}
public function getTotalRowCount(
?array $filter_data,
?array $additional_parameters
): ?int {
return null;
}
};
}

Expand Down Expand Up @@ -187,8 +187,7 @@ public function testDataTableWithSelectedOptionalCols(): void
$cols = [
'f0' => $this->getTableFactory()->column()->text(''),
'f1' => $this->getTableFactory()->column()->text('')
->withIsOptional(true)
->withIsInitiallyVisible(false),
->withIsOptional(true, false),
'f2' => $this->getTableFactory()->column()->text('')
];
$table = $this->getTableFactory()->data('title', $cols, $data);
Expand Down

0 comments on commit c9763cd

Please sign in to comment.