Property.js 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419
  1. MWF.require("MWF.widget.Common", null, false);
  2. MWF.require("MWF.widget.JsonTemplate", null, false);
  3. MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
  4. Extends: MWF.widget.Common,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "path": "../x_component_process_FormDesigner/property/property.html"
  9. },
  10. initialize: function(module, propertyNode, designer, options){
  11. this.setOptions(options);
  12. this.module = module;
  13. this.form = module.form;
  14. this.data = module.json;
  15. this.data.pid = this.form.options.mode+this.form.json.id+this.data.id;
  16. this.htmlPath = this.options.path;
  17. this.designer = designer;
  18. this.maplists = {};
  19. this.propertyNode = propertyNode;
  20. },
  21. load: function(){
  22. if (this.fireEvent("queryLoad")){
  23. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  24. this.htmlString = responseText;
  25. this.fireEvent("postLoad");
  26. }.bind(this));
  27. }
  28. this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
  29. },
  30. editProperty: function(td){
  31. },
  32. getHtmlString: function(callback){
  33. if (!this.htmlString){
  34. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  35. this.htmlString = responseText;
  36. if (callback) callback();
  37. }.bind(this));
  38. }else{
  39. if (callback) callback();
  40. }
  41. },
  42. show: function(){
  43. if (!this.propertyContent){
  44. this.getHtmlString(function(){
  45. if (this.htmlString){
  46. this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
  47. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  48. this.propertyContent.set("html", this.JsonTemplate.load());
  49. this.setEditNodeEvent();
  50. this.setEditNodeStyles(this.propertyContent);
  51. this.loadPropertyTab();
  52. this.loadMaplist();
  53. this.loadStylesList();
  54. this.loadDivTemplateType();
  55. this.loadPersonInput();
  56. this.loadFormFieldInput();
  57. this.loadScriptArea();
  58. this.loadCssArea();
  59. this.loadHtmlEditorArea();
  60. this.loadTreeData();
  61. this.loadArrayList();
  62. this.loadEventsEditor();
  63. this.loadActionArea();
  64. this.loadActionStylesArea();
  65. this.loadHTMLArea();
  66. this.loadJSONArea();
  67. this.loadFormSelect();
  68. this.loadSubformSelect();
  69. //this.loadPageSelect();
  70. this.loadWidgetSelect();
  71. this.loadANNModelSelect();
  72. //this.loadViewSelect();
  73. this.loadValidation();
  74. this.loadIconSelect();
  75. this.loadLabelFlagSelect();
  76. this.loadImageClipper();
  77. this.loadImageFileSelect();
  78. this.loadParameterEditor();
  79. this.loadContextRoot();
  80. this.loadUnitTypeSelector();
  81. this.loadSourceTestRestful();
  82. this.loadSidebarPosition();
  83. this.loadViewFilter();
  84. this.loadStatementFilter();
  85. this.loadDocumentTempleteSelect();
  86. // this.loadScriptIncluder();
  87. // this.loadDictionaryIncluder();
  88. //this.testRestful();
  89. // this.loadScriptInput();
  90. //MWF.process.widget.EventsEditor
  91. }
  92. }.bind(this));
  93. }else{
  94. this.propertyContent.setStyle("display", "block");
  95. }
  96. (new Fx.Scroll(layout.desktop.node)).toTop();
  97. },
  98. hide: function(){
  99. //this.JsonTemplate = null;
  100. //this.propertyNode.set("html", "");
  101. if (this.propertyContent) this.propertyContent.setStyle("display", "none");
  102. },
  103. destroy: function(){
  104. if (this.propertyContent){
  105. this.propertyContent.destroy();
  106. }
  107. MWF.release(this);
  108. },
  109. loadTreeData: function(){
  110. var arrays = this.propertyContent.getElements(".MWFTreeData");
  111. arrays.each(function(node){
  112. var title = node.get("title");
  113. var name = node.get("name");
  114. var json = this.data[name];
  115. if (!json) json = [];
  116. MWF.require("MWF.widget.TreeEditor", function(){
  117. var treeEditor = new MWF.widget.TreeEditor(node, {
  118. "title": title,
  119. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  120. "onChange": function(){
  121. this.data[name] = treeEditor.toJson();
  122. this.module.json[name] = this.data[name];
  123. this.module._refreshTree();
  124. }.bind(this)
  125. });
  126. treeEditor.load(json);
  127. }.bind(this));
  128. node.addEvent("keydown", function(e){e.stopPropagation();});
  129. }.bind(this));
  130. },
  131. loadJSONArea: function(){
  132. var jsonNode = this.propertyContent.getElement(".MWFJSONArea");
  133. if (jsonNode){
  134. this.propertyTab.pages.each(function(page){
  135. if (page.contentNode === jsonNode.parentElement){
  136. page.setOptions({
  137. "onShow": function(){
  138. jsonNode.empty();
  139. MWF.require("MWF.widget.JsonParse", function(){
  140. this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
  141. this.json.load();
  142. }.bind(this));
  143. }.bind(this)
  144. });
  145. }
  146. }.bind(this));
  147. }
  148. },
  149. loadHTMLArea: function(){
  150. var htmlNode = this.propertyContent.getElement(".MWFHTMLArea");
  151. if (htmlNode){
  152. var copy = this.module.node.clone(true, true);
  153. copy.clearStyles(true);
  154. htmlNode.set("text", copy.outerHTML);
  155. copy.destroy();
  156. this.propertyTab.pages.each(function(page){
  157. if (page.contentNode == htmlNode.parentElement){
  158. page.setOptions({
  159. "onShow": function(){
  160. var copy = this.module.node.clone(true, true);
  161. copy.clearStyles(true);
  162. //MWF.require("MWF.widget.HtmlEditor", function(){
  163. // debugger;
  164. // var editor = new MWF.widget.HtmlEditor(htmlNode);
  165. // editor.load(function(){
  166. // editor.editor.setValue(copy.outerHTML)
  167. // }.bind(this));
  168. //}.bind(this));
  169. o2.load("JSBeautifier_html", function(){
  170. htmlNode.set("text", html_beautify(copy.outerHTML, {"indent_size":1}));
  171. }.bind(this));
  172. o2.require("o2.widget.ace", function(){
  173. MWF.widget.ace.load(function(){
  174. COMMON.AjaxModule.loadDom("../o2_lib/ace/src-min-noconflict/ext-static_highlight.js", function(){
  175. var highlight = ace.require("ace/ext/static_highlight");
  176. highlight(htmlNode, {mode: "ace/mode/html", theme: "ace/theme/eclipse", "fontSize": 16});
  177. }.bind(this));
  178. }.bind(this));
  179. }.bind(this));
  180. copy.destroy();
  181. }.bind(this)
  182. });
  183. }
  184. }.bind(this));
  185. }
  186. },
  187. loadSidebarPosition: function(){
  188. var nodes = this.propertyContent.getElements(".MWFSidebarReposition");
  189. if (nodes.length){
  190. nodes.each(function(node){
  191. node.addEvent("click", function(){
  192. this.module.json.styles.top = "";
  193. this.module.loadPosition();
  194. }.bind(this));
  195. }.bind(this));
  196. }
  197. },
  198. loadANNModelSelect: function(){
  199. var nodes = this.propertyContent.getElements(".MWFANNModelSelect");
  200. if (nodes.length){
  201. this.getModelList(function(){
  202. nodes.each(function(node){
  203. var select = new Element("select").inject(node);
  204. select.addEvent("change", function(e){
  205. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  206. }.bind(this));
  207. this.setModelSelectOptions(node, select);
  208. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  209. refreshNode.addEvent("click", function(e){
  210. this.getModelList(function(){
  211. this.setModelSelectOptions(node, select);
  212. }.bind(this), true);
  213. }.bind(this));
  214. }.bind(this));
  215. }.bind(this));
  216. }
  217. },
  218. getModelList: function(callback, refresh){
  219. if (!this.models || refresh){
  220. var action = o2.Actions.get("x_query_assemble_designer");
  221. if (action.listModel) action.listModel(function(json){
  222. this.models = json.data;
  223. if (callback) callback();
  224. }.bind(this));
  225. }else{
  226. if (callback) callback();
  227. }
  228. },
  229. setModelSelectOptions: function(node, select){
  230. var name = node.get("name");
  231. select.empty();
  232. var option = new Element("option", {"text": "none"}).inject(select);
  233. this.models.each(function(model){
  234. var option = new Element("option", {
  235. "text": model.name,
  236. "value": model.id,
  237. "selected": (this.data[name]==model.id)
  238. }).inject(select);
  239. }.bind(this));
  240. },
  241. loadFormSelect: function(){
  242. var formNodes = this.propertyContent.getElements(".MWFFormSelect");
  243. if (formNodes.length){
  244. this.getFormList(function(){
  245. formNodes.each(function(node){
  246. var select = new Element("select").inject(node);
  247. select.addEvent("change", function(e){
  248. var value = e.target.options[e.target.selectedIndex].value;
  249. this.setValue(e.target.getParent("div").get("name"), value, select);
  250. }.bind(this));
  251. this.setFormSelectOptions(node, select);
  252. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  253. refreshNode.addEvent("click", function(e){
  254. this.getFormList(function(){
  255. this.setFormSelectOptions(node, select);
  256. }.bind(this), true);
  257. }.bind(this));
  258. //select.addEvent("click", function(e){
  259. // this.setFormSelectOptions(node, select);
  260. //}.bind(this));
  261. }.bind(this));
  262. }.bind(this));
  263. }
  264. },
  265. setFormSelectOptions: function(node, select){
  266. var name = node.get("name");
  267. select.empty();
  268. var option = new Element("option", {"text": "none"}).inject(select);
  269. this.forms.each(function(form){
  270. if( this.form.json.id !== form.id ){
  271. var option = new Element("option", {
  272. "text": form.name,
  273. "value": form.id,
  274. "selected": (this.data[name]==form.id)
  275. }).inject(select);
  276. }
  277. }.bind(this));
  278. },
  279. getFormList: function(callback, refresh){
  280. if (!this.forms || refresh){
  281. this.form.designer.actions.listForm(this.form.designer.application.id, function(json){
  282. this.forms = json.data;
  283. if (callback) callback();
  284. }.bind(this));
  285. }else{
  286. if (callback) callback();
  287. }
  288. },
  289. loadSubformSelect: function(){
  290. var subformContainers = this.propertyContent.getElements(".MWFSubFormSelectContainer");
  291. if (subformContainers.length){
  292. subformContainers.each( function( container ){
  293. var appSelectNode = container.getElement(".MWFSubformAppSelect");
  294. var formSelectNode = container.getElement(".MWFSubformSelect");
  295. var formSelect;
  296. var appNodeName = appSelectNode.get("name");
  297. var formNodeName = formSelectNode.get("name");
  298. this.loadProcessApplictionSelect( appSelectNode, appNodeName, function( apps ){
  299. var oldValue = this.data[appNodeName] || "";
  300. this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
  301. if( oldValue !== this.data[appNodeName] ){
  302. this.getSubFormList(function(){
  303. this.setSubformSelectOptions(formSelectNode, formSelect);
  304. formSelect.fireEvent("change");
  305. }.bind(this), true, appNodeName);
  306. }
  307. }.bind(this));
  308. formSelect = this._loadSubformSelect( formSelectNode, formNodeName, appNodeName ) ;
  309. }.bind(this))
  310. }
  311. },
  312. loadProcessApplictionSelect : function( node, appNodeName, callback ){
  313. var application = appNodeName ? this.data[appNodeName] : "";
  314. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
  315. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  316. "title" : this.form.designer.lp.selectApplication,
  317. "type": "application",
  318. "count" : 1,
  319. "names": application ? [ {id : application} ] : [],
  320. "onChange": function (apps) {
  321. callback(apps)
  322. }.bind(this)
  323. });
  324. }.bind(this))
  325. },
  326. _loadSubformSelect : function( node, formNodeName, appNodeName ){
  327. var select;
  328. this.getSubFormList(function(){
  329. select = new Element("select").inject(node);
  330. select.addEvent("change", function(e){
  331. var value = select.options[select.selectedIndex].value;
  332. this.setValue(formNodeName, value, select);
  333. }.bind(this));
  334. this.setSubformSelectOptions(node, select);
  335. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  336. refreshNode.addEvent("click", function(e){
  337. this.getSubFormList(function(){
  338. this.setSubformSelectOptions(node, select);
  339. }.bind(this), true, appNodeName);
  340. }.bind(this));
  341. }.bind(this), false, appNodeName );
  342. return select;
  343. },
  344. setSubformSelectOptions: function(node, select){
  345. var name = node.get("name");
  346. select.empty();
  347. var option = new Element("option", {"text": "none"}).inject(select);
  348. this.subforms.each(function(subforms){
  349. if( this.form.json.id !== subforms.id ){
  350. var option = new Element("option", {
  351. "text": subforms.name,
  352. "value": subforms.id,
  353. "selected": (this.data[name]==subforms.id)
  354. }).inject(select);
  355. }
  356. }.bind(this));
  357. },
  358. getSubFormList: function(callback, refresh, appNodeName){
  359. var application = appNodeName ? this.data[appNodeName] : "";
  360. if (!this.subforms || refresh){
  361. this.form.designer.actions.listForm( application || this.form.designer.application.id, function(json){
  362. this.subforms = json.data;
  363. if (callback) callback();
  364. }.bind(this), null, false);
  365. }else{
  366. if (callback) callback();
  367. }
  368. },
  369. loadPageSelect: function(){
  370. var pageNodes = this.propertyContent.getElements(".MWFPageSelect");
  371. if (pageNodes.length){
  372. this.getPageList(function(){
  373. pageNodes.each(function(node){
  374. var select = new Element("select").inject(node);
  375. select.addEvent("change", function(e){
  376. var value = e.target.options[e.target.selectedIndex].value;
  377. this.setValue(e.target.getParent("div").get("name"), value, select);
  378. }.bind(this));
  379. this.setPageSelectOptions(node, select);
  380. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  381. refreshNode.addEvent("click", function(e){
  382. this.getPageList(function(){
  383. this.setPageSelectOptions(node, select);
  384. }.bind(this), true);
  385. }.bind(this));
  386. }.bind(this));
  387. }.bind(this));
  388. }
  389. },
  390. setPageSelectOptions: function(node, select){
  391. var name = node.get("name");
  392. select.empty();
  393. var option = new Element("option", {"text": "none"}).inject(select);
  394. this.pages.each(function(page){
  395. if( this.form.json.id !== page.id ){
  396. var option = new Element("option", {
  397. "text": page.name,
  398. "value": page.id,
  399. "selected": (this.data[name]==page.id)
  400. }).inject(select);
  401. }
  402. }.bind(this));
  403. },
  404. getPageList: function(callback, refresh){
  405. if (!this.pages || refresh){
  406. this.form.designer.actions.listPage(this.form.designer.application.id, function(json){
  407. this.pages = json.data;
  408. if (callback) callback();
  409. }.bind(this));
  410. }else{
  411. if (callback) callback();
  412. }
  413. },
  414. loadWidgetSelect: function(){
  415. var widgetNodes = this.propertyContent.getElements(".MWFWidgetSelect");
  416. if (widgetNodes.length){
  417. this.getWidgetList(function(){
  418. widgetNodes.each(function(node){
  419. var select = new Element("select").inject(node);
  420. select.addEvent("change", function(e){
  421. var value = e.target.options[e.target.selectedIndex].value;
  422. this.setValue(e.target.getParent("div").get("name"), value, select);
  423. }.bind(this));
  424. this.setWidgetSelectOptions(node, select);
  425. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  426. refreshNode.addEvent("click", function(e){
  427. this.getWidgetList(function(){
  428. this.setWidgetSelectOptions(node, select);
  429. }.bind(this), true);
  430. }.bind(this));
  431. }.bind(this));
  432. }.bind(this));
  433. }
  434. },
  435. setWidgetSelectOptions: function(node, select){
  436. var name = node.get("name");
  437. select.empty();
  438. var option = new Element("option", {"text": "none"}).inject(select);
  439. this.widgets.each(function(widget){
  440. if( this.form.json.id !== widget.id ){
  441. var option = new Element("option", {
  442. "text": widget.name,
  443. "value": widget.id,
  444. "selected": (this.data[name]==widget.id)
  445. }).inject(select);
  446. }
  447. }.bind(this));
  448. },
  449. getWidgetList: function(callback, refresh){
  450. if (!this.widgets || refresh){
  451. this.form.designer.actions.listWidget(this.form.designer.application.id, function(json){
  452. this.widgets = json.data;
  453. if (callback) callback();
  454. }.bind(this));
  455. }else{
  456. if (callback) callback();
  457. }
  458. },
  459. // clearStyles: function(node){
  460. // node.removeProperty("style");
  461. // var subNode = node.getFirst();
  462. // while (subNode){
  463. // this.clearStyles(subNode);
  464. // subNode = subNode.getNext();
  465. // }
  466. // },
  467. loadDocumentTempleteSelect: function(){
  468. var nodes = this.propertyContent.getElements(".MWFDocumentTempleteSelect");
  469. if (nodes.length){
  470. o2.getJSON("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
  471. nodes.each(function(node){
  472. var name = node.get("name");
  473. Object.each(json, function(o, k){
  474. new Element("option", {
  475. "text": o.name,
  476. "value": k,
  477. "selected": (this.data[name]==k)
  478. }).inject(node);
  479. }.bind(this));
  480. node.addEvent("change", function(e){
  481. var oldValue = this.data[name];
  482. var value = e.target.options[e.target.selectedIndex].value;
  483. var name = e.target.options[e.target.selectedIndex].get("text");
  484. this.changeJsonDate([name], value);
  485. this.changeData(name, node, oldValue);
  486. }.bind(this));
  487. }.bind(this));
  488. }.bind(this));
  489. }
  490. },
  491. loadStatementFilter: function(){
  492. debugger;
  493. var nodes = this.propertyContent.getElements(".MWFStatementFilter");
  494. var filtrData = this.data.filterList;
  495. nodes.each(function(node){
  496. MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilter", function(){
  497. var _slef = this;
  498. this.viewFilter = new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null, "parameterData": null}, {
  499. "statementId" : this.data.queryStatement ? this.data.queryStatement.id : "",
  500. "withForm" : true,
  501. "onChange": function(ids){
  502. var data = this.getData();
  503. _slef.changeJsonDate(["filterList"], data.filterData);
  504. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  505. }
  506. });
  507. }.bind(this));
  508. }.bind(this));
  509. },
  510. loadViewFilter: function(){
  511. var nodes = this.propertyContent.getElements(".MWFViewFilter");
  512. var filtrData = this.data.filterList;
  513. nodes.each(function(node){
  514. MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
  515. var _slef = this;
  516. new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
  517. "onChange": function(ids){
  518. var data = this.getData();
  519. _slef.changeJsonDate(["filterList"], data.data);
  520. //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
  521. }
  522. });
  523. }.bind(this));
  524. }.bind(this));
  525. },
  526. loadViewSelect: function(){
  527. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  528. if (viewNodes.length){
  529. this.getViewList(function(){
  530. viewNodes.each(function(node){
  531. var select = new Element("select").inject(node);
  532. select.addEvent("change", function(e){
  533. var viewId = e.target.options[e.target.selectedIndex].value;
  534. var viewName = e.target.options[e.target.selectedIndex].get("text");
  535. this.setValue(e.target.getParent("div").get("name"), viewId);
  536. this.setValue(e.target.getParent("div").get("name")+"Name", viewName);
  537. }.bind(this));
  538. this.setViewSelectOptions(node, select);
  539. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  540. refreshNode.addEvent("click", function(e){
  541. this.getViewList(function(){
  542. this.setViewSelectOptions(node, select);
  543. }.bind(this), true);
  544. }.bind(this));
  545. //select.addEvent("click", function(e){
  546. // this.setFormSelectOptions(node, select);
  547. //}.bind(this));
  548. }.bind(this));
  549. }.bind(this));
  550. }
  551. },
  552. setViewSelectOptions: function(node, select){
  553. var name = node.get("name");
  554. select.empty();
  555. var option = new Element("option", {"text": "none"}).inject(select);
  556. this.views.each(function(view){
  557. var option = new Element("option", {
  558. "text": view.name,
  559. "value": view.id,
  560. "selected": (this.data[name]==view.id)
  561. }).inject(select);
  562. }.bind(this));
  563. },
  564. getViewList: function(callback, refresh){
  565. if (!this.views || refresh){
  566. this.form.designer.actions.listView(this.form.designer.application.id, function(json){
  567. this.views = json.data;
  568. if (callback) callback();
  569. }.bind(this));
  570. }else{
  571. if (callback) callback();
  572. }
  573. },
  574. loadValidation: function(){
  575. var nodes = this.propertyContent.getElements(".MWFValidation");
  576. if (nodes.length){
  577. nodes.each(function(node){
  578. var name = node.get("name");
  579. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ValidationEditor", function(){
  580. var validationEditor = new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer, {
  581. "onChange": function(){
  582. var data = validationEditor.getValidationData();
  583. this.data[name] = data;
  584. }.bind(this)
  585. });
  586. validationEditor.load(this.data[name])
  587. }.bind(this));
  588. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  589. }.bind(this));
  590. }
  591. },
  592. loadIconSelect: function(){
  593. var nodes = this.propertyContent.getElements(".MWFIcon");
  594. if (nodes.length){
  595. nodes.each(function(node){
  596. var id = node.get("name");
  597. var icon = this.data[id];
  598. var iconNode = new Element("div", {"styles": this.form.css.processIconNode}).inject(node);
  599. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  600. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectIcon}).inject(node);
  601. selectNode.addEvent("click", function(){
  602. this.selectIcon(node);
  603. }.bind(this));
  604. }.bind(this));
  605. }
  606. },
  607. selectIcon: function(node){
  608. if (!node.iconMenu){
  609. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
  610. iconSelectMenu.load();
  611. node.iconMenu = iconSelectMenu;
  612. var _self = this;
  613. for (var i=0; i<=48; i++){
  614. var icon = "../x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
  615. var item = iconSelectMenu.addMenuItem("", "click", function(){
  616. var id = node.get("name");
  617. var src = this.item.getElement("img").get("src");
  618. _self.data[id] = src;
  619. node.getFirst("div").setStyle("background-image", "url("+src+")");
  620. }, icon);
  621. item.iconName = icon;
  622. }
  623. }
  624. },
  625. loadLabelFlagSelect: function(){
  626. var nodes = this.propertyContent.getElements(".MWFLabelFlag");
  627. if (nodes.length){
  628. nodes.each(function(node){
  629. var id = node.get("name");
  630. var icon = this.data[id];
  631. var iconNode = new Element("div", {"styles": this.form.css.labelFlagNode}).inject(node);
  632. if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
  633. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.empty}).inject(node);
  634. selectNode.addEvent("click", function(e){
  635. var id = node.get("name");
  636. this.data[id] = "";
  637. node.getFirst("div").setStyle("background-image", "");
  638. this.changeData(id);
  639. e.stopPropagation();
  640. }.bind(this));
  641. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.select}).inject(node);
  642. selectNode.addEvent("click", function(){
  643. this.selectLabelFlag(node);
  644. }.bind(this));
  645. }.bind(this));
  646. }
  647. },
  648. selectLabelFlag: function(node){
  649. if (!node.iconMenu){
  650. var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "labelFlag"});
  651. iconSelectMenu.load();
  652. node.iconMenu = iconSelectMenu;
  653. var _self = this;
  654. for (var i=1; i<=21; i++){
  655. var icon = "../x_component_process_FormDesigner/Module/Label/default/icon/flag/"+i+".png";
  656. var item = iconSelectMenu.addMenuItem("", "click", function(){
  657. var id = node.get("name");
  658. var src = this.item.getElement("img").get("src");
  659. _self.data[id] = src;
  660. node.getFirst("div").setStyle("background-image", "url("+src+")");
  661. _self.changeData(id);
  662. }, icon);
  663. item.iconName = icon;
  664. }
  665. }
  666. },
  667. loadImageFileSelect: function(){
  668. // var nodes = this.propertyContent.getElements(".MWFImageFileSelect");
  669. // if (nodes.length){
  670. //
  671. //
  672. //
  673. //
  674. // this.getFileList(function(){
  675. // nodes.each(function(node){
  676. // var select = new Element("select").inject(node);
  677. // select.addEvent("change", function(e){
  678. // this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
  679. //
  680. // }.bind(this));
  681. // this.setFileSelectOptions(node, select);
  682. //
  683. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  684. // refreshNode.addEvent("click", function(e){
  685. // this.getFileList(function(){
  686. // this.setFileSelectOptions(node, select);
  687. // }.bind(this), true);
  688. // }.bind(this));
  689. // }.bind(this));
  690. // }.bind(this));
  691. // }
  692. },
  693. setFileSelectOptions: function(node, select){
  694. var name = node.get("name");
  695. select.empty();
  696. var option = new Element("option", {"text": "none"}).inject(select);
  697. this.files.each(function(file){
  698. var option = new Element("option", {
  699. "text": file.name,
  700. "value": file.id,
  701. "selected": (this.data[name]==file.id)
  702. }).inject(select);
  703. }.bind(this));
  704. },
  705. getFileList: function(callback, refresh){
  706. if (!this.files || refresh){
  707. this.form.designer.actions.listFile(this.form.designer.application.id, function(json){
  708. this.files = json.data;
  709. if (callback) callback();
  710. }.bind(this));
  711. }else{
  712. if (callback) callback();
  713. }
  714. },
  715. loadImageClipper: function(){
  716. var nodes = this.propertyContent.getElements(".MWFImageClipper");
  717. if (nodes.length){
  718. nodes.each(function(node){
  719. var id = node.get("name");
  720. var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectImage}).inject(node);
  721. selectNode.addEvent("click", function(){
  722. this.selectImage(node, id);
  723. }.bind(this));
  724. }.bind(this));
  725. }
  726. },
  727. createUploadFileAreaNode: function(node, name){
  728. this.uploadFileAreaNode = new Element("div");
  729. var html = "<input name=\"file\" multiple type=\"file\" accept=\"images/*\" />";
  730. this.uploadFileAreaNode.set("html", html);
  731. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  732. this.fileUploadNode.addEvent("change", function(){
  733. //var fileId = attachment.data.id;
  734. var files = this.fileUploadNode.files;
  735. if (files.length){
  736. var count = files.length;
  737. for (var i = 0; i < files.length; i++) {
  738. var file = files.item(i);
  739. var formData = new FormData();
  740. formData.append('file', file);
  741. MWF.xDesktop.uploadImage(
  742. this.form.json.id,
  743. (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  744. formData,
  745. file,
  746. function(json){
  747. var id = json.id;
  748. var src = MWF.xDesktop.getImageSrc(id);
  749. var data = {"imageSrc": src, "imageId": id};
  750. this.changeJsonDate(name, data);
  751. this.changeData(name, node, null);
  752. }.bind(this)
  753. );
  754. }
  755. }
  756. }.bind(this));
  757. },
  758. selectImage: function(node, name){
  759. if (!this.uploadFileAreaNode){
  760. this.createUploadFileAreaNode(node, name);
  761. }
  762. //this.fileUploadNode.set("accept", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
  763. this.fileUploadNode.set("multiple", false);
  764. var fileNode = this.uploadFileAreaNode.getFirst();
  765. fileNode.set("accept", ".png,.jpg,.bmp,.gif,.jpeg,.jpe");
  766. fileNode.click();
  767. //MWF.xDesktop.requireApp("process.FormDesigner", "widget.ImageClipper", function(){
  768. // var size = this.module.node.getSize();
  769. // var image = new MWF.xApplication.process.FormDesigner.widget.ImageClipper(this.designer, {
  770. // "title": this.form.designer.lp.selectImage,
  771. // "width": (this.data.styles.width) ? size.x : 0,
  772. // "height": (this.data.styles.height) ? size.y : 0,
  773. // "imageUrl" : this.data.imageSrc,
  774. // "reference" : this.form.json.id,
  775. // "referenceType": (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
  776. // "onChange": function(){
  777. // var data = {"imageSrc": image.imageSrc, "imageId": image.imageId};
  778. // this.changeJsonDate(name, data);
  779. // this.changeData(name, node, null);
  780. // }.bind(this)
  781. // });
  782. // image.load(this.data[name])
  783. //}.bind(this));
  784. },
  785. loadEventsEditor: function(){
  786. var events = this.propertyContent.getElement(".MWFEventsArea");
  787. if (events){
  788. var name = events.get("name");
  789. var eventsObj = this.data[name];
  790. MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
  791. var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
  792. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  793. "maxObj": this.designer.formContentNode || this.designer.pageContentNode
  794. });
  795. eventsEditor.load(eventsObj, this.data, name);
  796. }.bind(this));
  797. }
  798. },
  799. testRestful: function(){
  800. var node = this.propertyContent.getElements(".MWFTestRestful");
  801. if (node){
  802. var resultNode = node.getLast();
  803. node.getFirst().addEvent("click", function(){
  804. }.bind(this));
  805. }
  806. },
  807. loadContextRoot: function(){
  808. var nodes = this.propertyContent.getElements(".MWFContextRoot");
  809. if (nodes){
  810. nodes.each(function(node){
  811. var name = node.get("name");
  812. var selects = node.getElements("select");
  813. var rootSelect = selects[0];
  814. var actionSelect = selects[1];
  815. var methodSelect = selects[2];
  816. var pathInput = node.getElement("input");
  817. //var select = new Element("select").inject(node);
  818. //var methodSelect = new Element("select").inject(node);
  819. debugger;
  820. var getValue = function(){
  821. var v;
  822. try {
  823. v = JSON.parse(this.data[name]);
  824. }catch(e){
  825. v = {"root": this.data[name], "action":"", "method": "", "uri": ""};
  826. }
  827. return v
  828. }.bind(this);
  829. var value = getValue();
  830. var resetRootSelects = function(){
  831. var root = rootSelect.options[rootSelect.selectedIndex].value;
  832. var action = o2.Actions.load(root);
  833. actionSelect.empty();
  834. methodSelect.empty();
  835. pathInput.set("value", "");
  836. var value = getValue();
  837. Object.each(action, function(o, key){
  838. var option = new Element("option", {"value": key, "text": key, "selected": (value.action==key)}).inject(actionSelect);
  839. });
  840. return JSON.stringify({"root": root, "action":"", "method": "", "uri": ""});
  841. };
  842. var resetActionSelects = function(){
  843. var root = rootSelect.options[rootSelect.selectedIndex].value;
  844. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  845. var action = o2.Actions.load(root);
  846. methodSelect.empty();
  847. pathInput.set("value", "");
  848. var value = getValue();
  849. Object.each(action[actionName].action.actions, function(o, key){
  850. var option = new Element("option", {"value": key, "text": key, "selected": (value.method==key)}).inject(methodSelect);
  851. });
  852. return JSON.stringify({"root": root, "action":actionName, "method": "", "uri": ""});
  853. };
  854. var resetMethodSelects = function(){
  855. var root = rootSelect.options[rootSelect.selectedIndex].value;
  856. var actionName = actionSelect.options[actionSelect.selectedIndex].value;
  857. var methodName = methodSelect.options[methodSelect.selectedIndex].value;
  858. var action = o2.Actions.load(root);
  859. var uri = action[actionName].action.actions[methodName].uri;
  860. pathInput.set("value", uri);
  861. return JSON.stringify({"root": root, "action":actionName, "method": methodName, "uri": uri});
  862. };
  863. Object.each(layout.serviceAddressList, function(v, key){
  864. var option = new Element("option", {"value": key, "text": v.name, "selected": (value.root==key)}).inject(rootSelect);
  865. }.bind(this));
  866. resetRootSelects()
  867. resetActionSelects();
  868. resetMethodSelects();
  869. rootSelect.addEvent("change", function(){
  870. resetRootSelects();
  871. resetActionSelects();
  872. var data = resetMethodSelects();
  873. this.changeJsonDate(name, data);
  874. this.changeData(name, node, value);
  875. }.bind(this));
  876. actionSelect.addEvent("change", function(){
  877. resetActionSelects();
  878. var data = resetMethodSelects();
  879. this.changeJsonDate(name, data);
  880. this.changeData(name, node, value);
  881. }.bind(this));
  882. methodSelect.addEvent("change", function(){
  883. var data = resetMethodSelects();
  884. this.changeJsonDate(name, data);
  885. this.changeData(name, node, value);
  886. }.bind(this));
  887. }.bind(this));
  888. }
  889. },
  890. loadSourceTestRestful: function(){
  891. var nodes = this.propertyContent.getElements(".MWFSourceTestRestful");
  892. if (nodes.length){
  893. nodes.each(function(node){
  894. var button = node.getFirst();
  895. var content = node.getLast();
  896. //var button = new Element("input", {"type": "button", "value": "Test"}).inject(node);
  897. button.addEvent("click", function(e){
  898. this.testSourceRestful(content);
  899. }.bind(this));
  900. }.bind(this));
  901. }
  902. },
  903. testSourceRestful: function(content){
  904. var service;
  905. try {
  906. service = JSON.parse(this.module.json.contextRoot);
  907. }catch(e){
  908. service = {"root": this.module.json.contextRoot, "action":"", "method": "", "url": ""};
  909. }
  910. var address = this._getO2Address(service.root);
  911. var uri = this._getO2Uri(this.module, address);
  912. this._invoke(this.module, uri, function(json){
  913. content.empty();
  914. MWF.require("MWF.widget.JsonParse", function(){
  915. var jsonParse = new MWF.widget.JsonParse(json, content, null);
  916. jsonParse.load();
  917. }.bind(this));
  918. }.bind(this));
  919. },
  920. _getO2Address: function(contextRoot){
  921. var addressObj = layout.serviceAddressList[contextRoot];
  922. var address = "";
  923. if (addressObj){
  924. address = layout.config.app_protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;
  925. }else{
  926. var host = layout.desktop.centerServer.host || window.location.hostname;
  927. var port = layout.desktop.centerServer.port;
  928. address = layout.config.app_protocol+"//"+host+(port=="80" ? "" : ":"+port)+"/x_program_center";
  929. }
  930. return address;
  931. },
  932. _getO2Uri: function(module, address){
  933. //var uri = module.json.path || module.json.selectPath;
  934. var uri = module.json.path;
  935. var pars = {};
  936. MWF.require("MWF.xScript.Macro", null, false);
  937. var macro = new MWF.Macro["PageContext"]({"businessData": {}, "json": {}, "options": {}});
  938. if (module.json.parameters){
  939. Object.each(module.json.parameters, function(v, key){
  940. if (uri.indexOf("{"+key+"}")!==-1){
  941. var reg = new RegExp("{"+key+"}", "g");
  942. uri = uri.replace(reg, encodeURIComponent((v && v.code) ? (macro.exec(v.code, this) || "") : v));
  943. }else{
  944. pars[key] = v;
  945. }
  946. }.bind(this));
  947. }
  948. var data = null;
  949. if (module.json.requestBody){
  950. if (module.json.requestBody.code){
  951. data = macro.exec(module.json.requestBody.code, this)
  952. }
  953. }
  954. if (module.json.httpMethod==="GET" || module.json.httpMethod==="OPTIONS" || module.json.httpMethod==="HEAD" || module.json.httpMethod==="DELETE"){
  955. var tag = "?";
  956. if (uri.indexOf("?")!==-1) tag = "&";
  957. Object.each(pars, function(v, k){
  958. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  959. uri = uri+tag+k+"="+value;
  960. }.bind(this));
  961. }else{
  962. Object.each(pars, function(v, k){
  963. if (!data) data = {};
  964. var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
  965. data[k] = value;
  966. }.bind(this));
  967. }
  968. this.body = data;
  969. return {"uri": address+uri, "body": data};
  970. },
  971. _invoke: function(module, uri, callback){
  972. MWF.restful(module.json.httpMethod, uri.uri, JSON.encode(uri.body), function(json){
  973. //this.data = json;
  974. if (callback) callback(json);
  975. }.bind(this), true, true);
  976. },
  977. loadUnitTypeSelector: function(){
  978. var nodes = this.propertyContent.getElements(".MWFFormUnitTypeSelector");
  979. if (nodes.length){
  980. this.getUnitTypeList(function(){
  981. nodes.each(function(node){
  982. var select = new Element("select").inject(node);
  983. select.addEvent("change", function(e){
  984. this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
  985. }.bind(this));
  986. this.setUnitTypeSelectOptions(node, select);
  987. this.setValue(select.getParent("div").get("name"), select.options[select.selectedIndex].value);
  988. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
  989. // refreshNode.addEvent("click", function(e){
  990. // this.getUnitTypeList(function(){
  991. // this.setUnitTypeSelectOptions(node, select);
  992. // }.bind(this), true);
  993. // }.bind(this));
  994. }.bind(this));
  995. }.bind(this));
  996. }
  997. },
  998. setUnitTypeSelectOptions: function(node, select){
  999. var name = node.get("name");
  1000. select.empty();
  1001. var option = new Element("option", {"value":"all", "text": this.form.designer.lp.all, "selected": (!this.data[name] || this.data[name]==="all")}).inject(select);
  1002. this.unitTypeList.each(function(unitType){
  1003. var option = new Element("option", {
  1004. "text": unitType,
  1005. "value": unitType,
  1006. "selected": (this.data[name]===unitType)
  1007. }).inject(select);
  1008. }.bind(this));
  1009. },
  1010. getUnitTypeList: function(callback, refresh){
  1011. if (!this.unitTypeList || refresh){
  1012. //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
  1013. // var action = new MWF.xApplication.Org.Actions.RestActions();
  1014. var action = MWF.Actions.get("x_organization_assemble_control");
  1015. action.listUnitType(function(json){
  1016. this.unitTypeList = json.data.valueList;
  1017. if (callback) callback();
  1018. }.bind(this));
  1019. //}.bind(this));
  1020. }else{
  1021. if (callback) callback();
  1022. }
  1023. },
  1024. loadParameterEditor: function(){
  1025. var pars = this.propertyContent.getElements(".MWFParameterArea");
  1026. if (pars){
  1027. pars.each(function(par){
  1028. var name = par.get("name");
  1029. if (!this.data[name]) this.data[name] = {};
  1030. var parObj = this.data[name];
  1031. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ParameterEditor", function(){
  1032. var parameterEditor = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor(par, this.designer, {
  1033. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1034. "maxObj": this.designer.formContentNode
  1035. });
  1036. parameterEditor.load(parObj, this.data, name);
  1037. }.bind(this));
  1038. }.bind(this));
  1039. }
  1040. },
  1041. loadArrayList: function(){
  1042. var arrays = this.propertyContent.getElements(".MWFArraylist");
  1043. arrays.each(function(node){
  1044. var title = node.get("title");
  1045. var name = node.get("name");
  1046. var arr = this.data[name];
  1047. if (!arr) arr = [];
  1048. MWF.require("MWF.widget.Arraylist", function(){
  1049. var arraylist = new MWF.widget.Arraylist(node, {
  1050. "title": title,
  1051. "onChange": function(){
  1052. this.data[name] = arraylist.toArray();
  1053. }.bind(this)
  1054. });
  1055. arraylist.load(arr);
  1056. }.bind(this));
  1057. node.addEvent("keydown", function(e){e.stopPropagation();});
  1058. }.bind(this));
  1059. },
  1060. loadHtmlEditorArea: function(){
  1061. var htmlAreas = this.propertyContent.getElements(".MWFHtmlEditorArea");
  1062. htmlAreas.each(function(node){
  1063. var title = node.get("title");
  1064. var name = node.get("name");
  1065. var scriptContent = this.data[name];
  1066. MWF.require("MWF.widget.HtmlEditorArea", function(){
  1067. var htmlArea = new MWF.widget.HtmlEditorArea(node, {
  1068. "title": title,
  1069. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1070. "maxObj": this.designer.formContentNode,
  1071. "onChange": function(){
  1072. this.data[name] = htmlArea.getValue();
  1073. this.changeData(name);
  1074. htmlArea.isChanged = true;
  1075. }.bind(this),
  1076. // "onBlur": function(){
  1077. // if (htmlArea.isChanged){
  1078. // this.changeData(name, node, "");
  1079. // htmlArea.isChanged = false;
  1080. // }
  1081. // }.bind(this),
  1082. "onSave": function(){
  1083. this.designer.saveForm();
  1084. }.bind(this)
  1085. });
  1086. htmlArea.load({"code": scriptContent});
  1087. }.bind(this));
  1088. }.bind(this));
  1089. },
  1090. loadStylesList: function(){
  1091. var _self = this;
  1092. var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1093. styleSelNodes.each(function(node){
  1094. if (this.module.form.stylesList){
  1095. if (!this.data.formStyleType) this.data.formStyleType = "default";
  1096. var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1097. Object.each(this.module.form.stylesList, function(s, key){
  1098. if( s.mode.contains( mode ) ){
  1099. new Element("option", {
  1100. "text": s.name,
  1101. "value": key,
  1102. "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1103. }).inject(node)
  1104. }
  1105. }.bind(this));
  1106. }else{
  1107. node.getParent("tr").setStyle("display", "none");
  1108. }
  1109. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1110. refreshNode.addEvent("click", function(e){
  1111. _self.changeData(this.get("name"), this );
  1112. }.bind(node));
  1113. }.bind(this));
  1114. },
  1115. // loadStylesList: function(){
  1116. // var _self = this;
  1117. // var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
  1118. // styleSelNodes.each(function(node){
  1119. // if (this.module.form.stylesList){
  1120. // if (!this.data.formStyleType) this.data.formStyleType = "default";
  1121. // var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
  1122. // Object.each(this.module.form.stylesList, function(s, key){
  1123. // if( s.mode.contains( mode ) ){
  1124. // new Element("option", {
  1125. // "text": s.name,
  1126. // "value": key,
  1127. // "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
  1128. // }).inject(node)
  1129. // }
  1130. // }.bind(this));
  1131. // }else{
  1132. // node.getParent("tr").setStyle("display", "none");
  1133. // }
  1134. //
  1135. // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
  1136. // refreshNode.addEvent("click", function(e){
  1137. // _self.changeData(this.get("name"), this );
  1138. // }.bind(node));
  1139. // }.bind(this));
  1140. // },
  1141. loadDivTemplateType: function(){
  1142. var nodes = this.propertyContent.getElements(".MWFDivTemplate");
  1143. if (nodes.length){
  1144. var keys = [];
  1145. //if (this.module.form.stylesList) {
  1146. // if (this.module.form.stylesList[this.module.form.json.formStyleType]){
  1147. // var styles = this.module.form.stylesList[this.module.form.json.formStyleType][this.module.moduleName];
  1148. // if (styles) {
  1149. // Object.each(styles, function (v, k) {
  1150. // keys.push(k);
  1151. // }.bind(this));
  1152. // }
  1153. // }
  1154. //}
  1155. if (this.module.form.templateStyles && this.module.form.templateStyles[this.module.moduleName]) {
  1156. var styles = this.module.form.templateStyles[this.module.moduleName];
  1157. if (styles) {
  1158. Object.each(styles, function (v, k) {
  1159. keys.push(k);
  1160. }.bind(this));
  1161. }
  1162. }
  1163. nodes.each(function(node){
  1164. node.empty();
  1165. new Element("option", {
  1166. "text": "default",
  1167. "value": "default",
  1168. "selected": (!this.data.templateType || this.data.templateType=="default")
  1169. }).inject(node);
  1170. if (keys.length){
  1171. keys.each(function(k){
  1172. new Element("option", {
  1173. "text": styles[k].name,
  1174. "value": k,
  1175. "selected": (this.data.templateType==k)
  1176. }).inject(node)
  1177. }.bind(this));
  1178. }else{
  1179. node.getParent("tr").setStyle("display", "none");
  1180. }
  1181. }.bind(this));
  1182. }
  1183. },
  1184. loadPersonInput: function(){
  1185. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  1186. var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  1187. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  1188. var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
  1189. var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  1190. var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  1191. var queryviewNodes = this.propertyContent.getElements(".MWFQueryViewSelect");
  1192. var queryStatementNodes = this.propertyContent.getElements(".MWFQueryStatementSelect");
  1193. var querystatNodes = this.propertyContent.getElements(".MWFQueryStatSelect");
  1194. var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect");
  1195. var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect");
  1196. var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect");
  1197. var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect");
  1198. var dictionaryNodes = this.propertyContent.getElements(".MWFDictionarySelect");
  1199. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  1200. personIdentityNodes.each(function(node){
  1201. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1202. "type": "identity",
  1203. "names": this.data[node.get("name")],
  1204. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1205. });
  1206. }.bind(this));
  1207. personUnitNodes.each(function(node){
  1208. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1209. "type": "unit",
  1210. "names": this.data[node.get("name")],
  1211. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1212. });
  1213. }.bind(this));
  1214. dutyNodes.each(function(node){
  1215. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1216. "type": "duty",
  1217. "names": this.data[node.get("name")],
  1218. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  1219. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  1220. });
  1221. }.bind(this));
  1222. dutyNameNodes.each(function(node){
  1223. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1224. "type": "dutyName",
  1225. "names": this.data[node.get("name")],
  1226. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1227. });
  1228. }.bind(this));
  1229. viewNodes.each(function(node){
  1230. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1231. "type": "View",
  1232. "count": 1,
  1233. "names": [this.data[node.get("name")]],
  1234. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1235. });
  1236. }.bind(this));
  1237. cmsviewNodes.each(function(node){
  1238. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1239. "type": "CMSView",
  1240. "count": 1,
  1241. "names": [this.data[node.get("name")]],
  1242. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1243. });
  1244. }.bind(this));
  1245. queryviewNodes.each(function(node){
  1246. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1247. "type": "QueryView",
  1248. "count": 1,
  1249. "names": [this.data[node.get("name")]],
  1250. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1251. });
  1252. }.bind(this));
  1253. queryStatementNodes.each(function(node){
  1254. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1255. "type": "QueryStatement",
  1256. "count": 1,
  1257. "names": [this.data[node.get("name")]],
  1258. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1259. });
  1260. }.bind(this));
  1261. querystatNodes.each(function(node){
  1262. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1263. "type": "QueryStat",
  1264. "count": 1,
  1265. "names": [this.data[node.get("name")]],
  1266. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1267. });
  1268. }.bind(this));
  1269. scriptNodes.each(function(node){
  1270. var ps = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1271. "type": "Script",
  1272. "count": node.dataset["count"] || 1,
  1273. "names": (!node.dataset["count"] || node.dataset["count"].toInt()==1) ? [this.data[node.get("name")]] : this.data[node.get("name")],
  1274. "onChange": function(ids){
  1275. this.saveScriptSelectItem(node, ids);
  1276. }.bind(this)
  1277. });
  1278. node.store("selector", ps);
  1279. var actionNode = node.getNext();
  1280. if (actionNode.hasClass("MWFScriptSelectAction")){
  1281. var _self = this;
  1282. var copyNode = actionNode.getFirst();
  1283. var pasteNode = actionNode.getLast();
  1284. copyNode.store("slectNode", node);
  1285. pasteNode.store("slectNode", node);
  1286. copyNode.addEvent("click", function(e){
  1287. var selectNode = this.retrieve("slectNode");
  1288. if (selectNode){
  1289. var name = node.get("name");
  1290. var data = _self.data[name];
  1291. if (data){
  1292. var str = JSON.encode(data);
  1293. o2.DL.open({
  1294. "isTitle": false,
  1295. "width": 400,
  1296. "height": 500,
  1297. "html": "<textarea style='width: 99%; height: 98%'>"+str+"</textarea>",
  1298. "buttonList": [{
  1299. "type": "ok",
  1300. "text": "ok",
  1301. "action": function(){this.close();}
  1302. }]
  1303. })
  1304. }
  1305. }
  1306. });
  1307. pasteNode.addEvent("click", function(e){
  1308. var selectNode = this.retrieve("slectNode");
  1309. if (selectNode){
  1310. o2.DL.open({
  1311. "isTitle": false,
  1312. "width": 400,
  1313. "height": 500,
  1314. "html": "<textarea style='width: 99%; height: 98%'></textarea>",
  1315. "buttonList": [{
  1316. "type": "ok",
  1317. "text": "ok",
  1318. "action": function(){
  1319. var dataStr = this.content.getElement("textarea").get("value");
  1320. try{
  1321. var data = JSON.decode(dataStr);
  1322. var s = selectNode.retrieve("selector");
  1323. s.setData(data);
  1324. _self.saveScriptSelectItem(selectNode, s.identitys);
  1325. }catch(e){
  1326. throw e;
  1327. }
  1328. this.close();
  1329. }
  1330. },{
  1331. "type": "cancel",
  1332. "text": "cancel",
  1333. "action": function(){this.close();}
  1334. }]
  1335. })
  1336. }
  1337. });
  1338. }
  1339. }.bind(this));
  1340. var _self = this;
  1341. formStyleNodes.each(function(node){
  1342. debugger;
  1343. var data = this.data[node.get("name")];
  1344. if( typeOf( data ) === "string" ){
  1345. for( var key in this.module.form.stylesList ){
  1346. var s = this.module.form.stylesList[key];
  1347. if( ((!data && key=="default") || (data==key)) ){
  1348. data = {
  1349. name : s.name,
  1350. id : key
  1351. };
  1352. break;
  1353. }
  1354. }
  1355. }
  1356. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1357. "type": "FormStyle",
  1358. "count": 1,
  1359. "names": [data],
  1360. "selectorOptions" : {
  1361. "mode" : ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc"
  1362. },
  1363. "validFun" : function (ids) {
  1364. var flag = true;
  1365. if( ids.length === 0 ){
  1366. this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error");
  1367. flag = false;
  1368. }else if( ids[0].data.type === "script" ){
  1369. this.designer.actions.getScriptByName( ids[0].data.name, ids[0].data.application, function( json ) {
  1370. debugger;
  1371. try{
  1372. var f = eval("(function(){\n return "+json.data.text+"\n})");
  1373. var j = f();
  1374. if( typeOf(j) !== "object" ){
  1375. this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
  1376. flag = false;
  1377. }
  1378. }catch (e) {
  1379. this.designer.notice( MWF.APPFD.LP.notValidJson +":"+ e.message, "error" );
  1380. flag = false;
  1381. }
  1382. }.bind(this), function () {
  1383. flag = false;
  1384. }, false);
  1385. }
  1386. return flag;
  1387. }.bind(this),
  1388. "onChange": function(ids){
  1389. var d = ids[0].data;
  1390. var data;
  1391. if( d.type === "script" ){
  1392. data = {
  1393. "type" : "script",
  1394. "name": d.name,
  1395. "alias": d.alias,
  1396. "id": d.id,
  1397. "appName" : d.appName || d.applicationName,
  1398. "appId": d.appId,
  1399. "application": d.application
  1400. };
  1401. }else{
  1402. data = d.id;
  1403. }
  1404. var name = node.get("name");
  1405. var oldValue = this.data[name];
  1406. this.data[name] = data;
  1407. this.changeData(name, node, oldValue);
  1408. }.bind(this)
  1409. });
  1410. var next = node.getNext();
  1411. if( next && next.get("class") === "MWFScriptSelectRefresh" ){
  1412. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(next);
  1413. refreshNode.addEvent("click", function(e){
  1414. _self.changeData(this.get("name"), this );
  1415. }.bind(node));
  1416. }
  1417. }.bind(this));
  1418. dictionaryNodes.each(function(node){
  1419. var data = this.data[node.get("name")];
  1420. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1421. "type": "Dictionary",
  1422. "count": 0,
  1423. "names": typeOf(data)==="array" ? data : [data],
  1424. "onChange": function(ids){
  1425. var data = [];
  1426. var name = node.get("name");
  1427. if( ids.length > 0 ){
  1428. // var d = ids[0].data;
  1429. ids.each( function (id) {
  1430. debugger;
  1431. var d = id.data;
  1432. data.push({
  1433. "type" : "dictionary",
  1434. "name": d.name,
  1435. "alias": d.alias,
  1436. "id": d.id,
  1437. "appName" : d.appName || d.applicationName,
  1438. "appAlias" : d.appAlias || d.applicationAlias,
  1439. "appId": d.appId,
  1440. "application": d.application,
  1441. "appType" : d.appType
  1442. })
  1443. });
  1444. }
  1445. var oldValue = this.data[name];
  1446. this.data[name] = data;
  1447. this.changeData(name, node, oldValue);
  1448. }.bind(this)
  1449. });
  1450. }.bind(this));
  1451. fileNodes.each(function(node){
  1452. var d = this.data[node.get("name")];
  1453. var data = d || {};
  1454. //this.form
  1455. if (d && typeOf(d)==="string"){
  1456. if (this.form.page){
  1457. data = {"id": d, "portal": this.form.application}
  1458. }else{
  1459. data = {"id": d, "application": this.form.application}
  1460. }
  1461. }
  1462. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1463. "type": "PortalFile",
  1464. "count": 1,
  1465. "isImage": true,
  1466. "values": (data.id) ? [data.id] : [],
  1467. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  1468. });
  1469. }.bind(this));
  1470. processFileNodes.each(function(node){
  1471. var d = this.data[node.get("name")];
  1472. var data = d || {};
  1473. //this.form
  1474. if (d && typeOf(d)==="string"){
  1475. if (this.form.page){
  1476. data = {"id": d, "portal": this.form.application}
  1477. }else{
  1478. data = {"id": d, "application": this.form.application}
  1479. }
  1480. }
  1481. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1482. "type": "ProcessFile",
  1483. "count": 1,
  1484. "isImage": true,
  1485. "values": (data.id) ? [data.id] : [],
  1486. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  1487. });
  1488. }.bind(this));
  1489. }.bind(this));
  1490. },
  1491. loadDictionaryIncluder : function(){
  1492. var nodes = this.propertyContent.getElements(".MWFDictionaryIncluder");
  1493. if (nodes.length){
  1494. nodes.each(function(node){
  1495. var name = node.get("name");
  1496. MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictionaryIncluder", function(){
  1497. var dictionaryIncluder = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder(node, this.designer, {
  1498. "onChange": function(){
  1499. var data = dictionaryIncluder.getData();
  1500. this.data[name] = data;
  1501. }.bind(this)
  1502. });
  1503. dictionaryIncluder.load(this.data[name])
  1504. }.bind(this));
  1505. }.bind(this));
  1506. }
  1507. },
  1508. loadScriptIncluder : function(){
  1509. var nodes = this.propertyContent.getElements(".MWFScriptIncluder");
  1510. if (nodes.length){
  1511. nodes.each(function(node){
  1512. var name = node.get("name");
  1513. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ScriptIncluder", function(){
  1514. var scriptIncluder = new MWF.xApplication.process.FormDesigner.widget.ScriptIncluder(node, this.designer, {
  1515. "onChange": function(){
  1516. var data = scriptIncluder.getData();
  1517. this.data[name] = data;
  1518. }.bind(this)
  1519. });
  1520. scriptIncluder.load(this.data[name])
  1521. }.bind(this));
  1522. }.bind(this));
  1523. }
  1524. },
  1525. saveFileItem: function(node, ids){
  1526. if (ids[0]){
  1527. var file = ids[0].data;
  1528. this.data[node.get("name")] = file;
  1529. }else{
  1530. this.data[node.get("name")] = null;
  1531. }
  1532. this.changeData(node.get("name"));
  1533. },
  1534. saveViewItem: function(node, ids){
  1535. if (ids[0]){
  1536. var view = ids[0].data;
  1537. var data = {
  1538. "name": view.name,
  1539. "alias": view.alias,
  1540. "id": view.id,
  1541. "appName" : view.appName || view.applicationName || view.query,
  1542. "appId": view.appId,
  1543. "application": view.application || view.query
  1544. };
  1545. this.data[node.get("name")] = data;
  1546. }else{
  1547. this.data[node.get("name")] = null;
  1548. }
  1549. if (this.module._checkView) this.module._checkView();
  1550. },
  1551. removeViewItem: function(node, item){
  1552. },
  1553. saveScriptSelectItem: function(node, ids){
  1554. var count = (node.dataset["count"] || 1).toInt();
  1555. if (count==1){
  1556. if (ids[0]){
  1557. var script = ids[0].data;
  1558. var data = {
  1559. "appType": script.appType,
  1560. "type" : "script",
  1561. "name": script.name,
  1562. "alias": script.alias,
  1563. "id": script.id,
  1564. "appName" : script.appName || script.applicationName,
  1565. "appId": script.appId,
  1566. "application": script.application
  1567. };
  1568. var name = node.get("name");
  1569. var oldValue = this.data[name];
  1570. this.data[name] = data;
  1571. // this.changeJsonDate(name, data );
  1572. this.changeData(name, node, oldValue);
  1573. }else{
  1574. // this.data[node.get("name")] = null;
  1575. }
  1576. }else{
  1577. var scriptValues = [];
  1578. ids.each(function(s){
  1579. var scriptValue = {
  1580. "appType": s.data.appType,
  1581. "type" : "script",
  1582. "name": s.data.name,
  1583. "alias": s.data.alias,
  1584. "id": s.data.id,
  1585. "appName" : s.data.appName || s.data.applicationName,
  1586. "appId": s.data.appId,
  1587. "application": s.data.application
  1588. }
  1589. scriptValues.push(scriptValue);
  1590. }.bind(this));
  1591. var name = node.get("name");
  1592. var oldValue = this.data[name];
  1593. this.data[name] = scriptValues;
  1594. this.changeData(name, node, oldValue);
  1595. }
  1596. },
  1597. removeDutyItem: function(node, item){
  1598. if (item.data.id){
  1599. var values = JSON.decode(this.data[node.get("name")] || []);
  1600. var value = values.filter(function(v){
  1601. return v.id == item.data.id;
  1602. });
  1603. value.each(function(v) {
  1604. values = values.erase(v);
  1605. });
  1606. this.data[node.get("name")] = JSON.encode(values);
  1607. }
  1608. item.node.destroy();
  1609. MWF.release(item);
  1610. delete item;
  1611. },
  1612. addDutyItem: function(node, ids){
  1613. var value = this.data[node.get("name")] || "";
  1614. if (!value) value = "[]";
  1615. var values = JSON.decode(value);
  1616. ids.each(function(id){
  1617. if (id.data.dutyId){
  1618. for (var i=0; i<values.length; i++){
  1619. if (values[i].dutyId===id.data.dutyId){
  1620. values[i].name = id.data.name;
  1621. values[i].code = id.data.code;
  1622. break;
  1623. }
  1624. }
  1625. }else{
  1626. id.data.dutyId = new MWF.widget.UUID().toString();
  1627. values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
  1628. }
  1629. }.bind(this));
  1630. this.data[node.get("name")] = JSON.encode(values);
  1631. },
  1632. loadFormFieldInput: function(){
  1633. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  1634. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  1635. fieldNodes.each(function(node){
  1636. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1637. "type": "formField",
  1638. "application": this.form.json.application,
  1639. "fieldType": "person",
  1640. "names": this.data[node.get("name")],
  1641. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1642. });
  1643. }.bind(this));
  1644. }.bind(this));
  1645. },
  1646. savePersonItem: function(node, ids){
  1647. var values = [];
  1648. ids.each(function(id){
  1649. values.push(MWF.org.parseOrgData(id.data));
  1650. }.bind(this));
  1651. this.data[node.get("name")] = values;
  1652. },
  1653. loadScriptArea: function(){
  1654. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  1655. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  1656. this.loadScriptEditor(scriptAreas);
  1657. this.loadScriptEditor(formulaAreas, "formula");
  1658. },
  1659. loadScriptEditor: function(scriptAreas, style){
  1660. scriptAreas.each(function(node){
  1661. var title = node.get("title");
  1662. var name = node.get("name");
  1663. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  1664. var scriptContent = this.data[name];
  1665. MWF.require("MWF.widget.ScriptArea", function(){
  1666. var scriptArea = new MWF.widget.ScriptArea(node, {
  1667. "title": title,
  1668. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1669. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1670. "onChange": function(){
  1671. //this.data[name] = scriptArea.toJson();
  1672. if (!this.data[name]){
  1673. this.data[name] = {"code": "", "html": ""};
  1674. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  1675. }
  1676. var json = scriptArea.toJson();
  1677. this.data[name].code = json.code;
  1678. //this.data[name].html = json.html;
  1679. }.bind(this),
  1680. "onSave": function(){
  1681. this.designer.saveForm();
  1682. }.bind(this),
  1683. "style": style || "default",
  1684. "runtime": "web"
  1685. });
  1686. scriptArea.load(scriptContent);
  1687. }.bind(this));
  1688. }.bind(this));
  1689. },
  1690. loadCssArea: function(style){
  1691. var cssAreas = this.propertyContent.getElements(".MWFCssArea");
  1692. cssAreas.each(function(node){
  1693. var title = node.get("title");
  1694. var name = node.get("name");
  1695. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  1696. var cssContent = this.data[name];
  1697. o2.require("o2.widget.CssArea", function(){
  1698. var cssArea = new o2.widget.CssArea(node, {
  1699. "title": title,
  1700. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1701. "onChange": function(){
  1702. //this.data[name] = scriptArea.toJson();
  1703. if (!this.data[name]){
  1704. this.data[name] = {"code": "", "html": ""};
  1705. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  1706. }
  1707. var json = cssArea.toJson();
  1708. this.data[name].code = json.code;
  1709. cssArea.isChanged = true;
  1710. //this.data[name].html = json.html;
  1711. }.bind(this),
  1712. "onBlur": function(){
  1713. if (cssArea.isChanged){
  1714. this.changeData(name, node, "");
  1715. cssArea.isChanged = false;
  1716. }
  1717. }.bind(this),
  1718. "onSave": function(){
  1719. this.designer.saveForm();
  1720. }.bind(this),
  1721. "style": style || "default"
  1722. });
  1723. cssArea.load(cssContent);
  1724. }.bind(this));
  1725. }.bind(this));
  1726. },
  1727. loadActionStylesArea: function(){
  1728. var _self = this;
  1729. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  1730. actionAreas.each(function(node){
  1731. var name = node.get("name");
  1732. var actionStyles = this.data[name];
  1733. MWF.require("MWF.widget.Maplist", function(){
  1734. var maps = [];
  1735. Object.each(actionStyles, function(v, k){
  1736. var mapNode = new Element("div").inject(node);
  1737. mapNode.empty();
  1738. var maplist = new MWF.widget.Maplist(mapNode, {
  1739. "title": k,
  1740. "collapse": true,
  1741. "onChange": function(){
  1742. var oldData = _self.data[name];
  1743. maps.each(function(o){
  1744. _self.data[name][o.key] = o.map.toJson();
  1745. }.bind(this));
  1746. _self.changeData(name, node, oldData);
  1747. }
  1748. });
  1749. maps.push({"key": k, "map": maplist});
  1750. maplist.load(v);
  1751. }.bind(this));
  1752. }.bind(this));
  1753. }.bind(this));
  1754. },
  1755. loadActionArea: function(){
  1756. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  1757. actionAreas.each(function(node){
  1758. var name = node.get("name");
  1759. var actionContent = this.data[name];
  1760. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  1761. // debugger;
  1762. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  1763. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1764. // "noCreate": true,
  1765. // "noDelete": true,
  1766. // "noCode": true,
  1767. // "onChange": function(){
  1768. // this.data[name] = actionEditor.data;
  1769. // }.bind(this)
  1770. // });
  1771. // actionEditor.load(this.module.defaultToolBarsData);
  1772. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  1773. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1774. "onChange": function(){
  1775. this.data[name] = actionEditor.data;
  1776. this.changeData(name);
  1777. }.bind(this)
  1778. });
  1779. actionEditor.load(actionContent);
  1780. }.bind(this));
  1781. }.bind(this));
  1782. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  1783. actionAreas.each(function(node){
  1784. var name = node.get("name");
  1785. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  1786. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  1787. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  1788. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1789. "isSystemTool" : true,
  1790. "noCreate": true,
  1791. "noDelete": false,
  1792. "noCode": true,
  1793. "noReadShow": true,
  1794. "target" : node.get("data-target"),
  1795. "noEditShow": true,
  1796. "onChange": function(){
  1797. this.data[name] = actionEditor.data;
  1798. this.changeData(name);
  1799. }.bind(this)
  1800. });
  1801. actionEditor.load(actionContent);
  1802. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  1803. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1804. // "onChange": function(){
  1805. // this.data[name] = actionEditor.data;
  1806. // }.bind(this)
  1807. // });
  1808. // actionEditor.load(actionContent);
  1809. }.bind(this));
  1810. }.bind(this));
  1811. },
  1812. loadMaplist: function(){
  1813. var maplists = this.propertyContent.getElements(".MWFMaplist");
  1814. debugger;
  1815. maplists.each(function(node){
  1816. var title = node.get("title");
  1817. var name = node.get("name");
  1818. var collapse = node.get("collapse");
  1819. var mapObj = this.data[name];
  1820. if (!mapObj) mapObj = {};
  1821. MWF.require("MWF.widget.Maplist", function(){
  1822. node.empty();
  1823. var maplist = new MWF.widget.Maplist(node, {
  1824. "title": title,
  1825. "collapse": (collapse) ? true : false,
  1826. "onChange": function(){
  1827. //this.data[name] = maplist.toJson();
  1828. //
  1829. var oldData = this.data[name];
  1830. this.changeJsonDate(name, maplist.toJson());
  1831. this.changeStyle(name, oldData);
  1832. this.changeData(name);
  1833. }.bind(this),
  1834. "onDelete": function(key){
  1835. debugger;
  1836. this.module.deletePropertiesOrStyles(name, key);
  1837. }.bind(this)
  1838. });
  1839. maplist.load(mapObj);
  1840. this.maplists[name] = maplist;
  1841. }.bind(this));
  1842. }.bind(this));
  1843. },
  1844. //loadPropertyTab: function(){
  1845. // var tabNodes = this.propertyContent.getElements(".MWFTab");
  1846. // if (tabNodes.length){
  1847. // var tmpNode = this.propertyContent.getFirst();
  1848. // var tabAreaNode = new Element("div", {
  1849. // "styles": this.form.css.propertyTabNode
  1850. // }).inject(tmpNode, "before");
  1851. //
  1852. // MWF.require("MWF.widget.Tab", function(){
  1853. // var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  1854. // tab.load();
  1855. // var tabPages = [];
  1856. // tabNodes.each(function(node){
  1857. // if (node.getStyle("display")!="none"){
  1858. // var page = tab.addTab(node, node.get("title"), false);
  1859. // tabPages.push(page);
  1860. // page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  1861. // node.inject(page.contentScrollNode);
  1862. // this.setScrollBar(page.contentScrollNode, "small", null, null);
  1863. // }
  1864. // }.bind(this));
  1865. // tabPages[0].showTab();
  1866. //
  1867. // this.propertyTab = tab;
  1868. //
  1869. // this.designer.resizeNode();
  1870. // }.bind(this), false);
  1871. // }
  1872. //},
  1873. loadPropertyTab: function(){
  1874. var tabNodes = this.propertyContent.getElements(".MWFTab");
  1875. var groupObject = {}; //data-group 属性可以表示不同的分组
  1876. if (tabNodes.length){
  1877. tabNodes.each( function(node){
  1878. var group = node.get("data-group") || "default";
  1879. groupObject[group] = groupObject[group] || [];
  1880. groupObject[group].push( node );
  1881. }.bind(this))
  1882. }
  1883. for( var group in groupObject ){
  1884. if( group === "default" ){
  1885. var tmpNode = this.propertyContent.getFirst();
  1886. var tabAreaNode = new Element("div", {
  1887. "styles": this.form.css.propertyTabNode
  1888. }).inject(tmpNode, "before");
  1889. MWF.require("MWF.widget.Tab", function(){
  1890. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  1891. tab.load();
  1892. var tabPages = [];
  1893. groupObject["default"].each(function(node){
  1894. if (node.getStyle("display")!="none"){
  1895. var page = tab.addTab(node, node.get("title"), false);
  1896. tabPages.push(page);
  1897. page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  1898. node.inject(page.contentScrollNode);
  1899. this.setScrollBar(page.contentScrollNode, "small", null, null);
  1900. }
  1901. }.bind(this));
  1902. tabPages[0].showTab();
  1903. this.propertyTab = tab;
  1904. this.designer.resizeNode();
  1905. }.bind(this), false);
  1906. }else{
  1907. var tmpNode = groupObject[group][0];
  1908. var tabAreaNode = new Element("div", {
  1909. "styles": this.form.css.propertyTabNode
  1910. }).inject(tmpNode, "before");
  1911. MWF.require("MWF.widget.Tab", function(){
  1912. var tab = new MWF.widget.Tab(tabAreaNode, {"style": tmpNode.get("data-style") || "formPropertyList"});
  1913. tab.load();
  1914. var tabPages = [];
  1915. groupObject[group].each(function(node) {
  1916. var page = tab.addTab(node, node.get("title"), false);
  1917. tabPages.push(page);
  1918. node.store("tab", page);
  1919. if (node.getStyle("display") === "none"){
  1920. page.disableTab( true );
  1921. node.show();
  1922. }
  1923. }.bind(this));
  1924. for( var i=0; i<tabPages.length; i++ ){
  1925. if( !tabPages[i].disabled ){
  1926. tabPages[i].showTab();
  1927. break
  1928. }
  1929. }
  1930. }.bind(this), false);
  1931. }
  1932. }
  1933. },
  1934. setEditNodeEvent: function(){
  1935. var property = this;
  1936. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  1937. var inputs = this.propertyContent.getElements("input");
  1938. inputs.each(function(input){
  1939. var jsondata = input.get("name");
  1940. if (this.module){
  1941. var id = this.data.pid;
  1942. //var id = this.form.json.id;
  1943. // input.set("name", this.form.options.mode+id+jsondata);
  1944. input.set("name", id+jsondata);
  1945. }
  1946. if (jsondata){
  1947. var inputType = input.get("type").toLowerCase();
  1948. switch (inputType){
  1949. case "radio":
  1950. input.addEvent("change", function(e){
  1951. property.setRadioValue(jsondata, this);
  1952. });
  1953. input.addEvent("blur", function(e){
  1954. property.setRadioValue(jsondata, this);
  1955. });
  1956. input.addEvent("keydown", function(e){
  1957. e.stopPropagation();
  1958. });
  1959. property.setRadioValue(jsondata, input);
  1960. break;
  1961. case "checkbox":
  1962. input.addEvent("change", function(e){
  1963. property.setCheckboxValue(jsondata, this);
  1964. });
  1965. input.addEvent("click", function(e){
  1966. property.setCheckboxValue(jsondata, this);
  1967. });
  1968. input.addEvent("keydown", function(e){
  1969. e.stopPropagation();
  1970. });
  1971. break;
  1972. default:
  1973. input.addEvent("change", function(e){
  1974. property.setValue(jsondata, this.value, this);
  1975. });
  1976. input.addEvent("blur", function(e){
  1977. property.setValue(jsondata, this.value, this);
  1978. });
  1979. input.addEvent("keydown", function(e){
  1980. if (e.code==13){
  1981. property.setValue(jsondata, this.value, this);
  1982. }
  1983. e.stopPropagation();
  1984. });
  1985. }
  1986. }
  1987. }.bind(this));
  1988. var selects = this.propertyContent.getElements("select");
  1989. selects.each(function(select){
  1990. var jsondata = select.get("name");
  1991. if (jsondata){
  1992. select.addEvent("change", function(e){
  1993. property.setSelectValue(jsondata, this);
  1994. });
  1995. //property.setSelectValue(jsondata, select);
  1996. }
  1997. });
  1998. var textareas = this.propertyContent.getElements("textarea");
  1999. textareas.each(function(input){
  2000. var jsondata = input.get("name");
  2001. if (jsondata){
  2002. input.addEvent("change", function(e){
  2003. property.setValue(jsondata, this.value);
  2004. });
  2005. input.addEvent("blur", function(e){
  2006. property.setValue(jsondata, this.value);
  2007. });
  2008. input.addEvent("keydown", function(e){
  2009. e.stopPropagation();
  2010. });
  2011. }
  2012. }.bind(this));
  2013. },
  2014. changeStyle: function(name, oldData){
  2015. this.module.setPropertiesOrStyles(name, oldData);
  2016. },
  2017. changeData: function(name, input, oldValue){
  2018. this.module._setEditStyle(name, input, oldValue);
  2019. },
  2020. changeJsonDate: function(key, value){
  2021. if (typeOf(key)!=="array") key = [key];
  2022. var o = this.data;
  2023. var len = key.length-1;
  2024. key.each(function(n, i){
  2025. if (!o[n]) o[n] = {};
  2026. if (i<len) o = o[n];
  2027. }.bind(this));
  2028. o[key[len]] = value;
  2029. //this.data[key] = value;
  2030. },
  2031. setRadioValue: function(name, input){
  2032. if (input.checked){
  2033. var i = name.indexOf("*");
  2034. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  2035. var value = input.value;
  2036. if (value=="false") value = false;
  2037. if (value=="true") value = true;
  2038. var oldValue = this.data;
  2039. for (var idx = 0; idx<names.length; idx++){
  2040. if (!oldValue[names[idx]]){
  2041. oldValue = null;
  2042. break;
  2043. }else{
  2044. oldValue = oldValue[names[idx]];
  2045. }
  2046. }
  2047. // var value = input.value;
  2048. // if (value==="false") value = false;
  2049. // if (value==="true") value = true;
  2050. //var oldValue = this.data[name];
  2051. this.changeJsonDate(names, value);
  2052. this.changeData(name, input, oldValue);
  2053. }
  2054. },
  2055. setCheckboxValue: function(name, input){
  2056. //var id = this.module.json.id;
  2057. //var id = this.form.json.id;
  2058. var id = this.data.pid;
  2059. // var checkboxList = $$("input[name='"+this.form.options.mode+id+name+"']");
  2060. var checkboxList = $$("input[name='"+id+name+"']");
  2061. var values = [];
  2062. checkboxList.each(function(checkbox){
  2063. if (checkbox.get("checked")){
  2064. values.push(checkbox.value);
  2065. }
  2066. });
  2067. var oldValue = this.data[name];
  2068. //this.data[name] = values;
  2069. this.changeJsonDate(name, values);
  2070. this.changeData(name, input, oldValue);
  2071. },
  2072. setSelectValue: function(name, select){
  2073. var idx = select.selectedIndex;
  2074. var options = select.getElements("option");
  2075. var value = "";
  2076. if (options[idx]){
  2077. value = options[idx].get("value");
  2078. }
  2079. var oldValue = this.data[name];
  2080. //this.data[name] = value;
  2081. this.changeJsonDate(name, value);
  2082. this.changeData(name, select, oldValue);
  2083. },
  2084. setValue: function(name, value, obj){
  2085. if (name==="id"){
  2086. if (value!==this.module.json.id) {
  2087. if (!value) {
  2088. this.designer.notice(MWF.APPFD.LP.notNullId, "error", this.module.form.designer.propertyContentArea, {
  2089. x: "right",
  2090. y: "bottom"
  2091. });
  2092. obj.focus();
  2093. return false;
  2094. } else {
  2095. var check = this.module.form.checkModuleId(value, this.module.json.type);
  2096. if (check.elementConflict) {
  2097. this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {
  2098. x: "right",
  2099. y: "bottom"
  2100. });
  2101. obj.focus();
  2102. return false;
  2103. } else {
  2104. var json = this.module.form.json.moduleList[this.module.json.id];
  2105. this.module.form.json.moduleList[value] = json;
  2106. delete this.module.form.json.moduleList[this.module.json.id];
  2107. }
  2108. }
  2109. // if (this.module.form.json.moduleList[value]){
  2110. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  2111. // obj.focus();
  2112. // return false;
  2113. // }else{
  2114. // var flag = false;
  2115. // if (this.module.form.subformList){
  2116. // Object.each(this.module.form.subformList, function(o, k){
  2117. // if (o.subformData.moduleList[value] && o.subformData.moduleList[value] ) flag = true;
  2118. // });
  2119. // }
  2120. // if (flag){
  2121. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  2122. // obj.focus();
  2123. // return false;
  2124. // }else{
  2125. // var json = this.module.form.json.moduleList[this.module.json.id];
  2126. // this.module.form.json.moduleList[value]=json;
  2127. // delete this.module.form.json.moduleList[this.module.json.id];
  2128. // }
  2129. // }
  2130. }
  2131. }
  2132. //var oldValue = this.data[name];
  2133. var names = name.split(".");
  2134. var oldValue = this.data;
  2135. for (var idx = 0; idx<names.length; idx++){
  2136. if (!oldValue[names[idx]]){
  2137. oldValue = null;
  2138. break;
  2139. }else{
  2140. oldValue = oldValue[names[idx]];
  2141. }
  2142. }
  2143. //this.data[name] = value;
  2144. this.changeJsonDate(names, value);
  2145. this.changeData(name, obj, oldValue);
  2146. },
  2147. setEditNodeStyles: function(node){
  2148. var nodes = node.getChildren();
  2149. if (nodes.length){
  2150. nodes.each(function(el){
  2151. var cName = el.get("class");
  2152. if (cName){
  2153. if (this.form.css[cName]) el.setStyles(this.form.css[cName]);
  2154. }
  2155. this.setEditNodeStyles(el);
  2156. }.bind(this));
  2157. }
  2158. },
  2159. loadScriptInput: function(){
  2160. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  2161. scriptNodes.each(function(node){
  2162. MWF.require("MWF.widget.ScriptEditor", function(){
  2163. var script = new MWF.widget.ScriptEditor(node, {
  2164. "onPostSave": function(script){
  2165. this.saveScriptItem(node, script);
  2166. }.bind(this),
  2167. "onQueryDelete": function(script){
  2168. this.deleteScriptItem(node, script);
  2169. }.bind(this)
  2170. });
  2171. this.setScriptItems(script, node);
  2172. }.bind(this));
  2173. }.bind(this));
  2174. },
  2175. deleteScriptItem: function(node, script){
  2176. var jsondata = node.get("name");
  2177. this.data[jsondata].erase(script.data.id);
  2178. this.process.scripts[script.data.id] = null;
  2179. delete this.process.scripts[script.data.id];
  2180. this.process.process.scriptList.erase(script.data);
  2181. },
  2182. saveScriptItem: function(node, script){
  2183. var jsondata = node.get("name");
  2184. var scriptList = this.data[jsondata];
  2185. var data = script.data;
  2186. var scriptData = this.process.scripts[script.data.id];
  2187. if (!scriptData){
  2188. this.process.process.scriptList.push(data);
  2189. this.process.scripts[script.data.id] = data;
  2190. }
  2191. if (scriptList.indexOf(data.id) == -1){
  2192. this.data[jsondata].push(data.id);
  2193. }
  2194. },
  2195. setScriptItems: function(script, node){
  2196. var jsondata = node.get("name");
  2197. var scriptList = this.data[jsondata];
  2198. scriptList.each(function(id){
  2199. if (id){
  2200. var data = this.process.scripts[id];
  2201. if (data) script.setScriptItem(data);
  2202. }
  2203. }.bind(this));
  2204. }
  2205. });
  2206. MWF.xApplication.process.FormDesigner.PropertyMulti = new Class({
  2207. Extends: MWF.xApplication.process.FormDesigner.Property,
  2208. Implements: [Options, Events],
  2209. initialize: function(form, modules, propertyNode, designer, options){
  2210. this.setOptions(options);
  2211. this.modules = modules;
  2212. this.form = form;
  2213. // this.data = module.json;
  2214. this.data = {};
  2215. this.htmlPath = this.options.path;
  2216. this.designer = designer;
  2217. this.maplists = {};
  2218. this.propertyNode = propertyNode;
  2219. },
  2220. load: function(){
  2221. if (this.fireEvent("queryLoad")){
  2222. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  2223. this.htmlString = responseText;
  2224. MWF.require("MWF.widget.JsonTemplate", function(){
  2225. this.fireEvent("postLoad");
  2226. }.bind(this));
  2227. }.bind(this));
  2228. }
  2229. },
  2230. show: function(){
  2231. if (!this.propertyContent){
  2232. if (this.htmlString){
  2233. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  2234. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  2235. this.propertyContent.set("html", this.JsonTemplate.load());
  2236. this.setEditNodeEvent();
  2237. this.setEditNodeStyles(this.propertyContent);
  2238. this.loadPropertyTab();
  2239. this.loadMaplist();
  2240. this.loadScriptArea();
  2241. this.loadTreeData();
  2242. this.loadArrayList();
  2243. //this.loadEventsEditor();
  2244. //this.loadHTMLArea();
  2245. //this.loadJSONArea();
  2246. // this.loadScriptInput();
  2247. //MWF.process.widget.EventsEditor
  2248. }
  2249. }else{
  2250. this.propertyContent.setStyle("display", "block");
  2251. }
  2252. },
  2253. hide: function(){
  2254. if (this.propertyContent) this.propertyContent.destroy();
  2255. },
  2256. changeStyle: function(name){
  2257. this.modules.each(function(module){
  2258. module.setPropertiesOrStyles(name);
  2259. }.bind(this));
  2260. },
  2261. changeData: function(name, input, oldValue){
  2262. this.modules.each(function(module){
  2263. module._setEditStyle(name, input, oldValue);
  2264. }.bind(this));
  2265. },
  2266. changeJsonDate: function(key, value){
  2267. //alert(key+": "+value );
  2268. this.modules.each(function(module){
  2269. module.json[key] = value;
  2270. }.bind(this));
  2271. },
  2272. });