/pimcore/static/js/pimcore/object/classes/data/objects.js

https://github.com/timglabisch/pimcore · JavaScript · 139 lines · 100 code · 20 blank · 19 comment · 6 complexity · 4a33d2211f6d777c1b47c068ceec8e86 MD5 · raw file

  1. /**
  2. * Pimcore
  3. *
  4. * LICENSE
  5. *
  6. * This source file is subject to the new BSD license that is bundled
  7. * with this package in the file LICENSE.txt.
  8. * It is also available through the world-wide-web at this URL:
  9. * http://www.pimcore.org/license
  10. *
  11. * @copyright Copyright (c) 2009-2013 pimcore GmbH (http://www.pimcore.org)
  12. * @license http://www.pimcore.org/license New BSD License
  13. */
  14. pimcore.registerNS("pimcore.object.classes.data.objects");
  15. pimcore.object.classes.data.objects = Class.create(pimcore.object.classes.data.data, {
  16. type: "objects",
  17. /**
  18. * define where this datatype is allowed
  19. */
  20. allowIn: {
  21. object: true,
  22. objectbrick: true,
  23. fieldcollection: true,
  24. localizedfield: true
  25. },
  26. initialize: function (treeNode, initData) {
  27. this.type = "objects";
  28. this.initData(initData);
  29. // overwrite default settings
  30. this.availableSettingsFields = ["name","title","tooltip","mandatory","noteditable","invisible",
  31. "visibleGridView","visibleSearch","style"];
  32. this.treeNode = treeNode;
  33. },
  34. getGroup: function () {
  35. return "relation";
  36. },
  37. getTypeName: function () {
  38. return t("objects");
  39. },
  40. getIconClass: function () {
  41. return "pimcore_icon_object";
  42. },
  43. getLayout: function ($super) {
  44. $super();
  45. this.specificPanel.removeAll();
  46. this.uniqeFieldId = uniqid();
  47. this.specificPanel.removeAll();
  48. this.specificPanel.add([
  49. {
  50. xtype: "spinnerfield",
  51. fieldLabel: t("width"),
  52. name: "width",
  53. value: this.datax.width
  54. },
  55. {
  56. xtype: "spinnerfield",
  57. fieldLabel: t("height"),
  58. name: "height",
  59. value: this.datax.height
  60. },{
  61. xtype: "spinnerfield",
  62. fieldLabel: t("maximum_items"),
  63. name: "maxItems",
  64. value: this.datax.maxItems
  65. },
  66. {
  67. xtype: "checkbox",
  68. fieldLabel: t("lazy_loading"),
  69. name: "lazyLoading",
  70. checked: this.datax.lazyLoading
  71. },
  72. {
  73. xtype: "displayfield",
  74. hideLabel: true,
  75. value: t('lazy_loading_description'),
  76. cls: "pimcore_extra_label_bottom",
  77. style: "padding-bottom:0;"
  78. },
  79. {
  80. xtype: "displayfield",
  81. hideLabel: true,
  82. value: t('lazy_loading_warning'),
  83. cls: "pimcore_extra_label_bottom",
  84. style: "color:red; font-weight: bold;"
  85. }
  86. ]);
  87. var classes = [];
  88. if(typeof this.datax.classes == "object") {
  89. // this is when it comes from the server
  90. for(var i=0; i<this.datax.classes.length; i++) {
  91. classes.push(this.datax.classes[i]["classes"]);
  92. }
  93. } else if(typeof this.datax.classes == "string") {
  94. // this is when it comes from the local store
  95. classes = this.datax.classes.split(",");
  96. }
  97. var classesStore = new Ext.data.JsonStore({
  98. autoDestroy: true,
  99. url: '/admin/class/get-tree',
  100. fields: ["text"]
  101. });
  102. classesStore.load({
  103. "callback": function (classes) {
  104. Ext.getCmp('class_allowed_object_classes_' + this.uniqeFieldId).setValue(classes.join(","));
  105. }.bind(this, classes)
  106. });
  107. this.specificPanel.add(new Ext.ux.form.MultiSelect({
  108. fieldLabel: t("allowed_classes"),
  109. id: "class_allowed_object_classes_" + this.uniqeFieldId,
  110. name: "classes",
  111. value: classes.join(","),
  112. displayField: "text",
  113. valueField: "text",
  114. store: classesStore,
  115. width: 300
  116. }));
  117. return this.layout;
  118. }
  119. });