Property.js 102 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437
  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. debugger;
  1224. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1225. "type": "dutyName",
  1226. "names": this.data[node.get("name")],
  1227. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1228. });
  1229. }.bind(this));
  1230. viewNodes.each(function(node){
  1231. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1232. "type": "View",
  1233. "count": 1,
  1234. "names": [this.data[node.get("name")]],
  1235. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1236. });
  1237. }.bind(this));
  1238. cmsviewNodes.each(function(node){
  1239. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1240. "type": "CMSView",
  1241. "count": 1,
  1242. "names": [this.data[node.get("name")]],
  1243. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1244. });
  1245. }.bind(this));
  1246. queryviewNodes.each(function(node){
  1247. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1248. "type": "QueryView",
  1249. "count": 1,
  1250. "names": [this.data[node.get("name")]],
  1251. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1252. });
  1253. }.bind(this));
  1254. queryStatementNodes.each(function(node){
  1255. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1256. "type": "QueryStatement",
  1257. "count": 1,
  1258. "names": [this.data[node.get("name")]],
  1259. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1260. });
  1261. }.bind(this));
  1262. querystatNodes.each(function(node){
  1263. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1264. "type": "QueryStat",
  1265. "count": 1,
  1266. "names": [this.data[node.get("name")]],
  1267. "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  1268. });
  1269. }.bind(this));
  1270. scriptNodes.each(function(node){
  1271. var ps = new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1272. "type": "Script",
  1273. "count": node.dataset["count"] || 1,
  1274. "names": (!node.dataset["count"] || node.dataset["count"].toInt()==1) ? [this.data[node.get("name")]] : this.data[node.get("name")],
  1275. "onChange": function(ids){
  1276. this.saveScriptSelectItem(node, ids);
  1277. }.bind(this)
  1278. });
  1279. node.store("selector", ps);
  1280. var actionNode = node.getNext();
  1281. if (actionNode.hasClass("MWFScriptSelectAction")){
  1282. var _self = this;
  1283. var copyNode = actionNode.getFirst();
  1284. var pasteNode = actionNode.getLast();
  1285. copyNode.store("slectNode", node);
  1286. pasteNode.store("slectNode", node);
  1287. copyNode.addEvent("click", function(e){
  1288. var selectNode = this.retrieve("slectNode");
  1289. if (selectNode){
  1290. var name = node.get("name");
  1291. var data = _self.data[name];
  1292. if (data){
  1293. var str = JSON.encode(data);
  1294. o2.DL.open({
  1295. "isTitle": false,
  1296. "width": 400,
  1297. "height": 500,
  1298. "html": "<textarea style='width: 99%; height: 98%'>"+str+"</textarea>",
  1299. "buttonList": [{
  1300. "type": "ok",
  1301. "text": "ok",
  1302. "action": function(){this.close();}
  1303. }]
  1304. })
  1305. }
  1306. }
  1307. });
  1308. pasteNode.addEvent("click", function(e){
  1309. var selectNode = this.retrieve("slectNode");
  1310. if (selectNode){
  1311. o2.DL.open({
  1312. "isTitle": false,
  1313. "width": 400,
  1314. "height": 500,
  1315. "html": "<textarea style='width: 99%; height: 98%'></textarea>",
  1316. "buttonList": [{
  1317. "type": "ok",
  1318. "text": "ok",
  1319. "action": function(){
  1320. var dataStr = this.content.getElement("textarea").get("value");
  1321. try{
  1322. var data = JSON.decode(dataStr);
  1323. var s = selectNode.retrieve("selector");
  1324. s.setData(data);
  1325. _self.saveScriptSelectItem(selectNode, s.identitys);
  1326. }catch(e){
  1327. throw e;
  1328. }
  1329. this.close();
  1330. }
  1331. },{
  1332. "type": "cancel",
  1333. "text": "cancel",
  1334. "action": function(){this.close();}
  1335. }]
  1336. })
  1337. }
  1338. });
  1339. }
  1340. }.bind(this));
  1341. var _self = this;
  1342. formStyleNodes.each(function(node){
  1343. debugger;
  1344. var data = this.data[node.get("name")];
  1345. if( typeOf( data ) === "string" ){
  1346. for( var key in this.module.form.stylesList ){
  1347. var s = this.module.form.stylesList[key];
  1348. if( ((!data && key=="default") || (data==key)) ){
  1349. data = {
  1350. name : s.name,
  1351. id : key
  1352. };
  1353. break;
  1354. }
  1355. }
  1356. }
  1357. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1358. "type": "FormStyle",
  1359. "count": 1,
  1360. "names": [data],
  1361. "selectorOptions" : {
  1362. "mode" : ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc"
  1363. },
  1364. "validFun" : function (ids) {
  1365. var flag = true;
  1366. if( ids.length === 0 ){
  1367. this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error");
  1368. flag = false;
  1369. }else if( ids[0].data.type === "script" ){
  1370. this.designer.actions.getScriptByName( ids[0].data.name, ids[0].data.application, function( json ) {
  1371. debugger;
  1372. try{
  1373. var f = eval("(function(){\n return "+json.data.text+"\n})");
  1374. var j = f();
  1375. if( typeOf(j) !== "object" ){
  1376. this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
  1377. flag = false;
  1378. }
  1379. }catch (e) {
  1380. this.designer.notice( MWF.APPFD.LP.notValidJson +":"+ e.message, "error" );
  1381. flag = false;
  1382. }
  1383. }.bind(this), function () {
  1384. flag = false;
  1385. }, false);
  1386. }
  1387. return flag;
  1388. }.bind(this),
  1389. "onChange": function(ids){
  1390. var d = ids[0].data;
  1391. var data;
  1392. if( d.type === "script" ){
  1393. data = {
  1394. "type" : "script",
  1395. "name": d.name,
  1396. "alias": d.alias,
  1397. "id": d.id,
  1398. "appName" : d.appName || d.applicationName,
  1399. "appId": d.appId,
  1400. "application": d.application
  1401. };
  1402. }else{
  1403. data = d.id;
  1404. }
  1405. var name = node.get("name");
  1406. var oldValue = this.data[name];
  1407. this.data[name] = data;
  1408. this.changeData(name, node, oldValue);
  1409. }.bind(this)
  1410. });
  1411. var next = node.getNext();
  1412. if( next && next.get("class") === "MWFScriptSelectRefresh" ){
  1413. var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(next);
  1414. refreshNode.addEvent("click", function(e){
  1415. _self.changeData(this.get("name"), this );
  1416. }.bind(node));
  1417. }
  1418. }.bind(this));
  1419. dictionaryNodes.each(function(node){
  1420. var data = this.data[node.get("name")];
  1421. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1422. "type": "Dictionary",
  1423. "count": 0,
  1424. "names": typeOf(data)==="array" ? data : [data],
  1425. "onChange": function(ids){
  1426. var data = [];
  1427. var name = node.get("name");
  1428. if( ids.length > 0 ){
  1429. // var d = ids[0].data;
  1430. ids.each( function (id) {
  1431. debugger;
  1432. var d = id.data;
  1433. data.push({
  1434. "type" : "dictionary",
  1435. "name": d.name,
  1436. "alias": d.alias,
  1437. "id": d.id,
  1438. "appName" : d.appName || d.applicationName,
  1439. "appAlias" : d.appAlias || d.applicationAlias,
  1440. "appId": d.appId,
  1441. "application": d.application,
  1442. "appType" : d.appType
  1443. })
  1444. });
  1445. }
  1446. var oldValue = this.data[name];
  1447. this.data[name] = data;
  1448. this.changeData(name, node, oldValue);
  1449. }.bind(this)
  1450. });
  1451. }.bind(this));
  1452. fileNodes.each(function(node){
  1453. var d = this.data[node.get("name")];
  1454. var data = d || {};
  1455. //this.form
  1456. if (d && typeOf(d)==="string"){
  1457. if (this.form.page){
  1458. data = {"id": d, "portal": this.form.application}
  1459. }else{
  1460. data = {"id": d, "application": this.form.application}
  1461. }
  1462. }
  1463. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1464. "type": "PortalFile",
  1465. "count": 1,
  1466. "isImage": true,
  1467. "values": (data.id) ? [data.id] : [],
  1468. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  1469. });
  1470. }.bind(this));
  1471. processFileNodes.each(function(node){
  1472. var d = this.data[node.get("name")];
  1473. var data = d || {};
  1474. //this.form
  1475. if (d && typeOf(d)==="string"){
  1476. if (this.form.page){
  1477. data = {"id": d, "portal": this.form.application}
  1478. }else{
  1479. data = {"id": d, "application": this.form.application}
  1480. }
  1481. }
  1482. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1483. "type": "ProcessFile",
  1484. "count": 1,
  1485. "isImage": true,
  1486. "values": (data.id) ? [data.id] : [],
  1487. "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
  1488. });
  1489. }.bind(this));
  1490. }.bind(this));
  1491. },
  1492. loadDictionaryIncluder : function(){
  1493. var nodes = this.propertyContent.getElements(".MWFDictionaryIncluder");
  1494. if (nodes.length){
  1495. nodes.each(function(node){
  1496. var name = node.get("name");
  1497. MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictionaryIncluder", function(){
  1498. var dictionaryIncluder = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder(node, this.designer, {
  1499. "onChange": function(){
  1500. var data = dictionaryIncluder.getData();
  1501. this.data[name] = data;
  1502. }.bind(this)
  1503. });
  1504. dictionaryIncluder.load(this.data[name])
  1505. }.bind(this));
  1506. }.bind(this));
  1507. }
  1508. },
  1509. loadScriptIncluder : function(){
  1510. var nodes = this.propertyContent.getElements(".MWFScriptIncluder");
  1511. if (nodes.length){
  1512. nodes.each(function(node){
  1513. var name = node.get("name");
  1514. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ScriptIncluder", function(){
  1515. var scriptIncluder = new MWF.xApplication.process.FormDesigner.widget.ScriptIncluder(node, this.designer, {
  1516. "onChange": function(){
  1517. var data = scriptIncluder.getData();
  1518. this.data[name] = data;
  1519. }.bind(this)
  1520. });
  1521. scriptIncluder.load(this.data[name])
  1522. }.bind(this));
  1523. }.bind(this));
  1524. }
  1525. },
  1526. saveFileItem: function(node, ids){
  1527. if (ids[0]){
  1528. var file = ids[0].data;
  1529. this.data[node.get("name")] = file;
  1530. }else{
  1531. this.data[node.get("name")] = null;
  1532. }
  1533. this.changeData(node.get("name"));
  1534. },
  1535. saveViewItem: function(node, ids){
  1536. if (ids[0]){
  1537. var view = ids[0].data;
  1538. var data = {
  1539. "name": view.name,
  1540. "alias": view.alias,
  1541. "id": view.id,
  1542. "appName" : view.appName || view.applicationName || view.query,
  1543. "appId": view.appId,
  1544. "application": view.application || view.query
  1545. };
  1546. this.data[node.get("name")] = data;
  1547. }else{
  1548. this.data[node.get("name")] = null;
  1549. }
  1550. if (this.module._checkView) this.module._checkView();
  1551. },
  1552. removeViewItem: function(node, item){
  1553. },
  1554. saveScriptSelectItem: function(node, ids){
  1555. var count = (node.dataset["count"] || 1).toInt();
  1556. if (count==1){
  1557. if (ids[0]){
  1558. var script = ids[0].data;
  1559. var data = {
  1560. "appType": script.appType,
  1561. "type" : "script",
  1562. "name": script.name,
  1563. "alias": script.alias,
  1564. "id": script.id,
  1565. "appName" : script.appName || script.applicationName,
  1566. "appId": script.appId,
  1567. "application": script.application
  1568. };
  1569. var name = node.get("name");
  1570. var oldValue = this.data[name];
  1571. this.data[name] = data;
  1572. // this.changeJsonDate(name, data );
  1573. this.changeData(name, node, oldValue);
  1574. }else{
  1575. // this.data[node.get("name")] = null;
  1576. }
  1577. }else{
  1578. var scriptValues = [];
  1579. ids.each(function(s){
  1580. var scriptValue = {
  1581. "appType": s.data.appType,
  1582. "type" : "script",
  1583. "name": s.data.name,
  1584. "alias": s.data.alias,
  1585. "id": s.data.id,
  1586. "appName" : s.data.appName || s.data.applicationName,
  1587. "appId": s.data.appId,
  1588. "application": s.data.application
  1589. }
  1590. scriptValues.push(scriptValue);
  1591. }.bind(this));
  1592. var name = node.get("name");
  1593. var oldValue = this.data[name];
  1594. this.data[name] = scriptValues;
  1595. this.changeData(name, node, oldValue);
  1596. }
  1597. },
  1598. removeDutyItem: function(node, item){
  1599. if (item.data.id){
  1600. var values = JSON.decode(this.data[node.get("name")] || []);
  1601. var value = values.filter(function(v){
  1602. return v.id == item.data.id;
  1603. });
  1604. value.each(function(v) {
  1605. values = values.erase(v);
  1606. });
  1607. this.data[node.get("name")] = JSON.encode(values);
  1608. }
  1609. item.node.destroy();
  1610. MWF.release(item);
  1611. delete item;
  1612. },
  1613. addDutyItem: function(node, ids){
  1614. var value = this.data[node.get("name")] || "";
  1615. if (!value) value = "[]";
  1616. var values = JSON.decode(value);
  1617. ids.each(function(id){
  1618. if (id.data.dutyId){
  1619. for (var i=0; i<values.length; i++){
  1620. if (values[i].dutyId===id.data.dutyId){
  1621. values[i].name = id.data.name;
  1622. values[i].code = id.data.code;
  1623. break;
  1624. }
  1625. }
  1626. }else{
  1627. id.data.dutyId = new MWF.widget.UUID().toString();
  1628. values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
  1629. }
  1630. }.bind(this));
  1631. this.data[node.get("name")] = JSON.encode(values);
  1632. },
  1633. loadFormFieldInput: function(){
  1634. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  1635. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  1636. fieldNodes.each(function(node){
  1637. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  1638. "type": "formField",
  1639. "application": this.form.json.application,
  1640. "fieldType": "person",
  1641. "names": this.data[node.get("name")],
  1642. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  1643. });
  1644. }.bind(this));
  1645. }.bind(this));
  1646. },
  1647. savePersonItem: function(node, ids){
  1648. var values = [];
  1649. ids.each(function(id){
  1650. values.push(MWF.org.parseOrgData(id.data));
  1651. }.bind(this));
  1652. this.data[node.get("name")] = values;
  1653. },
  1654. loadScriptArea: function(){
  1655. var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
  1656. var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
  1657. this.loadScriptEditor(scriptAreas);
  1658. this.loadScriptEditor(formulaAreas, "formula");
  1659. },
  1660. loadScriptEditor: function(scriptAreas, style){
  1661. scriptAreas.each(function(node){
  1662. var title = node.get("title");
  1663. var name = node.get("name");
  1664. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  1665. var scriptContent = this.data[name];
  1666. MWF.require("MWF.widget.ScriptArea", function(){
  1667. var scriptArea = new MWF.widget.ScriptArea(node, {
  1668. "title": title,
  1669. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1670. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1671. "onChange": function(){
  1672. //this.data[name] = scriptArea.toJson();
  1673. if (!this.data[name]){
  1674. this.data[name] = {"code": "", "html": ""};
  1675. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  1676. }
  1677. var json = scriptArea.toJson();
  1678. this.data[name].code = json.code;
  1679. //this.data[name].html = json.html;
  1680. }.bind(this),
  1681. "onSave": function(){
  1682. this.designer.saveForm();
  1683. }.bind(this),
  1684. "style": style || "default",
  1685. "runtime": "web"
  1686. });
  1687. scriptArea.load(scriptContent);
  1688. }.bind(this));
  1689. }.bind(this));
  1690. },
  1691. loadCssArea: function(style){
  1692. var cssAreas = this.propertyContent.getElements(".MWFCssArea");
  1693. cssAreas.each(function(node){
  1694. var title = node.get("title");
  1695. var name = node.get("name");
  1696. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  1697. var cssContent = this.data[name];
  1698. o2.require("o2.widget.CssArea", function(){
  1699. var cssArea = new o2.widget.CssArea(node, {
  1700. "title": title,
  1701. "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
  1702. "onChange": function(){
  1703. //this.data[name] = scriptArea.toJson();
  1704. if (!this.data[name]){
  1705. this.data[name] = {"code": "", "html": ""};
  1706. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  1707. }
  1708. var json = cssArea.toJson();
  1709. this.data[name].code = json.code;
  1710. cssArea.isChanged = true;
  1711. //this.data[name].html = json.html;
  1712. }.bind(this),
  1713. "onBlur": function(){
  1714. if (cssArea.isChanged){
  1715. this.changeData(name, node, "");
  1716. cssArea.isChanged = false;
  1717. }
  1718. }.bind(this),
  1719. "onSave": function(){
  1720. this.designer.saveForm();
  1721. }.bind(this),
  1722. "style": style || "default"
  1723. });
  1724. cssArea.load(cssContent);
  1725. }.bind(this));
  1726. }.bind(this));
  1727. },
  1728. loadActionStylesArea: function(){
  1729. var _self = this;
  1730. var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
  1731. actionAreas.each(function(node){
  1732. var name = node.get("name");
  1733. var actionStyles = this.data[name];
  1734. MWF.require("MWF.widget.Maplist", function(){
  1735. var maps = [];
  1736. Object.each(actionStyles, function(v, k){
  1737. var mapNode = new Element("div").inject(node);
  1738. mapNode.empty();
  1739. var maplist = new MWF.widget.Maplist(mapNode, {
  1740. "title": k,
  1741. "collapse": true,
  1742. "onChange": function(){
  1743. var oldData = _self.data[name];
  1744. maps.each(function(o){
  1745. _self.data[name][o.key] = o.map.toJson();
  1746. }.bind(this));
  1747. _self.changeData(name, node, oldData);
  1748. }
  1749. });
  1750. maps.push({"key": k, "map": maplist});
  1751. maplist.load(v);
  1752. }.bind(this));
  1753. }.bind(this));
  1754. }.bind(this));
  1755. },
  1756. loadActionArea: function(){
  1757. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  1758. multiActionArea.each(function(node){
  1759. var name = node.get("name");
  1760. var actionContent = this.data[name];
  1761. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  1762. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  1763. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1764. "isSystemTool" : true,
  1765. "onChange": function(){
  1766. this.data[name] = actionEditor.data;
  1767. this.changeData(name);
  1768. }.bind(this)
  1769. });
  1770. actionEditor.load(actionContent);
  1771. }.bind(this));
  1772. }.bind(this));
  1773. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  1774. actionAreas.each(function(node){
  1775. var name = node.get("name");
  1776. var actionContent = this.data[name];
  1777. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  1778. // debugger;
  1779. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  1780. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1781. // "noCreate": true,
  1782. // "noDelete": true,
  1783. // "noCode": true,
  1784. // "onChange": function(){
  1785. // this.data[name] = actionEditor.data;
  1786. // }.bind(this)
  1787. // });
  1788. // actionEditor.load(this.module.defaultToolBarsData);
  1789. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  1790. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1791. "onChange": function(){
  1792. this.data[name] = actionEditor.data;
  1793. this.changeData(name);
  1794. }.bind(this)
  1795. });
  1796. actionEditor.load(actionContent);
  1797. }.bind(this));
  1798. }.bind(this));
  1799. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  1800. actionAreas.each(function(node){
  1801. var name = node.get("name");
  1802. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  1803. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  1804. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  1805. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1806. "isSystemTool" : true,
  1807. "noCreate": true,
  1808. "noDelete": false,
  1809. "noCode": true,
  1810. "noReadShow": true,
  1811. "target" : node.get("data-target"),
  1812. "noEditShow": true,
  1813. "onChange": function(){
  1814. this.data[name] = actionEditor.data;
  1815. this.changeData(name);
  1816. }.bind(this)
  1817. });
  1818. actionEditor.load(actionContent);
  1819. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  1820. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  1821. // "onChange": function(){
  1822. // this.data[name] = actionEditor.data;
  1823. // }.bind(this)
  1824. // });
  1825. // actionEditor.load(actionContent);
  1826. }.bind(this));
  1827. }.bind(this));
  1828. },
  1829. loadMaplist: function(){
  1830. var maplists = this.propertyContent.getElements(".MWFMaplist");
  1831. debugger;
  1832. maplists.each(function(node){
  1833. var title = node.get("title");
  1834. var name = node.get("name");
  1835. var collapse = node.get("collapse");
  1836. var mapObj = this.data[name];
  1837. if (!mapObj) mapObj = {};
  1838. MWF.require("MWF.widget.Maplist", function(){
  1839. node.empty();
  1840. var maplist = new MWF.widget.Maplist(node, {
  1841. "title": title,
  1842. "collapse": (collapse) ? true : false,
  1843. "onChange": function(){
  1844. //this.data[name] = maplist.toJson();
  1845. //
  1846. var oldData = this.data[name];
  1847. this.changeJsonDate(name, maplist.toJson());
  1848. this.changeStyle(name, oldData);
  1849. this.changeData(name);
  1850. }.bind(this),
  1851. "onDelete": function(key){
  1852. debugger;
  1853. this.module.deletePropertiesOrStyles(name, key);
  1854. }.bind(this)
  1855. });
  1856. maplist.load(mapObj);
  1857. this.maplists[name] = maplist;
  1858. }.bind(this));
  1859. }.bind(this));
  1860. },
  1861. //loadPropertyTab: function(){
  1862. // var tabNodes = this.propertyContent.getElements(".MWFTab");
  1863. // if (tabNodes.length){
  1864. // var tmpNode = this.propertyContent.getFirst();
  1865. // var tabAreaNode = new Element("div", {
  1866. // "styles": this.form.css.propertyTabNode
  1867. // }).inject(tmpNode, "before");
  1868. //
  1869. // MWF.require("MWF.widget.Tab", function(){
  1870. // var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  1871. // tab.load();
  1872. // var tabPages = [];
  1873. // tabNodes.each(function(node){
  1874. // if (node.getStyle("display")!="none"){
  1875. // var page = tab.addTab(node, node.get("title"), false);
  1876. // tabPages.push(page);
  1877. // page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  1878. // node.inject(page.contentScrollNode);
  1879. // this.setScrollBar(page.contentScrollNode, "small", null, null);
  1880. // }
  1881. // }.bind(this));
  1882. // tabPages[0].showTab();
  1883. //
  1884. // this.propertyTab = tab;
  1885. //
  1886. // this.designer.resizeNode();
  1887. // }.bind(this), false);
  1888. // }
  1889. //},
  1890. loadPropertyTab: function(){
  1891. var tabNodes = this.propertyContent.getElements(".MWFTab");
  1892. var groupObject = {}; //data-group 属性可以表示不同的分组
  1893. if (tabNodes.length){
  1894. tabNodes.each( function(node){
  1895. var group = node.get("data-group") || "default";
  1896. groupObject[group] = groupObject[group] || [];
  1897. groupObject[group].push( node );
  1898. }.bind(this))
  1899. }
  1900. for( var group in groupObject ){
  1901. if( group === "default" ){
  1902. var tmpNode = this.propertyContent.getFirst();
  1903. var tabAreaNode = new Element("div", {
  1904. "styles": this.form.css.propertyTabNode
  1905. }).inject(tmpNode, "before");
  1906. MWF.require("MWF.widget.Tab", function(){
  1907. var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
  1908. tab.load();
  1909. var tabPages = [];
  1910. groupObject["default"].each(function(node){
  1911. if (node.getStyle("display")!="none"){
  1912. var page = tab.addTab(node, node.get("title"), false);
  1913. tabPages.push(page);
  1914. page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
  1915. node.inject(page.contentScrollNode);
  1916. this.setScrollBar(page.contentScrollNode, "small", null, null);
  1917. }
  1918. }.bind(this));
  1919. tabPages[0].showTab();
  1920. this.propertyTab = tab;
  1921. this.designer.resizeNode();
  1922. }.bind(this), false);
  1923. }else{
  1924. var tmpNode = groupObject[group][0];
  1925. var tabAreaNode = new Element("div", {
  1926. "styles": this.form.css.propertyTabNode
  1927. }).inject(tmpNode, "before");
  1928. MWF.require("MWF.widget.Tab", function(){
  1929. var tab = new MWF.widget.Tab(tabAreaNode, {"style": tmpNode.get("data-style") || "formPropertyList"});
  1930. tab.load();
  1931. var tabPages = [];
  1932. groupObject[group].each(function(node) {
  1933. var page = tab.addTab(node, node.get("title"), false);
  1934. tabPages.push(page);
  1935. node.store("tab", page);
  1936. if (node.getStyle("display") === "none"){
  1937. page.disableTab( true );
  1938. node.show();
  1939. }
  1940. }.bind(this));
  1941. for( var i=0; i<tabPages.length; i++ ){
  1942. if( !tabPages[i].disabled ){
  1943. tabPages[i].showTab();
  1944. break
  1945. }
  1946. }
  1947. }.bind(this), false);
  1948. }
  1949. }
  1950. },
  1951. setEditNodeEvent: function(){
  1952. var property = this;
  1953. // var inputs = this.process.propertyListNode.getElements(".editTableInput");
  1954. var inputs = this.propertyContent.getElements("input");
  1955. inputs.each(function(input){
  1956. var jsondata = input.get("name");
  1957. if (this.module){
  1958. var id = this.data.pid;
  1959. //var id = this.form.json.id;
  1960. // input.set("name", this.form.options.mode+id+jsondata);
  1961. input.set("name", id+jsondata);
  1962. }
  1963. if (jsondata){
  1964. var inputType = input.get("type").toLowerCase();
  1965. switch (inputType){
  1966. case "radio":
  1967. input.addEvent("change", function(e){
  1968. property.setRadioValue(jsondata, this);
  1969. });
  1970. input.addEvent("blur", function(e){
  1971. property.setRadioValue(jsondata, this);
  1972. });
  1973. input.addEvent("keydown", function(e){
  1974. e.stopPropagation();
  1975. });
  1976. property.setRadioValue(jsondata, input);
  1977. break;
  1978. case "checkbox":
  1979. input.addEvent("change", function(e){
  1980. property.setCheckboxValue(jsondata, this);
  1981. });
  1982. input.addEvent("click", function(e){
  1983. property.setCheckboxValue(jsondata, this);
  1984. });
  1985. input.addEvent("keydown", function(e){
  1986. e.stopPropagation();
  1987. });
  1988. break;
  1989. default:
  1990. input.addEvent("change", function(e){
  1991. property.setValue(jsondata, this.value, this);
  1992. });
  1993. input.addEvent("blur", function(e){
  1994. property.setValue(jsondata, this.value, this);
  1995. });
  1996. input.addEvent("keydown", function(e){
  1997. if (e.code==13){
  1998. property.setValue(jsondata, this.value, this);
  1999. }
  2000. e.stopPropagation();
  2001. });
  2002. }
  2003. }
  2004. }.bind(this));
  2005. var selects = this.propertyContent.getElements("select");
  2006. selects.each(function(select){
  2007. var jsondata = select.get("name");
  2008. if (jsondata){
  2009. select.addEvent("change", function(e){
  2010. property.setSelectValue(jsondata, this);
  2011. });
  2012. //property.setSelectValue(jsondata, select);
  2013. }
  2014. });
  2015. var textareas = this.propertyContent.getElements("textarea");
  2016. textareas.each(function(input){
  2017. var jsondata = input.get("name");
  2018. if (jsondata){
  2019. input.addEvent("change", function(e){
  2020. property.setValue(jsondata, this.value);
  2021. });
  2022. input.addEvent("blur", function(e){
  2023. property.setValue(jsondata, this.value);
  2024. });
  2025. input.addEvent("keydown", function(e){
  2026. e.stopPropagation();
  2027. });
  2028. }
  2029. }.bind(this));
  2030. },
  2031. changeStyle: function(name, oldData){
  2032. this.module.setPropertiesOrStyles(name, oldData);
  2033. },
  2034. changeData: function(name, input, oldValue){
  2035. this.module._setEditStyle(name, input, oldValue);
  2036. },
  2037. changeJsonDate: function(key, value){
  2038. if (typeOf(key)!=="array") key = [key];
  2039. var o = this.data;
  2040. var len = key.length-1;
  2041. key.each(function(n, i){
  2042. if (!o[n]) o[n] = {};
  2043. if (i<len) o = o[n];
  2044. }.bind(this));
  2045. o[key[len]] = value;
  2046. //this.data[key] = value;
  2047. },
  2048. setRadioValue: function(name, input){
  2049. if (input.checked){
  2050. var i = name.indexOf("*");
  2051. var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");
  2052. var value = input.value;
  2053. if (value=="false") value = false;
  2054. if (value=="true") value = true;
  2055. var oldValue = this.data;
  2056. for (var idx = 0; idx<names.length; idx++){
  2057. if (!oldValue[names[idx]]){
  2058. oldValue = null;
  2059. break;
  2060. }else{
  2061. oldValue = oldValue[names[idx]];
  2062. }
  2063. }
  2064. // var value = input.value;
  2065. // if (value==="false") value = false;
  2066. // if (value==="true") value = true;
  2067. //var oldValue = this.data[name];
  2068. this.changeJsonDate(names, value);
  2069. this.changeData(name, input, oldValue);
  2070. }
  2071. },
  2072. setCheckboxValue: function(name, input){
  2073. //var id = this.module.json.id;
  2074. //var id = this.form.json.id;
  2075. var id = this.data.pid;
  2076. // var checkboxList = $$("input[name='"+this.form.options.mode+id+name+"']");
  2077. var checkboxList = $$("input[name='"+id+name+"']");
  2078. var values = [];
  2079. checkboxList.each(function(checkbox){
  2080. if (checkbox.get("checked")){
  2081. values.push(checkbox.value);
  2082. }
  2083. });
  2084. var oldValue = this.data[name];
  2085. //this.data[name] = values;
  2086. this.changeJsonDate(name, values);
  2087. this.changeData(name, input, oldValue);
  2088. },
  2089. setSelectValue: function(name, select){
  2090. var idx = select.selectedIndex;
  2091. var options = select.getElements("option");
  2092. var value = "";
  2093. if (options[idx]){
  2094. value = options[idx].get("value");
  2095. }
  2096. var oldValue = this.data[name];
  2097. //this.data[name] = value;
  2098. this.changeJsonDate(name, value);
  2099. this.changeData(name, select, oldValue);
  2100. },
  2101. setValue: function(name, value, obj){
  2102. if (name==="id"){
  2103. if (value!==this.module.json.id) {
  2104. if (!value) {
  2105. this.designer.notice(MWF.APPFD.LP.notNullId, "error", this.module.form.designer.propertyContentArea, {
  2106. x: "right",
  2107. y: "bottom"
  2108. });
  2109. obj.focus();
  2110. return false;
  2111. } else {
  2112. var check = this.module.form.checkModuleId(value, this.module.json.type);
  2113. if (check.elementConflict) {
  2114. this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {
  2115. x: "right",
  2116. y: "bottom"
  2117. });
  2118. obj.focus();
  2119. return false;
  2120. } else {
  2121. var json = this.module.form.json.moduleList[this.module.json.id];
  2122. this.module.form.json.moduleList[value] = json;
  2123. delete this.module.form.json.moduleList[this.module.json.id];
  2124. }
  2125. }
  2126. // if (this.module.form.json.moduleList[value]){
  2127. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  2128. // obj.focus();
  2129. // return false;
  2130. // }else{
  2131. // var flag = false;
  2132. // if (this.module.form.subformList){
  2133. // Object.each(this.module.form.subformList, function(o, k){
  2134. // if (o.subformData.moduleList[value] && o.subformData.moduleList[value] ) flag = true;
  2135. // });
  2136. // }
  2137. // if (flag){
  2138. // this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
  2139. // obj.focus();
  2140. // return false;
  2141. // }else{
  2142. // var json = this.module.form.json.moduleList[this.module.json.id];
  2143. // this.module.form.json.moduleList[value]=json;
  2144. // delete this.module.form.json.moduleList[this.module.json.id];
  2145. // }
  2146. // }
  2147. }
  2148. }
  2149. //var oldValue = this.data[name];
  2150. var names = name.split(".");
  2151. var oldValue = this.data;
  2152. for (var idx = 0; idx<names.length; idx++){
  2153. if (!oldValue[names[idx]]){
  2154. oldValue = null;
  2155. break;
  2156. }else{
  2157. oldValue = oldValue[names[idx]];
  2158. }
  2159. }
  2160. //this.data[name] = value;
  2161. this.changeJsonDate(names, value);
  2162. this.changeData(name, obj, oldValue);
  2163. },
  2164. setEditNodeStyles: function(node){
  2165. var nodes = node.getChildren();
  2166. if (nodes.length){
  2167. nodes.each(function(el){
  2168. var cName = el.get("class");
  2169. if (cName){
  2170. if (this.form.css[cName]) el.setStyles(this.form.css[cName]);
  2171. }
  2172. this.setEditNodeStyles(el);
  2173. }.bind(this));
  2174. }
  2175. },
  2176. loadScriptInput: function(){
  2177. var scriptNodes = this.propertyContent.getElements(".MWFScript");
  2178. scriptNodes.each(function(node){
  2179. MWF.require("MWF.widget.ScriptEditor", function(){
  2180. var script = new MWF.widget.ScriptEditor(node, {
  2181. "onPostSave": function(script){
  2182. this.saveScriptItem(node, script);
  2183. }.bind(this),
  2184. "onQueryDelete": function(script){
  2185. this.deleteScriptItem(node, script);
  2186. }.bind(this)
  2187. });
  2188. this.setScriptItems(script, node);
  2189. }.bind(this));
  2190. }.bind(this));
  2191. },
  2192. deleteScriptItem: function(node, script){
  2193. var jsondata = node.get("name");
  2194. this.data[jsondata].erase(script.data.id);
  2195. this.process.scripts[script.data.id] = null;
  2196. delete this.process.scripts[script.data.id];
  2197. this.process.process.scriptList.erase(script.data);
  2198. },
  2199. saveScriptItem: function(node, script){
  2200. var jsondata = node.get("name");
  2201. var scriptList = this.data[jsondata];
  2202. var data = script.data;
  2203. var scriptData = this.process.scripts[script.data.id];
  2204. if (!scriptData){
  2205. this.process.process.scriptList.push(data);
  2206. this.process.scripts[script.data.id] = data;
  2207. }
  2208. if (scriptList.indexOf(data.id) == -1){
  2209. this.data[jsondata].push(data.id);
  2210. }
  2211. },
  2212. setScriptItems: function(script, node){
  2213. var jsondata = node.get("name");
  2214. var scriptList = this.data[jsondata];
  2215. scriptList.each(function(id){
  2216. if (id){
  2217. var data = this.process.scripts[id];
  2218. if (data) script.setScriptItem(data);
  2219. }
  2220. }.bind(this));
  2221. }
  2222. });
  2223. MWF.xApplication.process.FormDesigner.PropertyMulti = new Class({
  2224. Extends: MWF.xApplication.process.FormDesigner.Property,
  2225. Implements: [Options, Events],
  2226. initialize: function(form, modules, propertyNode, designer, options){
  2227. this.setOptions(options);
  2228. this.modules = modules;
  2229. this.form = form;
  2230. // this.data = module.json;
  2231. this.data = {};
  2232. this.htmlPath = this.options.path;
  2233. this.designer = designer;
  2234. this.maplists = {};
  2235. this.propertyNode = propertyNode;
  2236. },
  2237. load: function(){
  2238. if (this.fireEvent("queryLoad")){
  2239. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  2240. this.htmlString = responseText;
  2241. MWF.require("MWF.widget.JsonTemplate", function(){
  2242. this.fireEvent("postLoad");
  2243. }.bind(this));
  2244. }.bind(this));
  2245. }
  2246. },
  2247. show: function(){
  2248. if (!this.propertyContent){
  2249. if (this.htmlString){
  2250. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  2251. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  2252. this.propertyContent.set("html", this.JsonTemplate.load());
  2253. this.setEditNodeEvent();
  2254. this.setEditNodeStyles(this.propertyContent);
  2255. this.loadPropertyTab();
  2256. this.loadMaplist();
  2257. this.loadScriptArea();
  2258. this.loadTreeData();
  2259. this.loadArrayList();
  2260. //this.loadEventsEditor();
  2261. //this.loadHTMLArea();
  2262. //this.loadJSONArea();
  2263. // this.loadScriptInput();
  2264. //MWF.process.widget.EventsEditor
  2265. }
  2266. }else{
  2267. this.propertyContent.setStyle("display", "block");
  2268. }
  2269. },
  2270. hide: function(){
  2271. if (this.propertyContent) this.propertyContent.destroy();
  2272. },
  2273. changeStyle: function(name){
  2274. this.modules.each(function(module){
  2275. module.setPropertiesOrStyles(name);
  2276. }.bind(this));
  2277. },
  2278. changeData: function(name, input, oldValue){
  2279. this.modules.each(function(module){
  2280. module._setEditStyle(name, input, oldValue);
  2281. }.bind(this));
  2282. },
  2283. changeJsonDate: function(key, value){
  2284. //alert(key+": "+value );
  2285. this.modules.each(function(module){
  2286. module.json[key] = value;
  2287. }.bind(this));
  2288. },
  2289. });