Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add (missing) areabrick overview in admin backend #19

Merged
merged 56 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c267734
feature: add ArebrickOverviewController in Bundle
mike4git Aug 7, 2024
165ee3e
refactor: append bundle prefix
mike4git Aug 10, 2024
0cf1757
fix: remove proprietary brick attributes and allow customized columns…
mike4git Aug 10, 2024
eb662d9
Update config/services.yaml
mike4git Aug 16, 2024
6f8f3ac
Update config/services.yaml
mike4git Aug 16, 2024
223b7b0
feature: add ArebrickOverviewController in Bundle
mike4git Aug 7, 2024
943c8fa
refactor: append bundle prefix
mike4git Aug 10, 2024
ee52b43
refactor: better types for Brick properties and introduced by the way…
mike4git Aug 16, 2024
8823459
fix: JDs review
mike4git Aug 16, 2024
e73a227
Update src/Bricks/Populator/BrickPagePopulator.php
mike4git Aug 19, 2024
b92789a
Update src/Controller/Admin/AreabrickOverviewController.php
mike4git Aug 19, 2024
6f472d4
Update src/DependencyInjection/NeustaPimcoreAreabrickConfigExtension.php
mike4git Aug 19, 2024
7db93c4
feat: areabricks overview updated
mike4git Aug 21, 2024
eed5da0
feat: add menu for overview
mike4git Sep 24, 2024
bbd4fec
feat: add Resources and PimcoreAdminListener for offering js and css …
mike4git Sep 24, 2024
24588c6
fix: move assets to correct folder for install process
mike4git Sep 25, 2024
4be3054
feat: add menu item to Pimcore Tools menu and open Areabrick Overview…
mike4git Sep 25, 2024
413753b
feat: add panel inside Pimcore tab for Areabricks table; set table wi…
mike4git Sep 25, 2024
1bde277
[Areabrick Overview] translated labels
mike4git Sep 26, 2024
af1cac4
[Areabrick Overview] translated labels
mike4git Sep 26, 2024
919fbbf
fix: JDs review notes
mike4git Sep 28, 2024
cd0a48a
fix: phpstan
mike4git Sep 28, 2024
1871e43
fix: visibility of additional properties will be managed by Areabrick…
mike4git Sep 29, 2024
a8c011e
Pimcore 10 compatibility
jdreesen Sep 30, 2024
ae98570
Add admin translations (menu item & tab title)
jdreesen Sep 30, 2024
feba123
Allow some Brick fields to be empty
jdreesen Sep 30, 2024
4a47176
Some random cleanup
jdreesen Sep 30, 2024
dec0a37
Some random cleanup
jdreesen Sep 30, 2024
4072bb8
Some random cleanup & fixes from review
jdreesen Sep 30, 2024
1ac9f72
Some random cleanup & fixes from review
jdreesen Sep 30, 2024
7a81291
Refactor template
jdreesen Sep 30, 2024
ce781d4
Rename assets
jdreesen Sep 30, 2024
c99b72c
Refactor controller
jdreesen Sep 30, 2024
e77a444
Fix converter bundle prefix
jdreesen Sep 30, 2024
5fb441a
Fix test namespace
jdreesen Sep 30, 2024
a22aca1
Fix format placeholder type
jdreesen Sep 30, 2024
d6ea1ae
Fix translations
jdreesen Sep 30, 2024
b683968
Finalize the models
jdreesen Sep 30, 2024
c8b7fbe
Refactor/cleanup Models
jdreesen Sep 30, 2024
3ff1898
Add all direct dependencies to the composer.json
jdreesen Sep 30, 2024
b0b51ee
Raise minimum Pimcore version to 10.6
jdreesen Sep 30, 2024
9761a26
Use array_any() from PHP 8.4
jdreesen Sep 30, 2024
507a53f
Fix CS
jdreesen Sep 30, 2024
d6d6396
Fix PHPStan
jdreesen Sep 30, 2024
a6efa09
Better way to open documents in editmode
jdreesen Sep 30, 2024
443f3f0
fix: add migration script for permission definition
mike4git Oct 1, 2024
398a471
Fix additional properties in template
jdreesen Oct 1, 2024
d4549b0
Add permission
jdreesen Oct 1, 2024
2e69d72
[Areabrick Overview] sorting the bricks
nsd0sketzler Oct 2, 2024
dd58d53
[Areabrick Overview] adding areabrick-overview-unpublished-toggle.js
nsd0sketzler Oct 2, 2024
f6233b5
[Areabrick Overview] function for the accordion
nsd0sketzler Oct 2, 2024
9429cb9
[Areabrick Overview] refactoring table view
nsd0sketzler Oct 2, 2024
68ad4df
[Areabrick Overview] new style
nsd0sketzler Oct 2, 2024
41b3161
[Areabrick Overview] removed description
nsd0sketzler Oct 2, 2024
805314c
Some fixes & cleanup
jdreesen Oct 2, 2024
2615697
Some more refactoring
jdreesen Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
},
"require": {
"php": "~8.1.0 || ~8.2.0",
"pimcore/pimcore": "^10.5 || ^11.0"
"doctrine/dbal": "^2.13 || ^3.9",
"pimcore/pimcore": "^10.6 || ^11.0",
"symfony/config": "^5.4 || ^6.4",
"symfony/dependency-injection": "^5.4 || ^6.4",
"symfony/http-foundation": "^5.4 || ^6.4",
"symfony/http-kernel": "^5.4 || ^6.4",
"symfony/polyfill-php84": "^1.31",
"symfony/routing": "^5.4 || ^6.4",
"symfony/translation": "^5.4 || ^6.4",
"teamneusta/converter-bundle": "^1.6",
"twig/twig": "^3.8"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.62",
Expand Down
24 changes: 24 additions & 0 deletions config/pimcore/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
doctrine_migrations:
migrations_paths:
Neusta\Pimcore\AreabrickConfigBundle\Migrations: '@NeustaPimcoreAreabrickConfigBundle/migrations'

neusta_converter:
converter:
neusta_pimcore_areabrick_config.brick.converter:
target: Neusta\Pimcore\AreabrickConfigBundle\Bricks\Model\Brick
populators:
- Neusta\Pimcore\AreabrickConfigBundle\Bricks\Populator\BrickPagePopulator
properties:
id: ~
name: ~
version: ~
description: ~
template: ~

neusta_pimcore_areabrick_config.page.converter:
target: Neusta\Pimcore\AreabrickConfigBundle\Bricks\Model\Page
properties:
id: ~
type: ~
url: fullPath
published: ~
7 changes: 7 additions & 0 deletions config/pimcore/routing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
neusta_pimcore_areabrick_config:
resource: '@NeustaPimcoreAreabrickConfigBundle/src/Controller/Admin/'
type: annotation
name_prefix: neusta_areabrick_config_
prefix: /admin/bundle/neusta-areabrick-config
options:
expose: true
20 changes: 20 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
services:
_defaults:
autowire: true
autoconfigure: true

Neusta\Pimcore\AreabrickConfigBundle\Controller\Admin\AreabrickOverviewController:
arguments:
$brickConverter: '@neusta_pimcore_areabrick_config.brick.converter'
tags: [ 'controller.service_arguments' ]

Neusta\Pimcore\AreabrickConfigBundle\Bricks\Populator\BrickPageEditModeUrlPopulator: ~

Neusta\Pimcore\AreabrickConfigBundle\Bricks\Populator\BrickPagePopulator:
arguments:
$pageConverter: '@neusta_pimcore_areabrick_config.page.converter'

Neusta\Pimcore\AreabrickConfigBundle\EventListener\PimcoreAdminListener:
tags:
- { name: kernel.event_listener, event: pimcore.bundle_manager.paths.css, method: addCSSFiles }
- { name: kernel.event_listener, event: pimcore.bundle_manager.paths.js, method: addJSFiles }
27 changes: 27 additions & 0 deletions migrations/Version20241001090000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);

namespace Neusta\Pimcore\AreabrickConfigBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Pimcore\Migrations\BundleAwareMigration;

final class Version20241001090000 extends BundleAwareMigration
{
private const PERMISSION_KEY_AREABRICKS = 'neusta_areabrick_config.areabrick_overview';

public function up(Schema $schema): void
{
$this->addSql("INSERT IGNORE INTO users_permission_definitions (`key`, `category`) VALUES('" . self::PERMISSION_KEY_AREABRICKS . "', 'Neusta Areabrick Config Bundle');");
}

public function down(Schema $schema): void
{
$this->addSql("DELETE FROM users_permission_definitions WHERE `key` = '" . self::PERMISSION_KEY_AREABRICKS . "';");
}

protected function getBundleName(): string
{
return 'NeustaPimcoreAreabrickConfigBundle';
}
}
108 changes: 108 additions & 0 deletions public/css/admin-style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#neusta_areabrick_config table {
background-color: #ffffff;
border-collapse: collapse;
border: none;
width: 100%;
}

#neusta_areabrick_config thead {
background-color: #177fac;
position: sticky;
top: 0;
z-index: 10;
color: #ffffff;
}

#neusta_areabrick_config tfoot {
background-color: #F7F1D4;
font-size: 80%;
border-top: 1px solid #999;
}

#neusta_areabrick_config td,
#neusta_areabrick_config th {
text-align: match-parent;
padding: 0.5em 1em;
width: auto;
}

#neusta_areabrick_config tbody {
display: block;
height: 100%;
overflow-y: auto;
}

#neusta_areabrick_config thead,
#neusta_areabrick_config tbody tr {
display: table;
width: 100%;
table-layout: fixed; /* Prevents columns of different widths */
}

#neusta_areabrick_config tbody tr:nth-child(odd) {
background-color: #ffffff;
}

#neusta_areabrick_config tbody tr:nth-child(even) {
background-color: #d9d9d9;
}

#neusta_areabrick_config a {
color: #0096f3;
text-decoration: none;
}

#neusta_areabrick_config a:hover {
text-decoration: underline;
cursor: pointer;
}

/* Additional Properties */
#neusta_areabrick_config ul.additional-properties li {
list-style-type: none;
margin-left: 5px;
width: 150px;
padding: 2px 4px;
border-radius: 3px;
display: inline-block;
color: #ffffff;
}

#neusta_areabrick_config ul.additional-properties li.tag {
background-color: #2a6f9c;
}

#neusta_areabrick_config ul.additional-properties li.group {
background-color: #194567;
}

/* Accordion */
#neusta_areabrick_config .accordion button {
background-color: #efefef;
color: #444;
cursor: pointer;
padding: 10px;
width: 100%;
text-align: left;
border: none;
outline: none;
transition: 0.4s;
margin-bottom: 3px;
}

#neusta_areabrick_config .accordion button.active,
#neusta_areabrick_config .accordion button:hover {
background-color: #ccc;
}

#neusta_areabrick_config .accordion ul {
padding: 0 18px;
display: none;
overflow-x: hidden;
overflow-y: auto;
max-height: 500px;
}

#neusta_areabrick_config .accordion ul.active {
display: block;
}
9 changes: 9 additions & 0 deletions public/js/areabrick-overview-unpublished-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
document.addEventListener('DOMContentLoaded', function () {
document.addEventListener('click', event => {
const el = event.target.closest('#neusta_areabrick_config .accordion');

if (el) {
el.querySelectorAll('button, ul').forEach(el => el.classList.toggle('active'));
}
});
}, { once: true });
56 changes: 56 additions & 0 deletions public/js/areabrick-overview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
pimcore.registerNS('neusta.areabrick_config.areabrick_overview');

neusta.areabrick_config.areabrick_overview = Class.create({

tabId: 'neusta-areabrick-overview-tab',
panel: null,

initialize: function () {
this.getTabPanel();
},

getTabPanel: function () {
if (!this.panel) {
this.panel = Ext.create('Ext.panel.Panel', {
id: this.tabId,
title: t('neusta_areabrick_config.areabrick_overview'),
iconCls: 'pimcore_icon_areabrick',
border: false,
layout: 'fit',
flex: 1,
width: '100%',
scrollable: true,
closable: true,
});

const tabPanel = Ext.getCmp('pimcore_panel_tabs');
tabPanel.add(this.panel);
tabPanel.setActiveItem(this.tabId);

this.panel.on('destroy', function () {
pimcore.globalmanager.remove(this.tabId);
}.bind(this));

Ext.Ajax.request({
url: Routing.generate('neusta_areabrick_config_areabrick_overview'),
success: function(response) {
this.panel.add({
html: response.responseText,
autoScroll: true,
});
}.bind(this),
});

document.getElementById(this.tabId).addEventListener('click', event => {
const el = event.target.closest('#neusta_areabrick_config a[data-page-id]');

if (el) {
pimcore.helpers.openDocument(el.dataset.pageId, el.dataset.pageType);
}
});
}

return this.panel;
},

});
49 changes: 49 additions & 0 deletions public/js/startup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pimcore.registerNS('neusta.areabrick_config.startup');

neusta.areabrick_config.startup = Class.create({

initialize: function () {
if (pimcore.events.preMenuBuild) {
document.addEventListener(pimcore.events.preMenuBuild, this.preMenuBuild.bind(this));
} else {
// Todo: remove when we drop Pimcore 10 support
document.addEventListener(pimcore.events.pimcoreReady, this.preMenuBuild.bind(this));
}
},

preMenuBuild: function (e) {
if (!pimcore.globalmanager.get('perspective').inToolbar('tools.areabricks')) {
return;
}

if (!pimcore.globalmanager.get('user').isAllowed('neusta_areabrick_config.areabrick_overview')) {
return;
}

const items = {
text: t('neusta_areabrick_config.areabrick_overview'),
iconCls: 'pimcore_nav_icon_objectbricks',
priority: 31,
itemId: 'pimcore_menu_tools_areabricks',
handler: this.openAreabrickOverview,
}

if (e.type === pimcore.events.preMenuBuild) {
e.detail.menu.extras.items.push(items);
} else {
// Todo: remove when we drop Pimcore 10 support
pimcore.globalmanager.get('layout_toolbar').extrasMenu.insert(4, items);
}
},

openAreabrickOverview: function() {
try {
pimcore.globalmanager.get('neusta_areabrick_config_areabrick_overview').activate();
} catch (e) {
pimcore.globalmanager.add('neusta_areabrick_config_areabrick_overview', new neusta.areabrick_config.areabrick_overview());
}
},

});

new neusta.areabrick_config.startup();
18 changes: 18 additions & 0 deletions src/Bricks/Model/Brick.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php declare(strict_types=1);

namespace Neusta\Pimcore\AreabrickConfigBundle\Bricks\Model;

final class Brick
{
public string $id;
public string $name;
public ?string $version;
public ?string $description;
public ?string $template;

/** @var list<Page> */
public array $pages;

/** @var list<BrickProperty> */
public array $additionalProperties;
}
9 changes: 9 additions & 0 deletions src/Bricks/Model/BrickProperty.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php declare(strict_types=1);

namespace Neusta\Pimcore\AreabrickConfigBundle\Bricks\Model;

final class BrickProperty
{
public string $name;
public string $value;
}
11 changes: 11 additions & 0 deletions src/Bricks/Model/Page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);

namespace Neusta\Pimcore\AreabrickConfigBundle\Bricks\Model;

final class Page
{
public int $id;
public string $type;
public string $url;
public bool $published = false;
}
Loading
Loading