Skip to content

Commit 7b7c5e2

Browse files
authored
[Perspectives] Prevent objects from being copied to sections which do not allow objects of the given class (#881)
* perspectives: prevent objects from being copied to sections which do not allow objects of the given class * perspectives: prevent objects from being copied to sections which do not allow objects of the given class * perspectives: prevent objects from being copied to sections which do not allow objects of the given class * perspectives: prevent objects from being copied to sections which do not allow objects of the given class
1 parent a646eb0 commit 7b7c5e2

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

public/js/pimcore/object/tree.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ pimcore.registerNS("pimcore.object.tree");
555555
var pasteMenu = [];
556556

557557
if (perspectiveCfg.inTreeContextMenu("object.paste")) {
558-
if (pimcore.cachedObjectId) {
558+
if (pimcore.cachedObjectId && (typeof perspectiveCfg.classes === "undefined" || typeof pimcore.copiedObject.get('className') === "undefined" || pimcore.copiedObject.get('className') in perspectiveCfg.classes)) {
559559
pasteMenu.push({
560560
text: t("paste_recursive_as_child"),
561561
iconCls: "pimcore_icon_paste",
@@ -583,28 +583,26 @@ pimcore.registerNS("pimcore.object.tree");
583583
}
584584
}
585585

586-
if (!isVariant) {
587-
if (pimcore.cutObject) {
588-
pasteMenu.push({
589-
text: t("paste_cut_element"),
590-
iconCls: "pimcore_icon_paste",
591-
handler: function () {
592-
this.pasteCutObject(pimcore.cutObject,
593-
pimcore.cutObjectParentNode, record, this.tree);
594-
pimcore.cutObjectParentNode = null;
595-
pimcore.cutObject = null;
596-
}.bind(this)
597-
});
598-
}
586+
if (pimcore.cutObject && (typeof perspectiveCfg.classes === "undefined" || typeof pimcore.cutObject.get('className') === "undefined" || pimcore.cutObject.get('className') in perspectiveCfg.classes)) {
587+
pasteMenu.push({
588+
text: t("paste_cut_element"),
589+
iconCls: "pimcore_icon_paste",
590+
handler: function () {
591+
this.pasteCutObject(pimcore.cutObject,
592+
pimcore.cutObjectParentNode, record, this.tree);
593+
pimcore.cutObjectParentNode = null;
594+
pimcore.cutObject = null;
595+
}.bind(this)
596+
});
597+
}
599598

600-
if (pasteMenu.length > 0) {
601-
menu.add(new Ext.menu.Item({
602-
text: t('paste'),
603-
iconCls: "pimcore_icon_paste",
604-
hideOnClick: false,
605-
menu: pasteMenu
606-
}));
607-
}
599+
if (pasteMenu.length > 0) {
600+
menu.add(new Ext.menu.Item({
601+
text: t('paste'),
602+
iconCls: "pimcore_icon_paste",
603+
hideOnClick: false,
604+
menu: pasteMenu
605+
}));
608606
}
609607
}
610608
}
@@ -854,6 +852,7 @@ pimcore.registerNS("pimcore.object.tree");
854852

855853
copy: function (tree, record) {
856854
pimcore.cachedObjectId = record.data.id;
855+
pimcore.copiedObject = record;
857856
},
858857

859858
cut: function (tree, record) {

0 commit comments

Comments
 (0)