Permalink
Browse files

Merge pull request #210 from joramhoefs/upsteam

Prevent that empty class groups are created if there are no permitted classes.
  • Loading branch information...
brusch committed Aug 7, 2015
2 parents e201e25 + 3e3ccc0 commit e170f53609f74c429378db69728cf565ab24637d
Showing with 70 additions and 51 deletions.
  1. +70 −51 pimcore/static/js/pimcore/object/tree.js
@@ -331,74 +331,93 @@ pimcore.object.tree = Class.create({
var tmpMenuEntry;
var tmpMenuEntryImport;
var record, tmp;
var showGroup;
for (var groupName in classGroups) {
showGroup = false;
if (classGroups[groupName].length > 1) {
// handle group
tmpMenuEntry = {
text: groupName,
iconCls: "pimcore_icon_folder",
hideOnClick: false,
menu: {
items: []
}
};
tmpMenuEntryImport = {
text: groupName,
iconCls: "pimcore_icon_folder",
handler: this.attributes.reference.importObjects.bind(this, classGroups[groupName][0].get("id"), classGroups[groupName][0].get("text")),
menu: {
items: []
// check if there are any allowed classes
if (this.attributes.reference.config.allowedClasses != "all") {
for (var i = 0; i < classGroups[groupName].length; i++) {
if (showGroup) {
break;
}
record = classGroups[groupName][i];
if (in_array(record.get("id"), this.attributes.reference.config.allowedClasses)) {
showGroup = true;
}
}
};
} else {
showGroup = true;
}
// add items
for (var i = 0; i < classGroups[groupName].length; i++) {
record = classGroups[groupName][i];
if (this.attributes.reference.config.allowedClasses == "all" || in_array(record.get("id"),
this.attributes.reference.config.allowedClasses)) {
/* == menu entry: create new object == */
// create menu item
tmp = {
text: record.get("translatedText"),
iconCls: "pimcore_icon_object_add",
handler: this.attributes.reference.addObject.bind(this, record.get("id"), record.get("text"))
};
// add special icon
if (record.get("icon")) {
tmp.icon = record.get("icon");
tmp.iconCls = "";
if( showGroup) {
tmpMenuEntry = {
text: groupName,
iconCls: "pimcore_icon_folder",
hideOnClick: false,
menu: {
items: []
}
};
tmpMenuEntryImport = {
text: groupName,
iconCls: "pimcore_icon_folder",
handler: this.attributes.reference.importObjects.bind(this, classGroups[groupName][0].get("id"), classGroups[groupName][0].get("text")),
menu: {
items: []
}
};
tmpMenuEntry.menu.items.push(tmp);
// add items
for (var i = 0; i < classGroups[groupName].length; i++) {
record = classGroups[groupName][i];
if (this.attributes.reference.config.allowedClasses == "all" || in_array(record.get("id"),
this.attributes.reference.config.allowedClasses)) {
/* == menu entry: create new object == */
// create menu item
tmp = {
text: record.get("translatedText"),
iconCls: "pimcore_icon_object_add",
handler: this.attributes.reference.addObject.bind(this, record.get("id"), record.get("text"))
};
// add special icon
if (record.get("icon")) {
tmp.icon = record.get("icon");
tmp.iconCls = "";
}
tmpMenuEntry.menu.items.push(tmp);
/* == menu entry: import object == */
/* == menu entry: import object == */
// create menu item
tmp = {
text: record.get("translatedText"),
iconCls: "pimcore_icon_object_import",
handler: this.attributes.reference.importObjects.bind(this, record.get("id"), record.get("text"))
};
// create menu item
tmp = {
text: record.get("translatedText"),
iconCls: "pimcore_icon_object_import",
handler: this.attributes.reference.importObjects.bind(this, record.get("id"), record.get("text"))
};
// add special icon
if (record.get("icon")) {
tmp.icon = record.get("icon");
tmp.iconCls = "";
}
// add special icon
if (record.get("icon")) {
tmp.icon = record.get("icon");
tmp.iconCls = "";
}
tmpMenuEntryImport.menu.items.push(tmp);
tmpMenuEntryImport.menu.items.push(tmp);
}
}
}
objectMenu.objects.push(tmpMenuEntry);
objectMenu.importer.push(tmpMenuEntryImport);
objectMenu.objects.push(tmpMenuEntry);
objectMenu.importer.push(tmpMenuEntryImport);
}
}
else {
record = classGroups[groupName][0];

0 comments on commit e170f53

Please sign in to comment.