SourceText.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. COMMON.AjaxModule.load("JSONTemplate", null, false);
  3. MWF.xApplication.process.Xform.SourceText = MWF.APPSourceText = new Class({
  4. Extends: MWF.APP$Module,
  5. _loadUserInterface: function(){
  6. this._loadJsonData();
  7. },
  8. _getSource: function(){
  9. var parent = this.node.getParent();
  10. while(parent && (parent.get("MWFtype")!="source" && parent.get("MWFtype")!="subSource" && parent.get("MWFtype")!="subSourceItem")) parent = parent.getParent();
  11. return (parent) ? parent.retrieve("module") : null;
  12. },
  13. _loadJsonData: function(){
  14. this.node.set("text", "");
  15. this.source = this._getSource();
  16. if (this.source){
  17. if (this.source.data){
  18. this.template = new Template();
  19. this.text = this.template.substitute("{"+this.json.jsonPath+"}", this.source.data);
  20. if (this.json.jsonText){
  21. if (this.json.jsonText.code){
  22. this.text = this.form.Macro.exec(this.json.jsonText.code, this);
  23. this.node.set("text", this.text);
  24. }else{
  25. this.node.set("text", this.text);
  26. }
  27. }else{
  28. this.node.set("text", this.text);
  29. }
  30. }
  31. }
  32. }
  33. });