ValidationEditor.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. MWF.xApplication.cms.FormDesigner.widget = MWF.xApplication.cms.FormDesigner.widget || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ValidationEditor", null, false);
  3. MWF.xApplication.cms.FormDesigner.widget.ValidationEditor = new Class({
  4. Extends: MWF.xApplication.process.FormDesigner.widget.ValidationEditor,
  5. loadStatus: function(tds){
  6. var html = "<table width='100%' border='0' cellpadding='0' cellspacing='0'><tr>" +
  7. "<td width='140px'>"+"<input type='radio' value='all' checked />"+this.designer.lp.validation.anytime+
  8. "<input type='radio' value='publish' />"+this.designer.lp.validation.publish+"</td>" +
  9. //"<td><input type='text' value='"+this.designer.lp.validation.decisionName+"'></td>" +
  10. "</tr></table>";
  11. tds[0].set("html", html);
  12. var inputs = tds[0].getElements("input");
  13. var randomId = new MWF.widget.UUID().toString();
  14. inputs[0].set("name", "condition"+randomId);
  15. inputs[1].set("name", "condition"+randomId);
  16. //inputs[2].setStyles(this.css.decisionNameInput);
  17. //this.decisionInputNode = inputs[2];
  18. this.statusRadioNodes = inputs;
  19. //this.statusRadioNodes.pop();
  20. //this.decisionInputNode.addEvents({
  21. // "focus": function(){
  22. // if (this.decisionInputNode.get("value")==this.designer.lp.validation.decisionName) this.decisionInputNode.set("value", "");
  23. // }.bind(this),
  24. // "blur": function(){
  25. // if (!this.decisionInputNode.get("value")) this.decisionInputNode.set("value", this.designer.lp.validation.decisionName);
  26. // }.bind(this)
  27. //});
  28. },
  29. getData: function(){
  30. var status = this.getStatusValue();
  31. //var decision = this.decisionInputNode.get("value");
  32. var valueType = this.valueTypeSelectNode.options[this.valueTypeSelectNode.selectedIndex].value;
  33. var operateor = this.operateorSelectNode.options[this.operateorSelectNode.selectedIndex].value;
  34. var value = this.valueInputNode.get("value");
  35. var prompt = this.promptInputNode.get("value");
  36. //if (decision == this.designer.lp.validation.decisionName) decision = "";
  37. if (value == this.designer.lp.validation.valueInput) value = "";
  38. return {
  39. "status": status,
  40. //"decision": decision,
  41. "valueType": valueType,
  42. "operateor": operateor,
  43. "value": value,
  44. "prompt": prompt
  45. };
  46. },
  47. addValidation: function(){
  48. this.hideErrorNode();
  49. var data = this.getData();
  50. //if (data.status!="all"){
  51. // if (!data.decision || data.decision==this.designer.lp.validation.decisionName){
  52. // this.showErrorNode(this.designer.lp.validation.inputDecisionName);
  53. // return false;
  54. // }
  55. //}
  56. if (data.operateor!="isnull" && data.operateor!="notnull"){
  57. if (!data.value || data.value==this.designer.lp.validation.valueInput){
  58. this.showErrorNode(this.designer.lp.validation.inputValue);
  59. return false;
  60. }
  61. }
  62. if (!data.prompt){
  63. this.showErrorNode(this.designer.lp.validation.inputPrompt);
  64. return false;
  65. }
  66. var item = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor.Item(data, this);
  67. this.items.push(item);
  68. item.selected();
  69. this.fireEvent("change");
  70. },
  71. modifyValidation: function(){
  72. if (this.currentItem){
  73. this.hideErrorNode();
  74. var data = this.getData();
  75. //if (data.status!="all"){
  76. // if (!data.decision || data.decision==this.designer.lp.validation.decisionName){
  77. // this.showErrorNode(this.designer.lp.validation.inputDecisionName);
  78. // return false;
  79. // }
  80. //}
  81. if (data.operateor!="isnull" && data.operateor!="notnull"){
  82. if (!data.value || data.value==this.designer.lp.validation.valueInput){
  83. this.showErrorNode(this.designer.lp.validation.inputValue);
  84. return false;
  85. }
  86. }
  87. if (!data.prompt){
  88. this.showErrorNode(this.designer.lp.validation.inputPrompt);
  89. return false;
  90. }
  91. this.currentItem.reload(data);
  92. this.currentItem.unSelected();
  93. this.disabledModify();
  94. this.fireEvent("change");
  95. }
  96. },
  97. loadListNode: function(data){
  98. if (data){
  99. if (data.length){
  100. data.each(function(itemData){
  101. var item = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor.Item(itemData, this);
  102. this.items.push(item);
  103. }.bind(this));
  104. }
  105. }
  106. },
  107. setData: function(data){
  108. //if (data.decision) this.decisionInputNode.set("value", data.decision);
  109. if (data.status){
  110. for (var i=0; i<this.statusRadioNodes.length; i++){
  111. if (data.status == this.statusRadioNodes[i].get("value")){
  112. this.statusRadioNodes[i].set("checked", true);
  113. break;
  114. }
  115. }
  116. }else{
  117. this.statusRadioNodes[0].set("checked", true);
  118. }
  119. for (var i=0; i<this.valueTypeSelectNode.options.length; i++){
  120. if (data.valueType == this.valueTypeSelectNode.options[i].get("value")){
  121. this.valueTypeSelectNode.options[i].set("selected", true);
  122. break;
  123. }
  124. }
  125. for (var i=0; i<this.operateorSelectNode.options.length; i++){
  126. if (data.operateor == this.operateorSelectNode.options[i].get("value")){
  127. this.operateorSelectNode.options[i].set("selected", true);
  128. break;
  129. }
  130. }
  131. if (data.value) this.valueInputNode.set("value", data.value);
  132. if (data.prompt) this.promptInputNode.set("value", data.prompt);
  133. }
  134. });
  135. MWF.xApplication.cms.FormDesigner.widget.ValidationEditor.Item = new Class({
  136. Extends : MWF.xApplication.process.FormDesigner.widget.ValidationEditor.Item,
  137. getText: function(){
  138. var text = "";
  139. if (this.data.status=="all"){
  140. text = this.lp.validation.anytime+" ";
  141. }else{
  142. text = this.lp.validation.publish ;
  143. }
  144. text += this.lp.validation[this.data.valueType]+" ";
  145. text += this.lp.validation[this.data.operateor]+" ";
  146. text += " \""+this.data.value+"\" ";
  147. text += this.lp.validation.prompt+": \""+this.data.prompt+"\"";
  148. return text;
  149. }
  150. });