View.js 5.4 KB

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