@ergonode/media
Version:
Ergonode media module
104 lines (100 loc) • 3 kB
JavaScript
/*
* Copyright © Ergonode Sp. z o.o. All rights reserved.
* See LICENSE for license details.
*/
import {
Components,
Icons,
Store,
} from '/config/imports';
import {
ATTRIBUTE_TYPES,
} from '/defaults';
import {
getImage,
setImage,
} from '/extends/productTemplate/methods';
const AttributeIcons = {
[ATTRIBUTE_TYPES.IMAGE]: [
{
component: Icons.IconImage,
},
],
[ATTRIBUTE_TYPES.GALLERY]: [
{
component: Icons.IconGallery,
},
],
[ATTRIBUTE_TYPES.FILE]: [
{
component: Icons.IconFile,
},
],
};
export default {
extendStore: {
productTemplate: Store.Template,
},
extendComponents: {
'/components/Grid/Layout/Table/Columns': {
IMAGE_PREVIEW: Components.GridImagePreviewColumn,
},
'/components/Grid/Layout/Collection/Cells': {
MEDIA_ATTACH: Components.GridMediaAttachCollectionCell,
IMAGE_PREVIEW: Components.GridImagePreviewCollectionCell,
},
'/components/Grid/Layout/Table/Cells/Edit': {
[ATTRIBUTE_TYPES.IMAGE]: Components.GridImageEditCell,
[ATTRIBUTE_TYPES.GALLERY]: Components.GridGalleryEditCell,
[ATTRIBUTE_TYPES.FILE]: Components.GridFileEditCell,
IMAGE_PREVIEW: Components.GridImagePreviewEditCell,
},
'/components/Forms/ProductTemplateForm': {
__ALL: [
{
component: Components.ProductTemplateFormUploadImage,
order: 10,
},
],
},
'/components/Forms/ProductTemplateForm': {
[ATTRIBUTE_TYPES.IMAGE]: [
{
component: Components.ProductTemplateFormImageField,
},
],
[ATTRIBUTE_TYPES.GALLERY]: [
{
component: Components.ProductTemplateFormGalleryField,
},
],
[ATTRIBUTE_TYPES.FILE]: [
{
component: Components.ProductTemplateFormFileField,
},
],
},
'/extends/components/SideBars/AttributeSideBarElement/icons': AttributeIcons,
'/components/TemplateDesigner/ProductDesigner/AttributeElementContent/icons': AttributeIcons,
},
extendMethods: {
'/store/productTemplate/action/createTemplate/__before': ({
$this,
}) => getImage({
$this,
}),
'/store/productTemplate/action/updateTemplate/__before': ({
$this,
}) => getImage({
$this,
}),
'/store/productTemplate/action/getTemplate/__after': ({
$this, data,
}) => {
setImage({
$this,
data,
});
},
},
};