Skip to content
This repository has been archived by the owner on Jul 22, 2022. It is now read-only.

Commit

Permalink
Remove edited property from Dashboard entity
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Sep 28, 2019
1 parent eb7f5bc commit a8c7772
Show file tree
Hide file tree
Showing 12 changed files with 0 additions and 131 deletions.
8 changes: 0 additions & 8 deletions src/Admin/BlockAdmin.php
Expand Up @@ -119,10 +119,6 @@ public function preUpdate($object): void

// fix weird bug with setter object not being call
$object->setChildren($object->getChildren());

if ($object->getDashboard() instanceof DashboardInterface) {
$object->getDashboard()->setEdited(true);
}
}

public function postUpdate($object): void
Expand Down Expand Up @@ -164,10 +160,6 @@ public function prePersist($object): void
);
}

if ($object->getDashboard() instanceof DashboardInterface) {
$object->getDashboard()->setEdited(true);
}

// fix weird bug with setter object not being call
$object->setChildren($object->getChildren());
}
Expand Down
7 changes: 0 additions & 7 deletions src/Admin/DashboardAdmin.php
Expand Up @@ -55,17 +55,13 @@ public function preUpdate($object): void
if (!$object instanceof DashboardInterface) {
throw new \InvalidArgumentException('Invalid dashboard object');
}

$object->setEdited(true);
}

public function prePersist($object): void
{
if (!$object instanceof DashboardInterface) {
throw new \InvalidArgumentException('Invalid dashboard object');
}

$object->setEdited(true);
}

protected function configureShowFields(ShowMapper $showMapper): void
Expand All @@ -74,7 +70,6 @@ protected function configureShowFields(ShowMapper $showMapper): void
->add('name')
->add('default')
->add('enabled')
->add('edited')
;
}

Expand All @@ -84,15 +79,13 @@ protected function configureListFields(ListMapper $listMapper): void
->addIdentifier('name')
->add('default')
->add('enabled', null, ['editable' => true])
->add('edited', null, ['editable' => true])
;
}

protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('name')
->add('edited')
;
}

Expand Down
5 changes: 0 additions & 5 deletions src/Entity/DashboardManager.php
Expand Up @@ -52,11 +52,6 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = [])
$parameters['enabled'] = $criteria['enabled'];
}

if (isset($criteria['edited'])) {
$query->andWhere('d.edited = :edited');
$parameters['edited'] = $criteria['edited'];
}

$query->setParameters($parameters);

$pager = new Pager();
Expand Down
18 changes: 0 additions & 18 deletions src/Model/Dashboard.php
Expand Up @@ -50,11 +50,6 @@ abstract class Dashboard implements DashboardInterface
*/
protected $blocks;

/**
* @var bool|null
*/
protected $edited;

/**
* @var bool|null
*/
Expand All @@ -63,7 +58,6 @@ abstract class Dashboard implements DashboardInterface
public function __construct()
{
$this->blocks = [];
$this->edited = true;
}

public function __toString()
Expand Down Expand Up @@ -131,18 +125,6 @@ public function setEnabled(bool $enabled)
return $this;
}

public function getEdited(): bool
{
return $this->edited ?? false;
}

public function setEdited(bool $edited)
{
$this->edited = $edited;

return $this;
}

public function setDefault(bool $default)
{
$this->default = $default;
Expand Down
4 changes: 0 additions & 4 deletions src/Model/DashboardInterface.php
Expand Up @@ -48,8 +48,4 @@ public function addBlocks(DashboardBlockInterface $block);
* @return DashboardBlockInterface[]
*/
public function getBlocks();

public function getEdited(): bool;

public function setEdited(bool $edited);
}
5 changes: 0 additions & 5 deletions src/Resources/config/doctrine/BaseDashboard.orm.xml
Expand Up @@ -6,11 +6,6 @@
<option name="default">0</option>
</options>
</field>
<field name="edited" type="boolean" column="edited">
<options>
<option name="default">0</option>
</options>
</field>
<field name="default" type="boolean" column="is_default">
<options>
<option name="default">0</option>
Expand Down
12 changes: 0 additions & 12 deletions src/Resources/translations/SonataDashboardBundle.de.xliff
Expand Up @@ -74,10 +74,6 @@
<source>list.label_enabled</source>
<target>Aktiviert</target>
</trans-unit>
<trans-unit id="18" resname="list.label_edited">
<source>list.label_edited</source>
<target>bearbeitet</target>
</trans-unit>
<trans-unit id="19" resname="list.label_name">
<source>list.label_name</source>
<target>Name</target>
Expand Down Expand Up @@ -222,10 +218,6 @@
<source>filter.label_name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="55" resname="filter.label_edited">
<source>filter.label_edited</source>
<target>Bearbeitet</target>
</trans-unit>
<trans-unit id="56" resname="filter.label_type">
<source>filter.label_type</source>
<target>Typ</target>
Expand All @@ -246,10 +238,6 @@
<source>show.label_name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="61" resname="show.label_edited">
<source>show.label_edited</source>
<target>Bearbeitet</target>
</trans-unit>
<trans-unit id="62" resname="sidemenu.link_render_dashboard">
<source>sidemenu.link_render_dashboard</source>
<target>Vorschau</target>
Expand Down
12 changes: 0 additions & 12 deletions src/Resources/translations/SonataDashboardBundle.en.xliff
Expand Up @@ -70,10 +70,6 @@
<source>list.label_enabled</source>
<target>Enabled</target>
</trans-unit>
<trans-unit id="18" resname="list.label_edited">
<source>list.label_edited</source>
<target>Edited</target>
</trans-unit>
<trans-unit id="19" resname="list.label_name">
<source>list.label_name</source>
<target>Name</target>
Expand Down Expand Up @@ -218,10 +214,6 @@
<source>filter.label_name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="55" resname="filter.label_edited">
<source>filter.label_edited</source>
<target>Edited</target>
</trans-unit>
<trans-unit id="56" resname="filter.label_type">
<source>filter.label_type</source>
<target>Type</target>
Expand All @@ -242,10 +234,6 @@
<source>show.label_name</source>
<target>Name</target>
</trans-unit>
<trans-unit id="61" resname="show.label_edited">
<source>show.label_edited</source>
<target>Edited</target>
</trans-unit>
<trans-unit id="62" resname="sidemenu.link_render_dashboard">
<source>sidemenu.link_render_dashboard</source>
<target>View Dashboard</target>
Expand Down
12 changes: 0 additions & 12 deletions src/Resources/translations/SonataDashboardBundle.es.xliff
Expand Up @@ -70,10 +70,6 @@
<source>list.label_enabled</source>
<target>Habilitado</target>
</trans-unit>
<trans-unit id="18" resname="list.label_edited">
<source>list.label_edited</source>
<target>Editado</target>
</trans-unit>
<trans-unit id="19" resname="list.label_name">
<source>list.label_name</source>
<target>Nombre</target>
Expand Down Expand Up @@ -218,10 +214,6 @@
<source>filter.label_name</source>
<target>Nombre</target>
</trans-unit>
<trans-unit id="55" resname="filter.label_edited">
<source>filter.label_edited</source>
<target>Editado</target>
</trans-unit>
<trans-unit id="56" resname="filter.label_type">
<source>filter.label_type</source>
<target>Tipo</target>
Expand All @@ -242,10 +234,6 @@
<source>show.label_name</source>
<target>Nombre</target>
</trans-unit>
<trans-unit id="61" resname="show.label_edited">
<source>show.label_edited</source>
<target>Editado</target>
</trans-unit>
<trans-unit id="62" resname="sidemenu.link_render_dashboard">
<source>sidemenu.link_render_dashboard</source>
<target>Ver panel</target>
Expand Down
12 changes: 0 additions & 12 deletions src/Resources/translations/SonataDashboardBundle.fr.xliff
Expand Up @@ -70,10 +70,6 @@
<source>list.label_enabled</source>
<target>Activé</target>
</trans-unit>
<trans-unit id="18" resname="list.label_edited">
<source>list.label_edited</source>
<target>Edité</target>
</trans-unit>
<trans-unit id="19" resname="list.label_name">
<source>list.label_name</source>
<target>Nom</target>
Expand Down Expand Up @@ -218,10 +214,6 @@
<source>filter.label_name</source>
<target>Nom</target>
</trans-unit>
<trans-unit id="55" resname="filter.label_edited">
<source>filter.label_edited</source>
<target>Edité</target>
</trans-unit>
<trans-unit id="56" resname="filter.label_type">
<source>filter.label_type</source>
<target>Type</target>
Expand All @@ -242,10 +234,6 @@
<source>show.label_name</source>
<target>Nom</target>
</trans-unit>
<trans-unit id="61" resname="show.label_edited">
<source>show.label_edited</source>
<target>Edité</target>
</trans-unit>
<trans-unit id="62" resname="sidemenu.link_render_dashboard">
<source>sidemenu.link_render_dashboard</source>
<target>Aperçu</target>
Expand Down
12 changes: 0 additions & 12 deletions src/Resources/translations/SonataDashboardBundle.ru.xliff
Expand Up @@ -74,10 +74,6 @@
<source>list.label_enabled</source>
<target>Включена</target>
</trans-unit>
<trans-unit id="18" resname="list.label_edited">
<source>list.label_edited</source>
<target>Edited</target>
</trans-unit>
<trans-unit id="19" resname="list.label_name">
<source>list.label_name</source>
<target>Имя</target>
Expand Down Expand Up @@ -222,10 +218,6 @@
<source>filter.label_name</source>
<target>Имя</target>
</trans-unit>
<trans-unit id="55" resname="filter.label_edited">
<source>filter.label_edited</source>
<target>Отредактирован</target>
</trans-unit>
<trans-unit id="56" resname="filter.label_type">
<source>filter.label_type</source>
<target>Тип</target>
Expand All @@ -246,10 +238,6 @@
<source>show.label_name</source>
<target>Имя</target>
</trans-unit>
<trans-unit id="61" resname="show.label_edited">
<source>show.label_edited</source>
<target>Отредактирован</target>
</trans-unit>
</body>
</file>
</xliff>
24 changes: 0 additions & 24 deletions tests/Entity/DashboardManagerTest.php
Expand Up @@ -104,30 +104,6 @@ public function testGetPagerWithDisabledPages(): void
->getPager(['enabled' => false], 1);
}

public function testGetPagerWithEditedPages(): void
{
$self = $this;
$this
->getDashboardManager(function ($qb) use ($self): void {
$qb->expects($self->once())->method('andWhere')->with($self->equalTo('d.edited = :edited'));
$qb->expects($self->once())->method('setParameters')->with($self->equalTo(['edited' => true]));
$qb->expects($this->any())->method('getRootAliases')->willReturn([]);
})
->getPager(['edited' => true], 1);
}

public function testGetPagerWithNonEditedPages(): void
{
$self = $this;
$this
->getDashboardManager(function ($qb) use ($self): void {
$qb->expects($self->once())->method('andWhere')->with($self->equalTo('d.edited = :edited'));
$qb->expects($self->once())->method('setParameters')->with($self->equalTo(['edited' => false]));
$qb->expects($this->any())->method('getRootAliases')->willReturn([]);
})
->getPager(['edited' => false], 1);
}

private function getDashboardManager($qbCallback)
{
$query = $this->getMockForAbstractClass(AbstractQuery::class, [], '', false, true, true, ['execute']);
Expand Down

0 comments on commit a8c7772

Please sign in to comment.