diff --git a/pimcore/static6/js/pimcore/document/tags/renderlet.js b/pimcore/static6/js/pimcore/document/tags/renderlet.js index 13b54b3c37b..600f5ce6930 100644 --- a/pimcore/static6/js/pimcore/document/tags/renderlet.js +++ b/pimcore/static6/js/pimcore/document/tags/renderlet.js @@ -48,7 +48,7 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { this.element = new Ext.Panel(this.options); this.element.on("render", function (el) { - + // register at global DnD manager dndManager.addDropTarget(el.getEl(), this.onNodeOver.bind(this), this.onNodeDrop.bind(this)); @@ -64,7 +64,7 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { }.bind(this)); this.element.render(id); - + // insert snippet content if (data) { this.data = data; @@ -84,6 +84,18 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { this.data.type = data.elementType; this.data.subtype = data.type; + if (this.options.type) { + if (this.options.type != data.elementType) { + return false; + } + } + + if (this.options.className) { + if (this.options.className != data.className) { + return false; + } + } + if (this.options.reload) { this.reloadDocument(); } else { @@ -94,9 +106,20 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { }, onNodeOver: function(target, dd, e, data) { + data = data.records[0].data; + if (this.options.type) { + if (this.options.type != data.elementType) { + return false; + } + } - return Ext.dd.DropZone.prototype.dropAllowed; + if (this.options.className) { + if (this.options.className != data.className) { + return false; + } + } + return Ext.dd.DropZone.prototype.dropAllowed; }, getBody: function () { @@ -186,28 +209,39 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { }.bind(this) })); } - + menu.add(new Ext.menu.Item({ text: t('search'), iconCls: "pimcore_icon_search", handler: function (item) { item.parentMenu.destroy(); - + this.openSearchEditor(); }.bind(this) })); - + menu.showAt(e.getXY()); e.stopEvent(); }, - + openSearchEditor: function () { - pimcore.helpers.itemselector(false, this.addDataFromSelector.bind(this), {}); + var restrictions = {}; + + if (this.options.type) { + restrictions.type = [this.options.type]; + } + if (this.options.className) { + restrictions.specific = { + classes: [this.options.className] + }; + } + + pimcore.helpers.itemselector(false, this.addDataFromSelector.bind(this), restrictions); }, - - addDataFromSelector: function (item) { + + addDataFromSelector: function (item) { if(item) { // get path from nodes data this.data.id = item.id; @@ -221,7 +255,7 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { } } }, - + getValue: function () { return this.data; }, @@ -229,4 +263,4 @@ pimcore.document.tags.renderlet = Class.create(pimcore.document.tag, { getType: function () { return "renderlet"; } -}); \ No newline at end of file +});