Application.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.Application = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": "",
  9. "values": [],
  10. "expand": false,
  11. "forceSearchInItem" : true,
  12. "designer": true
  13. },
  14. setInitTitle: function(){
  15. if (!this.options.title) this.setOptions({"title": MWF.xApplication.Selector.LP.selectAppliction});
  16. },
  17. _init : function(){
  18. this.selectType = "application";
  19. this.className = "Application"
  20. },
  21. loadSelectItems: function(addToNext){
  22. if( this.options.designer ){
  23. o2.Actions.load("x_processplatform_assemble_designer").ApplicationAction.list(function(json){
  24. json.data.each(function(data){
  25. var category = this._newItem(data, this, this.itemAreaNode);
  26. this.items.push( category );
  27. }.bind(this));
  28. }.bind(this));
  29. }else{
  30. o2.Actions.load("x_processplatform_assemble_surface").ApplicationAction.listWithPerson(function(json){
  31. json.data.each(function(data){
  32. var category = this._newItem(data, this, this.itemAreaNode);
  33. this.items.push( category );
  34. }.bind(this));
  35. }.bind(this));
  36. }
  37. },
  38. _scrollEvent: function(y){
  39. return true;
  40. },
  41. _getChildrenItemIds: function(){
  42. return null;
  43. },
  44. _listItemByKey: function(callback, failure, key){
  45. return false;
  46. },
  47. _getItem: function(callback, failure, id, async){
  48. this.processAction.getApplications(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.Application.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.Application.Item(data, selector, container, level);
  60. }
  61. });
  62. MWF.xApplication.Selector.Application.Item = new Class({
  63. Extends: MWF.xApplication.Selector.Person.Item,
  64. _getShowName: function(){
  65. return this.data.name;
  66. },
  67. _setIcon: function(){
  68. var style = "default";
  69. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/applicationicon.png)");
  70. },
  71. loadSubItem: function(){
  72. return false;
  73. },
  74. checkSelectedSingle: function(){
  75. var selectedItem = this.selector.options.values.filter(function(item, index){
  76. if (typeOf(item)==="object"){
  77. if( this.data.id && item.id ){
  78. return this.data.id === item.id;
  79. }else{
  80. return this.data.name === item.name;
  81. }
  82. // return (this.data.id === item.id) || (this.data.name === item.name) ;
  83. }
  84. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  85. return false;
  86. }.bind(this));
  87. if (selectedItem.length){
  88. this.selectedSingle();
  89. }
  90. },
  91. checkSelected: function(){
  92. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  93. //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  94. if( item.data.id && this.data.id){
  95. return item.data.id === this.data.id;
  96. }else{
  97. return item.data.name === this.data.name;
  98. }
  99. }.bind(this));
  100. if (selectedItem.length){
  101. //selectedItem[0].item = this;
  102. selectedItem[0].addItem(this);
  103. this.selectedItem = selectedItem[0];
  104. this.setSelected();
  105. }
  106. }
  107. });
  108. MWF.xApplication.Selector.Application.ItemSelected = new Class({
  109. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  110. _getShowName: function(){
  111. return this.data.name;
  112. },
  113. _setIcon: function(){
  114. var style = "default";
  115. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/applicationicon.png)");
  116. },
  117. check: function(){
  118. if (this.selector.items.length){
  119. var items = this.selector.items.filter(function(item, index){
  120. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  121. }.bind(this));
  122. this.items = items;
  123. if (items.length){
  124. items.each(function(item){
  125. item.selectedItem = this;
  126. item.setSelected();
  127. }.bind(this));
  128. }
  129. }
  130. }
  131. });