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

IBX-6530: Fixed checkbox in content type edit #32

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Changes from 4 commits
Commits
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
23 changes: 18 additions & 5 deletions src/bundle/Resources/public/js/scripts/admin.contenttype.matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,39 @@
node.insertAdjacentHTML('beforeend', template.replace(NUMBER_PLACEHOLDER, getNextIndex(node)));

initColumns(settingsNode);

node.closest('.ibexa-table').dispatchEvent(new CustomEvent('ibexa-refresh-main-table-checkbox'));
};
const removeItems = (event) => {
const settingsNode = event.target.closest(SELECTOR_SETTINGS_COLUMNS);

findCheckedColumns(settingsNode).forEach((btn) => btn.closest(SELECTOR_COLUMN).remove());
findCheckedColumns(settingsNode).forEach((checkbox) => {
checkbox.checked = false;
checkbox.dispatchEvent(new Event('change'));
checkbox.closest(SELECTOR_COLUMN).remove();
});

initColumns(settingsNode);
};
const checkColumn = (event) => {
const settingsNode = event.target.closest(SELECTOR_SETTINGS_COLUMNS);
const settingsNode = event.currentTarget.closest(SELECTOR_SETTINGS_COLUMNS);
const isFromJS = event.detail?.isFromJS ?? false;

if (isFromJS) {
return;
}

updateDisabledState(settingsNode);
};
const initColumns = (parentNode) => {
updateDisabledState(parentNode);

parentNode.querySelectorAll(SELECTOR_COLUMN_CHECKBOX).forEach((btn) => {
btn.removeEventListener('click', checkColumn, false);
btn.addEventListener('click', checkColumn, false);
parentNode.querySelectorAll(SELECTOR_COLUMN_CHECKBOX).forEach((checkbox) => {
checkbox.removeEventListener('change', checkColumn, false);
checkbox.addEventListener('change', checkColumn, false);
});

parentNode.querySelector('.ibexa-table').dispatchEvent(new CustomEvent('ibexa-refresh-main-table-checkbox'));
};
const initComponent = (container) => {
container.querySelector(SELECTOR_ADD_COLUMN).addEventListener('click', addItem, false);
Expand Down