All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
META-INF.resources.js.ManagementToolbarPropsTransformer.js Maven / Gradle / Ivy
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
import {addParams, navigate, openSelectionModal} from 'frontend-js-web';
import openDeleteArticleModal from './modals/openDeleteArticleModal';
export default function propsTransformer({
additionalProps: {
addArticleURL,
exportTranslationURL,
moveArticlesAndFoldersURL,
openViewMoreStructuresURL,
selectEntityURL,
trashEnabled,
viewDDMStructureArticlesURL,
},
portletNamespace,
...otherProps
}) {
const deleteEntries = () => {
if (trashEnabled) {
Liferay.fire(`${portletNamespace}editEntry`, {
action: '/journal/move_articles_and_folders_to_trash',
});
return;
}
openDeleteArticleModal({
onDelete: () => {
Liferay.fire(`${portletNamespace}editEntry`, {
action: '/journal/delete_articles_and_folders',
});
},
});
};
const expireEntries = () => {
Liferay.fire(`${portletNamespace}editEntry`, {
action: '/journal/expire_articles_and_folders',
});
};
const exportTranslation = () => {
const url = new URL(exportTranslationURL);
const searchContainer = Liferay.SearchContainer.get(
`${portletNamespace}articles`
);
const keys = searchContainer.select
.getAllSelectedElements()
.get('value');
navigate(
addParams(
{
[`_${url.searchParams.get('p_p_id')}_key`]: keys.join(','),
},
exportTranslationURL
)
);
};
const moveEntries = () => {
let entrySelectorNodes = document.querySelectorAll('.entry-selector');
if (!entrySelectorNodes.length) {
entrySelectorNodes = document.querySelectorAll(
'.card-page-item input[type="checkbox"]'
);
}
entrySelectorNodes.forEach((node) => {
if (node.checked) {
moveArticlesAndFoldersURL = addParams(
`${node.name}=${node.value}`,
moveArticlesAndFoldersURL
);
}
});
navigate(moveArticlesAndFoldersURL);
};
return {
...otherProps,
onActionButtonClick(event, {item}) {
const action = item?.data?.action;
if (action === 'deleteEntries') {
deleteEntries();
}
else if (action === 'expireEntries') {
expireEntries();
}
else if (action === 'exportTranslation') {
exportTranslation();
}
else if (action === 'moveEntries') {
moveEntries();
}
},
onFilterDropdownItemClick(event, {item}) {
if (item?.data?.action === 'openDDMStructuresSelector') {
openSelectionModal({
onSelect: (selectedItem) => {
if (selectedItem) {
const itemValue = JSON.parse(selectedItem.value);
navigate(
addParams(
{
[`${portletNamespace}ddmStructureKey`]: itemValue.ddmstructurekey,
},
viewDDMStructureArticlesURL
)
);
}
},
selectEventName: `${portletNamespace}selectDDMStructure`,
title: Liferay.Language.get('structures'),
url: selectEntityURL,
});
}
},
onShowMoreButtonClick() {
let refreshOnClose = true;
openSelectionModal({
onClose: () => {
if (refreshOnClose) {
navigate(location.href);
}
},
onSelect: (selectedItem) => {
if (selectedItem) {
refreshOnClose = false;
navigate(
addParams(
{
[`${portletNamespace}ddmStructureKey`]: selectedItem.ddmstructurekey,
},
addArticleURL
)
);
}
},
selectEventName: `${portletNamespace}selectAddMenuItem`,
title: Liferay.Language.get('more'),
url: openViewMoreStructuresURL,
});
},
};
}