CMSView.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.CMSView = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectView,
  9. "values": [],
  10. "names": [],
  11. "expand": false
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.cmsAction.listCMSApplicationView(function(json){
  15. if (json.data.length){
  16. json.data.each(function(data){
  17. if (data.queryViews && data.queryViews.length){
  18. var category = this._newItemCategory(data, this, this.itemAreaNode);
  19. data.queryViews.each(function(d){
  20. d.applicationName = data.appName;
  21. var item = this._newItem(d, this, category.children);
  22. this.items.push(item);
  23. }.bind(this));
  24. }
  25. }.bind(this));
  26. }
  27. }.bind(this));
  28. },
  29. _scrollEvent: function(y){
  30. return true;
  31. },
  32. _getChildrenItemIds: function(data){
  33. return data.queryViews || [];
  34. },
  35. _newItemCategory: function(data, selector, item, level){
  36. return new MWF.xApplication.Selector.CMSView.ItemCategory(data, selector, item, level)
  37. },
  38. _listItemByKey: function(callback, failure, key){
  39. return false;
  40. },
  41. _getItem: function(callback, failure, id, async){
  42. this.cmsAction.getQueryView(function(json){
  43. if (callback) callback.apply(this, [json]);
  44. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
  45. },
  46. _newItemSelected: function(data, selector, item){
  47. return new MWF.xApplication.Selector.CMSView.ItemSelected(data, selector, item)
  48. },
  49. _listItemByPinyin: function(callback, failure, key){
  50. return false;
  51. },
  52. _newItem: function(data, selector, container, level){
  53. return new MWF.xApplication.Selector.CMSView.Item(data, selector, container, level);
  54. }
  55. });
  56. MWF.xApplication.Selector.CMSView.Item = new Class({
  57. Extends: MWF.xApplication.Selector.Person.Item,
  58. _getShowName: function(){
  59. return this.data.name;
  60. },
  61. _setIcon: function(){
  62. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  63. },
  64. loadSubItem: function(){
  65. return false;
  66. },
  67. checkSelectedSingle: function(){
  68. var selectedItem = this.selector.options.values.filter(function(item, index){
  69. if (typeOf(item)==="object") {
  70. //return (this.data.id === item.id) || (this.data.name === item.name) ;
  71. if (this.data.id && item.id) {
  72. return this.data.id === item.id;
  73. } else {
  74. return this.data.name === item.name;
  75. }
  76. }
  77. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  78. return false;
  79. }.bind(this));
  80. if (selectedItem.length){
  81. this.selectedSingle();
  82. }
  83. },
  84. checkSelected: function(){
  85. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  86. if( item.data.id && this.data.id){
  87. return item.data.id === this.data.id;
  88. }else{
  89. return item.data.name === this.data.name;
  90. }
  91. //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  92. }.bind(this));
  93. if (selectedItem.length){
  94. //selectedItem[0].item = this;
  95. selectedItem[0].addItem(this);
  96. this.selectedItem = selectedItem[0];
  97. this.setSelected();
  98. }
  99. }
  100. });
  101. MWF.xApplication.Selector.CMSView.ItemSelected = new Class({
  102. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  103. _getShowName: function(){
  104. return this.data.name;
  105. },
  106. _setIcon: function(){
  107. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  108. },
  109. check: function(){
  110. if (this.selector.items.length){
  111. var items = this.selector.items.filter(function(item, index){
  112. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  113. }.bind(this));
  114. this.items = items;
  115. if (items.length){
  116. items.each(function(item){
  117. item.selectedItem = this;
  118. item.setSelected();
  119. }.bind(this));
  120. }
  121. }
  122. }
  123. });
  124. MWF.xApplication.Selector.CMSView.ItemCategory = new Class({
  125. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  126. _getShowName: function(){
  127. return this.data.appName;
  128. },
  129. createNode: function(){
  130. this.node = new Element("div", {
  131. "styles": this.selector.css.selectorItemCategory_department
  132. }).inject(this.container);
  133. },
  134. _setIcon: function(){
  135. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  136. },
  137. _hasChild: function(){
  138. return (this.data.queryViews && this.data.queryViews.length);
  139. },
  140. check: function(){}
  141. });