CMSView.js 5.5 KB

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