Skip to content

Commit 9d5b256

Browse files
authored
Merge pull request #7 from elbformat/ibexa4
Ibexa 4.6 compatibility
2 parents 5c73cf9 + 33dddad commit 9d5b256

18 files changed

Lines changed: 76 additions & 202 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
.phpunit.result.cache
55
composer.lock
66
docker-compose.override.yml
7+
auth.json

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ elbformat_icon:
2626
- clock
2727
- house
2828
iconset2:
29-
folder: "vendor/ezsystems/ezplatform-admin-ui/src/bundle/Resources/public/img/icons"
29+
folder: "vendor/ibexa/admin-ui/src/bundle/Resources/public/img/icons"
3030
```
3131
See [configuration](doc/configuration.md) for more advanced examples
3232

Resources/encore/ez.config.manager.js

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// See https://doc.ibexa.co/en/3.3/extending/import_assets_from_bundle/#configuration-from-main-project-files
2+
const path = require('path');
3+
4+
module.exports = (ibexaConfig, ibexaConfigManager) => {
5+
// Edit
6+
ibexaConfigManager.add({
7+
ibexaConfig,
8+
entryName: 'ibexa-admin-ui-content-edit-parts-js',
9+
newItems: [
10+
path.resolve(__dirname, '../public/js/elbformat-icon-edit.js')
11+
]
12+
});
13+
// Preview
14+
ibexaConfigManager.add({
15+
ibexaConfig,
16+
entryName: 'ibexa-admin-ui-layout-css',
17+
newItems: [
18+
path.resolve(__dirname, '../public/css/elbformat-icon-preview.css')
19+
]
20+
});
21+
22+
};

Resources/public/css/elbformat-icon-edit.css

Lines changed: 0 additions & 84 deletions
This file was deleted.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
.ez-content-preview .elbformat-icon {
1+
.ibexa-content-preview .elbformat-icon {
22
text-align: left;
33
}
4-
.ez-content-preview .elbformat-icon .icon-container {
4+
.ibexa-content-preview .elbformat-icon .icon-container {
55
height: 18px;
66
width: 30px;
77
display: inline-block;
88
}
9-
.ez-content-preview .elbformat-icon .icon-container img {
9+
.ibexa-content-preview .elbformat-icon .icon-container img {
1010
max-height: 90%;
1111
max-width: 90%;
1212
}
Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,21 @@
1-
// Inspired by https://codepen.io/giannisrig/pen/ywBWOV
21
window.addEventListener('load', function() {
3-
document.querySelectorAll('.elbformat-icon-select').forEach((iconDropdown) => {
4-
// Hidden field to carry the form data
5-
let hiddenField = document.createElement('input');
6-
hiddenField.setAttribute('type','hidden');
7-
hiddenField.setAttribute('name', iconDropdown.getAttribute('name'));
8-
let value = iconDropdown.value || '';
9-
hiddenField.setAttribute('value', value);
10-
iconDropdown.after(hiddenField);
2+
// Find list entries
3+
document.querySelectorAll('.elbformat-icon-select').forEach((iconDropdownEntry) => {
4+
let value = iconDropdownEntry.value || '';
5+
let iconMarkup = iconDropdownEntry.getAttribute('data-markup');
6+
let li = iconDropdownEntry.closest('.ibexa-dropdown').querySelector('.ibexa-dropdown__item[data-value="'+value+'"]');
117

12-
// Wrapper for new widget
13-
let wrapper = document.createElement('div');
14-
wrapper.classList.add('icon-dropdown-wrapper');
15-
iconDropdown.after(wrapper);
8+
// Create a span with icon
9+
let wrapper = document.createElement('span');
10+
wrapper.classList.add('ibexa-icon');
11+
wrapper.classList.add('ibexa-icon--small');
12+
wrapper.innerHTML =iconMarkup;
1613

17-
let button = document.createElement('button');
18-
button.classList.add('icon-dropdown-trigger');
19-
wrapper.appendChild(button);
20-
let iconList = document.createElement('div');
21-
iconList.classList.add('icon-dropdown-list');
22-
wrapper.appendChild(iconList);
14+
// Insert before the label
15+
let label = li.querySelector('.ibexa-dropdown__item-label');
16+
li.insertBefore(wrapper, label);
2317

24-
// Extract icons
25-
let items = JSON.parse(iconDropdown.getAttribute('data-choices'));
26-
for (const [key, tmpl] of Object.entries(items)) {
27-
let container = document.createElement('button');
28-
container.setAttribute('value', key)
29-
let iconContainer = document.createElement('div');
30-
iconContainer.classList.add('icon-container');
31-
iconContainer.innerHTML = tmpl;
32-
container.appendChild(iconContainer);
33-
container.innerHTML+=key
34-
iconList.appendChild(container);
35-
if (value===key) {
36-
button.innerHTML = container.innerHTML;
37-
}
38-
// Click on entry
39-
container.addEventListener('click',(e) => {
40-
button.innerHTML = container.innerHTML;
41-
hiddenField.value = key;
42-
wrapper.classList.remove('open');
43-
e.preventDefault();
44-
return false;
45-
});
46-
};
47-
48-
// Open/Close
49-
button.addEventListener('click',(e) => {
50-
if (wrapper.classList.contains('open')) {
51-
wrapper.classList.remove('open');
52-
} else {
53-
wrapper.classList.add('open');
54-
}
55-
e.preventDefault();
56-
return false;
57-
});
18+
// @todo also update the selected choice with an icon
5819
});
5920

6021
});

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
},
2424
"require": {
2525
"php": "^8.1",
26-
"ezsystems/ezplatform-core": "^2.3",
27-
"ezsystems/ezplatform-admin-ui": "^2.3",
26+
"ibexa/core": "^4.6",
27+
"ibexa/admin-ui": "^4.6",
2828
"symfony/finder": "^5.4|^6.4"
2929
},
3030
"require-dev": {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ezplatform:
1+
ibexa:
22
system:
33
default:
44
field_templates:

config/services.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ services:
44
$serializer: '@eZ\Publish\SPI\FieldType\ValueSerializerInterface'
55
$validator: '@Symfony\Component\Validator\Validator\ValidatorInterface'
66
tags:
7-
- { name: ezplatform.field_type, alias: icon }
8-
- { name: ezplatform.field_type.form_mapper.value, fieldType: icon }
9-
- { name: ezplatform.field_type.form_mapper.definition, fieldType: icon }
7+
- { name: ibexa.field_type, alias: icon }
8+
- { name: ibexa.admin_ui.field_type.form.mapper.value, fieldType: icon }
9+
- { name: ibexa.admin_ui.field_type.form.mapper.definition, fieldType: icon }
1010

1111
Elbformat\IconBundle\FieldType\Icon\SearchField:
12-
class: '%ezpublish.fieldType.indexable.unindexed.class%'
12+
class: 'Ibexa\Core\FieldType\Unindexed'
1313
tags:
14-
- { name: ezplatform.field_type.indexable, alias: icon }
14+
- { name: ibexa.field_type.indexable, alias: icon }
1515

1616
Elbformat\IconBundle\Form\Type\IconType:
1717
arguments:

0 commit comments

Comments
 (0)