View.js 5.5 KB

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