Skip to content

Commit

Permalink
Merge branch '4.6' into IBX-3456-attribute-groups
Browse files Browse the repository at this point in the history
  • Loading branch information
bozatko authored Jan 8, 2025
2 parents 349a81f + c4dfa51 commit 5b0b962
Show file tree
Hide file tree
Showing 101 changed files with 1,638 additions and 273 deletions.
8 changes: 4 additions & 4 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ parameters:
path: src/bundle/Controller/LinkManagerController.php

-
message: "#^Cannot access offset 0 on iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\.$#"
message: "#^Cannot access offset 0 on iterable\\<int, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\Relation\\>\\.$#"
count: 1
path: src/bundle/Controller/LocationController.php

Expand Down Expand Up @@ -621,7 +621,7 @@ parameters:
path: src/bundle/Controller/ObjectStateController.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ObjectState\\\\ObjectStateCreateStruct\\:\\:\\$names \\(array\\<string\\>\\) does not accept array\\<int\\|string, string\\|null\\>\\.$#"
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ObjectState\\\\ObjectStateCreateStruct\\:\\:\\$names \\(array\\<string\\>\\) does not accept array\\<string\\|null\\>\\.$#"
count: 1
path: src/bundle/Controller/ObjectStateController.php

Expand Down Expand Up @@ -656,7 +656,7 @@ parameters:
path: src/bundle/Controller/ObjectStateGroupController.php

-
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ObjectState\\\\ObjectStateGroupCreateStruct\\:\\:\\$names \\(array\\<string\\>\\) does not accept array\\<int\\|string, string\\|null\\>\\.$#"
message: "#^Property Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\ObjectState\\\\ObjectStateGroupCreateStruct\\:\\:\\$names \\(array\\<string\\>\\) does not accept array\\<string\\|null\\>\\.$#"
count: 1
path: src/bundle/Controller/ObjectStateGroupController.php

Expand Down Expand Up @@ -9546,7 +9546,7 @@ parameters:
path: src/lib/UI/Dataset/VersionsDataset.php

-
message: "#^Parameter \\#2 \\$array of function array_map expects array, iterable\\<Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\> given\\.$#"
message: "#^Parameter \\#2 \\$array of function array_map expects array, iterable\\<int, Ibexa\\\\Contracts\\\\Core\\\\Repository\\\\Values\\\\Content\\\\VersionInfo\\> given\\.$#"
count: 1
path: src/lib/UI/Dataset/VersionsDataset.php

Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Controller/Content/ContentTreeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function loadNodeExtendedInfoAction(Location $location): NodeExtendedInfo
fn (string $languageCode): bool => $this->isPreviewable($location, $content, $languageCode)
);

return new NodeExtendedInfo($locationPermissionRestrictions, $previewableTranslations);
return new NodeExtendedInfo($locationPermissionRestrictions, $previewableTranslations, $translations);
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/bundle/Resources/config/bazinga_js_translation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ active_domains:
- 'ibexa_content_type'
- 'ibexa_dropdown'
- 'ibexa_collapse'
- 'ibexa_popup_menu'
- 'messages'
4 changes: 4 additions & 0 deletions src/bundle/Resources/config/services/forms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,10 @@ services:
tags:
- { name: ibexa.admin_ui.form.trash_location_option, priority: 60 }

Ibexa\AdminUi\Form\TrashLocationOptionProvider\CanHaveDrafts:
tags:
- { name: ibexa.admin_ui.form.trash_location_option, priority: 20 }

Ibexa\AdminUi\Form\TrashLocationOptionProvider\OptionsFactory:
arguments: [!tagged ibexa.admin_ui.form.trash_location_option]

Expand Down
2 changes: 2 additions & 0 deletions src/bundle/Resources/config/services/test/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ services:
Ibexa\AdminUi\Behat\Component\PropertiesList: ~

Ibexa\AdminUi\Behat\Component\FullView: ~

Ibexa\AdminUi\Behat\Component\DeleteContentDialog: ~
3 changes: 3 additions & 0 deletions src/bundle/Resources/encore/ibexa.js.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ const layout = [
path.resolve(__dirname, '../public/js/scripts/core/toggle.button.js'),
path.resolve(__dirname, '../public/js/scripts/core/slug.value.input.autogenerator.js'),
path.resolve(__dirname, '../public/js/scripts/core/date.time.picker.js'),
path.resolve(__dirname, '../public/js/scripts/core/taggify.js'),
path.resolve(__dirname, '../public/js/scripts/core/suggestion.taggify.js'),
path.resolve(__dirname, '../public/js/scripts/core/storage.js'),
path.resolve(__dirname, '../public/js/scripts/adaptive.filters.js'),
path.resolve(__dirname, '../public/js/scripts/admin.notifications.js'),
path.resolve(__dirname, '../public/js/scripts/button.trigger.js'),
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/public/img/ibexa-icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@
detail: { nodes: [fieldNode] },
}),
);
doc.body.dispatchEvent(
new CustomEvent('ibexa-autogenerate-identifier:init', {
detail: { fieldNode, shouldAutogenerateValue: true },
}),
);
};
const insertFieldDefinitionNode = (fieldNode, { targetContainer, draggedItemPosition }) => {
const fieldDefinitionNode = createFieldDefinitionNode(fieldNode, { targetContainer, draggedItemPosition });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,68 @@
(function (global, doc) {
let activeFieldEdit = null;
let previousDistractionFreeModeActive = null;
const clearedPositionNodesData = [];
const DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME = 'ibexa-distraction-free:enable';
const DISTRACTION_FREE_DISABLE_EVENT_NAME = 'ibexa-distraction-free:disable';
const distractionFreeModeEnableBtns = doc.querySelectorAll('.ibexa-field-edit__distraction-free-mode-control-btn--enable');
const distractionFreeModeDisableBtns = doc.querySelectorAll('.ibexa-field-edit__distraction-free-mode-control-btn--disable');
const resetAncestorsPositions = (field) => {
let parentElement = field.parentNode;

while (parentElement && parentElement !== doc.body) {
const { overflow, position } = getComputedStyle(parentElement);

if (overflow !== 'visible' || position === 'absolute') {
clearedPositionNodesData.push({
node: parentElement,
originalInlineOverflow: parentElement.style.overflow,
originalInlinePosition: parentElement.style.position,
});

parentElement.style.overflow = 'visible';
parentElement.style.position = 'static';
}

parentElement = parentElement.parentNode;
}
};
const restoreAncestorsPositions = () => {
clearedPositionNodesData.forEach(({ node, originalInlineOverflow, originalInlinePosition }) => {
if (originalInlineOverflow) {
node.style.overflow = originalInlineOverflow;
} else {
node.style.removeProperty('overflow');
}

if (originalInlinePosition) {
node.style.position = originalInlinePosition;
} else {
node.style.removeProperty('position');
}
});

clearedPositionNodesData.length = 0;
};
const changeDistractionFreeModeState = (active) => {
if (!activeFieldEdit) {
if (!activeFieldEdit || previousDistractionFreeModeActive === active) {
return;
}

previousDistractionFreeModeActive = active;

const dispatchEventName = active ? DISTRACTION_FREE_MODE_ENABLE_EVENT_NAME : DISTRACTION_FREE_DISABLE_EVENT_NAME;
const editorSourceElement = activeFieldEdit.querySelector('.ibexa-data-source__richtext');
const editorInstance = editorSourceElement.ckeditorInstance;

activeFieldEdit.classList.toggle('ibexa-field-edit--distraction-free-mode-active', active);
editorInstance.set('distractionFreeModeActive', active);

if (active) {
resetAncestorsPositions(activeFieldEdit);
} else {
restoreAncestorsPositions();
}

doc.body.dispatchEvent(
new CustomEvent(dispatchEventName, {
detail: {
Expand Down
41 changes: 17 additions & 24 deletions src/bundle/Resources/public/js/scripts/admin.input.text.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function (global, doc) {
const INPUT_PADDING = 12;
const togglePasswordVisibility = (event) => {
const passwordTogglerBtn = event.currentTarget;
const passwordShowIcon = passwordTogglerBtn.querySelector('.ibexa-input-text-wrapper__password-show');
Expand Down Expand Up @@ -40,35 +41,27 @@
passwordTogglerBtns.forEach((passwordTogglerBtn) => passwordTogglerBtn.addEventListener('click', togglePasswordVisibility, false));
recalculateStyling();
};
const handleInputChange = ({ target: { value } }, btn) => {
btn.disabled = value.trim() === '';
};
const recalculateStyling = () => {
const extraBtns = doc.querySelectorAll('.ibexa-input-text-wrapper__action-btn--extra-btn');

extraBtns.forEach((btn) => {
const input = btn.closest('.ibexa-input-text-wrapper').querySelector('input');
const clearButton = btn.previousElementSibling?.classList.contains('ibexa-input-text-wrapper__action-btn--clear')
? btn.previousElementSibling
: null;
const recalculateInputStyling = (inputActionsContainer) => {
const input = inputActionsContainer.closest('.ibexa-input-text-wrapper').querySelector('input');

if (!input) {
return;
}
if (!input) {
return;
}

btn.disabled = !input.value;
input.addEventListener('input', (inputEvent) => handleInputChange(inputEvent, btn), false);
const { width: actionsWidth } = inputActionsContainer.getBoundingClientRect();

if (!clearButton) {
return;
}
input.style.paddingRight = `${actionsWidth + INPUT_PADDING}px`;
};
const recalculateStyling = () => {
const inputActionsContainers = doc.querySelectorAll('.ibexa-input-text-wrapper__actions');

const clearButtonStyles = global.getComputedStyle(clearButton);
const clearButtonMarginRight = parseInt(clearButtonStyles.getPropertyValue('margin-right'), 10);
const clearButtonWidth = parseInt(clearButtonStyles.getPropertyValue('width'), 10);
const paddingRight = `${btn.offsetWidth + clearButtonMarginRight + clearButtonWidth}px`;
inputActionsContainers.forEach((inputActionsContainer) => {
const inputActionsContainerObserver = new ResizeObserver(() => {
recalculateInputStyling(inputActionsContainer);
});

input.style.paddingRight = paddingRight;
inputActionsContainerObserver.observe(inputActionsContainer);
recalculateInputStyling(inputActionsContainer);
});
};

Expand Down
34 changes: 26 additions & 8 deletions src/bundle/Resources/public/js/scripts/autogenerate.identifier.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
(function (doc, ibexa) {
const sourceInputs = doc.querySelectorAll('[data-autogenerate-identifier-target-selector]');

sourceInputs.forEach((sourceInput) => {
const { autogenerateIdentifierTargetSelector } = sourceInput.dataset;
const targetInput = doc.querySelector(autogenerateIdentifierTargetSelector);
const identifierAutogenerator = new ibexa.core.SlugValueInputAutogenerator({
sourceInput,
targetInput,
const initAutogenerator = (elements, shouldAutogenerateValue) => {
elements.forEach((sourceInput) => {
const { autogenerateIdentifierTargetSelector } = sourceInput.dataset;
const targetInput = doc.querySelector(autogenerateIdentifierTargetSelector);
const identifierAutogenerator = new ibexa.core.SlugValueInputAutogenerator({
sourceInput,
targetInput,
shouldAutogenerateValue: shouldAutogenerateValue || !targetInput.value,
});

identifierAutogenerator.init();
});
};
const attachListeners = () => {
doc.body.addEventListener(
'ibexa-autogenerate-identifier:init',
(event) => {
const { fieldNode, shouldAutogenerateValue } = event.detail;
const sourceFields = fieldNode.querySelectorAll('[data-autogenerate-identifier-target-selector]');

initAutogenerator(sourceFields, shouldAutogenerateValue);
},
false,
);
};

identifierAutogenerator.init();
});
initAutogenerator(sourceInputs);
attachListeners();
})(document, window.ibexa);
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
this.sourceInput = config.sourceInput;
this.targetInput = config.targetInput;
this.whitespaceTextReplacer = config.whitespaceTextReplacer || '_';
this.shouldAutogenerateValue = !this.targetInput.value;
this.shouldAutogenerateValue = config.shouldAutogenerateValue || !this.targetInput.value;
}

slugify(text) {
Expand Down
45 changes: 45 additions & 0 deletions src/bundle/Resources/public/js/scripts/core/storage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
(function (global, doc, ibexa) {
class IbexaStorage {
constructor(config) {
const keySuffix = config.isUserAware ? `:${ibexa.helpers.user.getId()}` : '';

this.key = `${config.key}${keySuffix}`;
this.eventName = config.eventName;
}

setItem(data) {
const stringifiedData = JSON.stringify(data);

global.localStorage.setItem(this.key, stringifiedData);

this.fireStorageChangeEvent(stringifiedData);
}

getItem() {
return JSON.parse(global.localStorage.getItem(this.key));
}

fireStorageChangeEvent(data) {
if (this.eventName) {
const storageChangeEvent = new CustomEvent(this.eventName, {
cancelable: true,
detail: { content: JSON.parse(data) },
});

doc.body.dispatchEvent(storageChangeEvent);
}
}

init() {
if (this.eventName) {
global.addEventListener('storage', (event) => {
if (event.key === this.key) {
this.fireStorageChangeEvent(event.newValue);
}
});
}
}
}

ibexa.addConfig('core.Storage', IbexaStorage);
})(window, window.document, window.ibexa);
Loading

0 comments on commit 5b0b962

Please sign in to comment.