Property.js 98.1 KB
Newer Older
NoSubject's avatar
NoSubject 已提交
1 2 3 4 5 6 7
MWF.require("MWF.widget.Common", null, false);
MWF.require("MWF.widget.JsonTemplate", null, false);
MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = new Class({
	Extends: MWF.widget.Common,
	Implements: [Options, Events],
	options: {
		"style": "default",
8
		"path": "../x_component_process_FormDesigner/property/property.html"
NoSubject's avatar
NoSubject 已提交
9 10 11 12 13 14 15
	},
	
	initialize: function(module, propertyNode, designer, options){
		this.setOptions(options);
		this.module = module;
		this.form = module.form;
		this.data = module.json;
U
unknown 已提交
16
		this.data.pid = this.form.options.mode+this.form.json.id+this.data.id;
NoSubject's avatar
NoSubject 已提交
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
		this.htmlPath = this.options.path;
		this.designer = designer;
		this.maplists = {};
		this.propertyNode = propertyNode;
	},

	load: function(){
		if (this.fireEvent("queryLoad")){
			MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
				this.htmlString = responseText;
				this.fireEvent("postLoad");
			}.bind(this));
		}
        this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
	},
	editProperty: function(td){
	},
    getHtmlString: function(callback){
        if (!this.htmlString){
            MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
                this.htmlString = responseText;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },
	show: function(){
        if (!this.propertyContent){
            this.getHtmlString(function(){
                if (this.htmlString){
                    this.JsonTemplate = new MWF.widget.JsonTemplate(this.data, this.htmlString);
                    this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
                    this.propertyContent.set("html", this.JsonTemplate.load());

                    this.setEditNodeEvent();
                    this.setEditNodeStyles(this.propertyContent);
                    this.loadPropertyTab();
                    this.loadMaplist();
                    this.loadStylesList();
                    this.loadDivTemplateType();
                    this.loadPersonInput();
                    this.loadFormFieldInput();
                    this.loadScriptArea();
                    this.loadCssArea();
                    this.loadHtmlEditorArea();
                    this.loadTreeData();
                    this.loadArrayList();
                    this.loadEventsEditor();
                    this.loadActionArea();
NoSubject's avatar
NoSubject 已提交
67
                    this.loadActionStylesArea();
NoSubject's avatar
NoSubject 已提交
68 69 70
                    this.loadHTMLArea();
                    this.loadJSONArea();
                    this.loadFormSelect();
R
roo00 已提交
71
                    this.loadSubformSelect();
NoSubject's avatar
NoSubject 已提交
72 73
                    //this.loadPageSelect();
                    this.loadWidgetSelect();
NoSubject's avatar
NoSubject 已提交
74
                    this.loadANNModelSelect();
NoSubject's avatar
NoSubject 已提交
75 76 77 78 79
                    //this.loadViewSelect();
                    this.loadValidation();
                    this.loadIconSelect();
                    this.loadLabelFlagSelect();
                    this.loadImageClipper();
NoSubject's avatar
NoSubject 已提交
80
                    this.loadImageFileSelect();
NoSubject's avatar
NoSubject 已提交
81 82 83 84 85 86
                    this.loadParameterEditor();
                    this.loadContextRoot();
                    this.loadUnitTypeSelector();
                    this.loadSourceTestRestful();
                    this.loadSidebarPosition();
                    this.loadViewFilter();
U
unknown 已提交
87
                    this.loadStatementFilter();
R
roo00 已提交
88
                    this.loadDocumentTempleteSelect();
89 90
                    // this.loadScriptIncluder();
                    // this.loadDictionaryIncluder();
NoSubject's avatar
NoSubject 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
                    //this.testRestful();
//			this.loadScriptInput();
                    //MWF.process.widget.EventsEditor
                }
            }.bind(this));
        }else{
            this.propertyContent.setStyle("display", "block");
        }

        (new Fx.Scroll(layout.desktop.node)).toTop();

	},
	hide: function(){
		//this.JsonTemplate = null;
		//this.propertyNode.set("html", "");
        if (this.propertyContent) this.propertyContent.setStyle("display", "none");
	},
    destroy: function(){
        if (this.propertyContent){
            this.propertyContent.destroy();
        }
NoSubject's avatar
NoSubject 已提交
112
        MWF.release(this);
NoSubject's avatar
NoSubject 已提交
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
    },
	
	loadTreeData: function(){
		var arrays = this.propertyContent.getElements(".MWFTreeData");
		arrays.each(function(node){
			var title = node.get("title");
			var name = node.get("name");
			var json = this.data[name];
			if (!json) json = [];
			MWF.require("MWF.widget.TreeEditor", function(){
				var treeEditor = new MWF.widget.TreeEditor(node, {
					"title": title,
					"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
					"onChange": function(){
						this.data[name] = treeEditor.toJson();
						this.module.json[name] = this.data[name];

						this.module._refreshTree();
					}.bind(this)
				});
				treeEditor.load(json);
			}.bind(this));
            node.addEvent("keydown", function(e){e.stopPropagation();});
		}.bind(this));
	},

	loadJSONArea: function(){
		var jsonNode = this.propertyContent.getElement(".MWFJSONArea");

        if (jsonNode){
            this.propertyTab.pages.each(function(page){
                if (page.contentNode === jsonNode.parentElement){
                    page.setOptions({
                        "onShow": function(){
                            jsonNode.empty();
                            MWF.require("MWF.widget.JsonParse", function(){
                                this.json = new MWF.widget.JsonParse(this.module.json, jsonNode, null);
                                this.json.load();
                            }.bind(this));
                        }.bind(this)
                    });
                }
            }.bind(this));
        }
	},
	loadHTMLArea: function(){
		var htmlNode = this.propertyContent.getElement(".MWFHTMLArea");
		if (htmlNode){
			var copy = this.module.node.clone(true, true);
			copy.clearStyles(true);
			htmlNode.set("text", copy.outerHTML);
			copy.destroy();

			this.propertyTab.pages.each(function(page){
				if (page.contentNode == htmlNode.parentElement){
					page.setOptions({
						"onShow": function(){
							var copy = this.module.node.clone(true, true);
							copy.clearStyles(true);

                            //MWF.require("MWF.widget.HtmlEditor", function(){
                            //    debugger;
                            //    var editor = new MWF.widget.HtmlEditor(htmlNode);
                            //    editor.load(function(){
                            //        editor.editor.setValue(copy.outerHTML)
                            //    }.bind(this));
                            //}.bind(this));

                            o2.load("JSBeautifier_html", function(){
                                htmlNode.set("text", html_beautify(copy.outerHTML, {"indent_size":1}));
                            }.bind(this));

NoSubject's avatar
NoSubject 已提交
185 186 187 188 189 190
                            o2.require("o2.widget.ace", function(){
                                MWF.widget.ace.load(function(){
                                    COMMON.AjaxModule.loadDom("../o2_lib/ace/src-min-noconflict/ext-static_highlight.js", function(){
                                        var highlight = ace.require("ace/ext/static_highlight");
                                        highlight(htmlNode, {mode: "ace/mode/html", theme: "ace/theme/eclipse", "fontSize": 16});
                                    }.bind(this));
NoSubject's avatar
NoSubject 已提交
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
                                }.bind(this));
                            }.bind(this));

							copy.destroy();
						}.bind(this)
					});
				}
			}.bind(this));
		}
	},
    loadSidebarPosition: function(){
        var nodes = this.propertyContent.getElements(".MWFSidebarReposition");
        if (nodes.length){
            nodes.each(function(node){
                node.addEvent("click", function(){
                    this.module.json.styles.top = "";
                    this.module.loadPosition();
                }.bind(this));
            }.bind(this));
        }
    },
NoSubject's avatar
NoSubject 已提交
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
    loadANNModelSelect: function(){
        var nodes = this.propertyContent.getElements(".MWFANNModelSelect");
        if (nodes.length){
            this.getModelList(function(){
                nodes.each(function(node){
                    var select = new Element("select").inject(node);
                    select.addEvent("change", function(e){
                        this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
                    }.bind(this));
                    this.setModelSelectOptions(node, select);

                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    refreshNode.addEvent("click", function(e){
                        this.getModelList(function(){
                            this.setModelSelectOptions(node, select);
                        }.bind(this), true);
                    }.bind(this));

                }.bind(this));
            }.bind(this));
        }
    },
    getModelList: function(callback, refresh){
        if (!this.models || refresh){
            var action = o2.Actions.get("x_query_assemble_designer");
            if (action.listModel) action.listModel(function(json){
                this.models = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },
    setModelSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.models.each(function(model){
            var option = new Element("option", {
                "text": model.name,
                "value": model.id,
                "selected": (this.data[name]==model.id)
            }).inject(select);
        }.bind(this));
    },
NoSubject's avatar
NoSubject 已提交
257 258 259 260 261 262
    loadFormSelect: function(){
        var formNodes = this.propertyContent.getElements(".MWFFormSelect");
        if (formNodes.length){
            this.getFormList(function(){
                formNodes.each(function(node){
                    var select = new Element("select").inject(node);
R
roo00 已提交
263

NoSubject's avatar
NoSubject 已提交
264
                    select.addEvent("change", function(e){
NoSubject's avatar
NoSubject 已提交
265
                        var value = e.target.options[e.target.selectedIndex].value;
R
roo00 已提交
266
                        this.setValue(e.target.getParent("div").get("name"), value, select);
NoSubject's avatar
NoSubject 已提交
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287
                    }.bind(this));
                    this.setFormSelectOptions(node, select);

                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    refreshNode.addEvent("click", function(e){
                        this.getFormList(function(){
                            this.setFormSelectOptions(node, select);
                        }.bind(this), true);
                    }.bind(this));
                    //select.addEvent("click", function(e){
                    //    this.setFormSelectOptions(node, select);
                    //}.bind(this));
                }.bind(this));
            }.bind(this));
        }
    },
    setFormSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.forms.each(function(form){
NoSubject's avatar
NoSubject 已提交
288 289 290 291 292 293 294
            if( this.form.json.id !== form.id ){
                var option = new Element("option", {
                    "text": form.name,
                    "value": form.id,
                    "selected": (this.data[name]==form.id)
                }).inject(select);
            }
NoSubject's avatar
NoSubject 已提交
295 296 297 298 299 300 301 302 303 304 305 306
        }.bind(this));
    },
    getFormList: function(callback, refresh){
        if (!this.forms || refresh){
            this.form.designer.actions.listForm(this.form.designer.application.id, function(json){
                this.forms = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },
NoSubject's avatar
NoSubject 已提交
307

R
roo00 已提交
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394

    loadSubformSelect: function(){
        var subformContainers = this.propertyContent.getElements(".MWFSubFormSelectContainer");
        if (subformContainers.length){
            subformContainers.each( function( container ){
                var appSelectNode = container.getElement(".MWFSubformAppSelect");
                var formSelectNode = container.getElement(".MWFSubformSelect");
                var formSelect;

                var appNodeName = appSelectNode.get("name");
                var formNodeName = formSelectNode.get("name");

                this.loadProcessApplictionSelect( appSelectNode, appNodeName, function( apps ){
                    var oldValue = this.data[appNodeName] || "";
                    this.data[appNodeName] = !apps.length ? "" : apps[0].data.id;
                    if( oldValue !== this.data[appNodeName] ){
                        this.getSubFormList(function(){
                            this.setSubformSelectOptions(formSelectNode, formSelect);
                            formSelect.fireEvent("change");
                        }.bind(this), true, appNodeName);
                    }
                }.bind(this));
                formSelect = this._loadSubformSelect( formSelectNode, formNodeName,  appNodeName ) ;
            }.bind(this))
        }
    },
    loadProcessApplictionSelect : function( node, appNodeName, callback ){
        var application = appNodeName ? this.data[appNodeName] : "";
        MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function() {
            new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                "title" : this.form.designer.lp.selectApplication,
                "type": "application",
                "count" : 1,
                "names": application ? [ {id : application} ] : [],
                "onChange": function (apps) {
                    callback(apps)
                }.bind(this)
            });
        }.bind(this))
    },
    _loadSubformSelect : function( node, formNodeName, appNodeName ){
        var select;
        this.getSubFormList(function(){
            select = new Element("select").inject(node);

            select.addEvent("change", function(e){
                var value = select.options[select.selectedIndex].value;
                this.setValue(formNodeName, value, select);
            }.bind(this));
            this.setSubformSelectOptions(node, select);

            var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
            refreshNode.addEvent("click", function(e){
                this.getSubFormList(function(){
                    this.setSubformSelectOptions(node, select);
                }.bind(this), true, appNodeName);
            }.bind(this));
        }.bind(this), false, appNodeName );
        return select;
    },
    setSubformSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.subforms.each(function(subforms){
            if( this.form.json.id !== subforms.id ){
                var option = new Element("option", {
                    "text": subforms.name,
                    "value": subforms.id,
                    "selected": (this.data[name]==subforms.id)
                }).inject(select);
            }
        }.bind(this));
    },
    getSubFormList: function(callback, refresh, appNodeName){
        var application = appNodeName ? this.data[appNodeName] : "";
        if (!this.subforms || refresh){
            this.form.designer.actions.listForm( application || this.form.designer.application.id, function(json){
                this.subforms = json.data;
                if (callback) callback();
            }.bind(this), null, false);
        }else{
            if (callback) callback();
        }
    },


NoSubject's avatar
NoSubject 已提交
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
    loadPageSelect: function(){
        var pageNodes = this.propertyContent.getElements(".MWFPageSelect");
        if (pageNodes.length){
            this.getPageList(function(){
                pageNodes.each(function(node){
                    var select = new Element("select").inject(node);
                    select.addEvent("change", function(e){
                        var value = e.target.options[e.target.selectedIndex].value;
                        this.setValue(e.target.getParent("div").get("name"), value, select);
                    }.bind(this));
                    this.setPageSelectOptions(node, select);

                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    refreshNode.addEvent("click", function(e){
                        this.getPageList(function(){
                            this.setPageSelectOptions(node, select);
                        }.bind(this), true);
                    }.bind(this));
                }.bind(this));
            }.bind(this));
        }
    },
    setPageSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.pages.each(function(page){
            if( this.form.json.id !== page.id ){
                var option = new Element("option", {
                    "text": page.name,
                    "value": page.id,
                    "selected": (this.data[name]==page.id)
                }).inject(select);
            }
        }.bind(this));
    },
    getPageList: function(callback, refresh){
        if (!this.pages || refresh){
            this.form.designer.actions.listPage(this.form.designer.application.id, function(json){
                this.pages = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },

    loadWidgetSelect: function(){
        var widgetNodes = this.propertyContent.getElements(".MWFWidgetSelect");
        if (widgetNodes.length){
            this.getWidgetList(function(){
                widgetNodes.each(function(node){
                    var select = new Element("select").inject(node);
                    select.addEvent("change", function(e){
                        var value = e.target.options[e.target.selectedIndex].value;
                        this.setValue(e.target.getParent("div").get("name"), value, select);
                    }.bind(this));
                    this.setWidgetSelectOptions(node, select);

                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    refreshNode.addEvent("click", function(e){
                        this.getWidgetList(function(){
                            this.setWidgetSelectOptions(node, select);
                        }.bind(this), true);
                    }.bind(this));
                }.bind(this));
            }.bind(this));
        }
    },
    setWidgetSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.widgets.each(function(widget){
            if( this.form.json.id !== widget.id ){
                var option = new Element("option", {
                    "text": widget.name,
                    "value": widget.id,
                    "selected": (this.data[name]==widget.id)
                }).inject(select);
            }
        }.bind(this));
    },
    getWidgetList: function(callback, refresh){
        if (!this.widgets || refresh){
            this.form.designer.actions.listWidget(this.form.designer.application.id, function(json){
                this.widgets = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },

NoSubject's avatar
NoSubject 已提交
489 490 491 492 493 494 495 496
//	clearStyles: function(node){
//		node.removeProperty("style");
//		var subNode = node.getFirst();
//		while (subNode){
//			this.clearStyles(subNode);
//			subNode = subNode.getNext();
//		}
//	},
R
roo00 已提交
497 498 499
    loadDocumentTempleteSelect: function(){
        var nodes = this.propertyContent.getElements(".MWFDocumentTempleteSelect");
        if (nodes.length){
500
            o2.getJSON("../x_component_process_FormDesigner/Module/Documenteditor/templete/templete.json", function(json){
R
roo00 已提交
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
                nodes.each(function(node){
                    var name = node.get("name");
                    Object.each(json, function(o, k){
                        new Element("option", {
                            "text": o.name,
                            "value": k,
                            "selected": (this.data[name]==k)
                        }).inject(node);
                    }.bind(this));
                    node.addEvent("change", function(e){
                        var oldValue = this.data[name];
                        var value = e.target.options[e.target.selectedIndex].value;
                        var name = e.target.options[e.target.selectedIndex].get("text");
                        this.changeJsonDate([name], value);
                        this.changeData(name, node, oldValue);
                    }.bind(this));
                }.bind(this));
            }.bind(this));
        }
    },
U
unknown 已提交
521
    loadStatementFilter: function(){
U
unknown 已提交
522
	    debugger;
U
unknown 已提交
523 524 525 526 527 528
        var nodes = this.propertyContent.getElements(".MWFStatementFilter");
        var filtrData = this.data.filterList;
        nodes.each(function(node){
            MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilter", function(){
                var _slef = this;
                new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
U
unknown 已提交
529 530
                    "statementId" : this.data.queryStatement ? this.data.queryStatement.id : "",
                    "withForm" : true,
U
unknown 已提交
531 532 533 534 535 536 537 538 539
                    "onChange": function(ids){
                        var data = this.getData();
                        _slef.changeJsonDate(["filterList"], data.data);
                        //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
                    }
                });
            }.bind(this));
        }.bind(this));
    },
NoSubject's avatar
NoSubject 已提交
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
    loadViewFilter: function(){
        var nodes = this.propertyContent.getElements(".MWFViewFilter");
        var filtrData = this.data.filterList;
        nodes.each(function(node){
            MWF.xDesktop.requireApp("query.ViewDesigner", "widget.ViewFilter", function(){
                var _slef = this;
                new MWF.xApplication.query.ViewDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
                    "onChange": function(ids){
                        var data = this.getData();
                        _slef.changeJsonDate(["filterList"], data.data);
                        //_slef.changeJsonDate(["data", "customFilterEntryList"], data.customData);
                    }
                });
            }.bind(this));
        }.bind(this));
    },
    loadViewSelect: function(){
        var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
        if (viewNodes.length){
            this.getViewList(function(){
                viewNodes.each(function(node){
                    var select = new Element("select").inject(node);
                    select.addEvent("change", function(e){
                        var viewId = e.target.options[e.target.selectedIndex].value;
                        var viewName = e.target.options[e.target.selectedIndex].get("text");
                        this.setValue(e.target.getParent("div").get("name"), viewId);
                        this.setValue(e.target.getParent("div").get("name")+"Name", viewName);
                    }.bind(this));
                    this.setViewSelectOptions(node, select);

                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    refreshNode.addEvent("click", function(e){
                        this.getViewList(function(){
                            this.setViewSelectOptions(node, select);
                        }.bind(this), true);
                    }.bind(this));
                    //select.addEvent("click", function(e){
                    //    this.setFormSelectOptions(node, select);
                    //}.bind(this));
                }.bind(this));
            }.bind(this));
        }
    },
    setViewSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.views.each(function(view){
            var option = new Element("option", {
                "text": view.name,
                "value": view.id,
                "selected": (this.data[name]==view.id)
            }).inject(select);
        }.bind(this));
    },
    getViewList: function(callback, refresh){
        if (!this.views || refresh){
            this.form.designer.actions.listView(this.form.designer.application.id, function(json){
                this.views = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },

    loadValidation: function(){
        var nodes = this.propertyContent.getElements(".MWFValidation");
        if (nodes.length){
            nodes.each(function(node){
                var name = node.get("name");
                MWF.xDesktop.requireApp("process.FormDesigner", "widget.ValidationEditor", function(){
                    var validationEditor = new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer, {
                        "onChange": function(){
                            var data = validationEditor.getValidationData();
                            this.data[name] = data;
                        }.bind(this)
                    });
                    validationEditor.load(this.data[name])
                }.bind(this));

                //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
            }.bind(this));
        }
    },

    loadIconSelect: function(){
        var nodes = this.propertyContent.getElements(".MWFIcon");
        if (nodes.length){
            nodes.each(function(node){
                var id = node.get("name");
                var icon = this.data[id];
                var iconNode = new Element("div", {"styles": this.form.css.processIconNode}).inject(node);
                if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});
                var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectIcon}).inject(node);
                selectNode.addEvent("click", function(){
                    this.selectIcon(node);
                }.bind(this));


            }.bind(this));
        }
    },
    selectIcon: function(node){
        if (!node.iconMenu){
            var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "processIcon"});
            iconSelectMenu.load();
            node.iconMenu = iconSelectMenu;
            var _self = this;
            for (var i=0; i<=48; i++){
650
                var icon = "../x_component_process_ProcessManager/$Explorer/default/processIcon/process_icon_"+i+".png";
NoSubject's avatar
NoSubject 已提交
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694
                var item = iconSelectMenu.addMenuItem("", "click", function(){
                    var id = node.get("name");
                    var src = this.item.getElement("img").get("src");

                    _self.data[id] = src;
                    node.getFirst("div").setStyle("background-image", "url("+src+")");
                }, icon);
                item.iconName = icon;
            }
        }
    },

    loadLabelFlagSelect: function(){
        var nodes = this.propertyContent.getElements(".MWFLabelFlag");
        if (nodes.length){
            nodes.each(function(node){
                var id = node.get("name");
                var icon = this.data[id];
                var iconNode = new Element("div", {"styles": this.form.css.labelFlagNode}).inject(node);
                if (icon) iconNode.setStyles({"background": "url("+icon+") center center no-repeat"});

                var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.empty}).inject(node);
                selectNode.addEvent("click", function(e){
                    var id = node.get("name");
                    this.data[id] = "";
                    node.getFirst("div").setStyle("background-image", "");
                    this.changeData(id);
                    e.stopPropagation();
                }.bind(this));

                var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.select}).inject(node);
                selectNode.addEvent("click", function(){
                    this.selectLabelFlag(node);
                }.bind(this));
            }.bind(this));
        }
    },
    selectLabelFlag: function(node){
        if (!node.iconMenu){
            var iconSelectMenu = new MWF.widget.Menu(node, {"event": "click", "style": "labelFlag"});
            iconSelectMenu.load();
            node.iconMenu = iconSelectMenu;
            var _self = this;
            for (var i=1; i<=21; i++){
695
                var icon = "../x_component_process_FormDesigner/Module/Label/default/icon/flag/"+i+".png";
NoSubject's avatar
NoSubject 已提交
696 697 698 699 700 701 702 703 704 705 706 707
                var item = iconSelectMenu.addMenuItem("", "click", function(){
                    var id = node.get("name");
                    var src = this.item.getElement("img").get("src");
                    _self.data[id] = src;
                    node.getFirst("div").setStyle("background-image", "url("+src+")");
                    _self.changeData(id);
                }, icon);
                item.iconName = icon;
            }
        }
    },

NoSubject's avatar
NoSubject 已提交
708
    loadImageFileSelect: function(){
NoSubject's avatar
NoSubject 已提交
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732
        // var nodes = this.propertyContent.getElements(".MWFImageFileSelect");
        // if (nodes.length){
        //
        //
        //
        //
        //     this.getFileList(function(){
        //         nodes.each(function(node){
        //             var select = new Element("select").inject(node);
        //             select.addEvent("change", function(e){
        //                 this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value, select);
        //
        //             }.bind(this));
        //             this.setFileSelectOptions(node, select);
        //
        //             var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
        //             refreshNode.addEvent("click", function(e){
        //                 this.getFileList(function(){
        //                     this.setFileSelectOptions(node, select);
        //                 }.bind(this), true);
        //             }.bind(this));
        //         }.bind(this));
        //     }.bind(this));
        // }
NoSubject's avatar
NoSubject 已提交
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755
    },
    setFileSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"text": "none"}).inject(select);
        this.files.each(function(file){
            var option = new Element("option", {
                "text": file.name,
                "value": file.id,
                "selected": (this.data[name]==file.id)
            }).inject(select);
        }.bind(this));
    },
    getFileList: function(callback, refresh){
        if (!this.files || refresh){
            this.form.designer.actions.listFile(this.form.designer.application.id, function(json){
                this.files = json.data;
                if (callback) callback();
            }.bind(this));
        }else{
            if (callback) callback();
        }
    },
NoSubject's avatar
NoSubject 已提交
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811

    loadImageClipper: function(){
        var nodes = this.propertyContent.getElements(".MWFImageClipper");
        if (nodes.length){
            nodes.each(function(node){
                var id = node.get("name");
                var selectNode = new Element("div", {"styles": this.form.css.processIconSelectNode, "text": this.form.designer.lp.selectImage}).inject(node);
                selectNode.addEvent("click", function(){
                    this.selectImage(node, id);
                }.bind(this));
            }.bind(this));
        }
    },
    createUploadFileAreaNode: function(node, name){
        this.uploadFileAreaNode = new Element("div");
        var html = "<input name=\"file\" multiple type=\"file\" accept=\"images/*\" />";
        this.uploadFileAreaNode.set("html", html);

        this.fileUploadNode = this.uploadFileAreaNode.getFirst();
        this.fileUploadNode.addEvent("change", function(){
            //var fileId = attachment.data.id;

            var files = this.fileUploadNode.files;
            if (files.length){
                var count = files.length;
                for (var i = 0; i < files.length; i++) {
                    var file = files.item(i);

                    var formData = new FormData();
                    formData.append('file', file);

                    MWF.xDesktop.uploadImage(
                        this.form.json.id,
                        (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
                        formData,
                        file,
                        function(json){
                            var id = json.id;
                            var src = MWF.xDesktop.getImageSrc(id);
                            var data = {"imageSrc": src, "imageId": id};
                            this.changeJsonDate(name, data);
                            this.changeData(name, node, null);
                        }.bind(this)
                    );
                }
            }
        }.bind(this));
    },
    selectImage: function(node, name){
        if (!this.uploadFileAreaNode){
            this.createUploadFileAreaNode(node, name);
        }
        //this.fileUploadNode.set("accept", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
        this.fileUploadNode.set("multiple", false);

        var fileNode = this.uploadFileAreaNode.getFirst();
NoSubject's avatar
NoSubject 已提交
812
        fileNode.set("accept", ".png,.jpg,.bmp,.gif,.jpeg,.jpe");
NoSubject's avatar
NoSubject 已提交
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
        fileNode.click();

        //MWF.xDesktop.requireApp("process.FormDesigner", "widget.ImageClipper", function(){
        //    var size = this.module.node.getSize();
        //    var image = new MWF.xApplication.process.FormDesigner.widget.ImageClipper(this.designer, {
        //        "title": this.form.designer.lp.selectImage,
        //        "width": (this.data.styles.width) ? size.x : 0,
        //        "height": (this.data.styles.height) ? size.y : 0,
        //        "imageUrl" : this.data.imageSrc,
        //        "reference" : this.form.json.id,
        //        "referenceType": (this.module.form.moduleType=="page") ? "portalPage" : "processPlatformForm",
        //        "onChange": function(){
        //            var data = {"imageSrc": image.imageSrc, "imageId": image.imageId};
        //            this.changeJsonDate(name, data);
        //            this.changeData(name, node, null);
        //        }.bind(this)
        //    });
        //    image.load(this.data[name])
        //}.bind(this));
    },
	
	loadEventsEditor: function(){
		var events = this.propertyContent.getElement(".MWFEventsArea");
		if (events){
			var name = events.get("name");
			var eventsObj = this.data[name];
            MWF.xDesktop.requireApp("process.FormDesigner", "widget.EventsEditor", function(){
				var eventsEditor = new MWF.xApplication.process.FormDesigner.widget.EventsEditor(events, this.designer, {
					//"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                    "maxObj": this.designer.formContentNode  || this.designer.pageContentNode
				});
				eventsEditor.load(eventsObj, this.data, name);
			}.bind(this));
		}
	},
    testRestful: function(){
        var node = this.propertyContent.getElements(".MWFTestRestful");
        if (node){
            var resultNode = node.getLast();
            node.getFirst().addEvent("click", function(){

            }.bind(this));
        }
    },
    loadContextRoot: function(){
        var nodes = this.propertyContent.getElements(".MWFContextRoot");
        if (nodes){
            nodes.each(function(node){
                var name = node.get("name");
NoSubject's avatar
NoSubject 已提交
862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927
                var selects = node.getElements("select");
                var rootSelect = selects[0];
                var actionSelect = selects[1];
                var methodSelect = selects[2];
                var pathInput = node.getElement("input");
                //var select = new Element("select").inject(node);
                //var methodSelect = new Element("select").inject(node);
debugger;
                var getValue = function(){
                    var v;
                    try {
                        v = JSON.parse(this.data[name]);
                    }catch(e){
                        v = {"root": this.data[name], "action":"", "method": "", "uri": ""};
                    }
                    return v
                }.bind(this);
                var value = getValue();

                var resetRootSelects = function(){
                    var root = rootSelect.options[rootSelect.selectedIndex].value;
                    var action = o2.Actions.load(root);
                    actionSelect.empty();
                    methodSelect.empty();
                    pathInput.set("value", "");
                    var value = getValue();
                    Object.each(action, function(o, key){
                        var option = new Element("option", {"value": key, "text": key, "selected": (value.action==key)}).inject(actionSelect);
                    });
                    return JSON.stringify({"root": root, "action":"", "method": "", "uri": ""});
                };
                var resetActionSelects = function(){
                    var root = rootSelect.options[rootSelect.selectedIndex].value;
                    var actionName = actionSelect.options[actionSelect.selectedIndex].value;
                    var action = o2.Actions.load(root);
                    methodSelect.empty();
                    pathInput.set("value", "");
                    var value = getValue();
                    Object.each(action[actionName].action.actions, function(o, key){
                        var option = new Element("option", {"value": key, "text": key, "selected": (value.method==key)}).inject(methodSelect);
                    });
                    return JSON.stringify({"root": root, "action":actionName, "method": "", "uri": ""});
                };
                var resetMethodSelects = function(){
                    var root = rootSelect.options[rootSelect.selectedIndex].value;
                    var actionName = actionSelect.options[actionSelect.selectedIndex].value;
                    var methodName = methodSelect.options[methodSelect.selectedIndex].value;
                    var action = o2.Actions.load(root);
                    var uri = action[actionName].action.actions[methodName].uri;
                    pathInput.set("value", uri);
                    return JSON.stringify({"root": root, "action":actionName, "method": methodName, "uri": uri});
                };

                Object.each(layout.serviceAddressList, function(v, key){
                    var option = new Element("option", {"value": key, "text": v.name, "selected": (value.root==key)}).inject(rootSelect);
                }.bind(this));
                resetRootSelects()
                resetActionSelects();
                resetMethodSelects();

                rootSelect.addEvent("change", function(){
                    resetRootSelects();
                    resetActionSelects();
                    var data = resetMethodSelects();
                    this.changeJsonDate(name, data);
                    this.changeData(name, node, value);
NoSubject's avatar
NoSubject 已提交
928
                }.bind(this));
NoSubject's avatar
NoSubject 已提交
929 930 931 932

                actionSelect.addEvent("change", function(){
                    resetActionSelects();
                    var data = resetMethodSelects();
NoSubject's avatar
NoSubject 已提交
933 934 935
                    this.changeJsonDate(name, data);
                    this.changeData(name, node, value);
                }.bind(this));
NoSubject's avatar
NoSubject 已提交
936 937 938 939 940 941 942

                methodSelect.addEvent("change", function(){
                    var data = resetMethodSelects();
                    this.changeJsonDate(name, data);
                    this.changeData(name, node, value);
                }.bind(this));

NoSubject's avatar
NoSubject 已提交
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959
            }.bind(this));
        }
    },
    loadSourceTestRestful: function(){
        var nodes = this.propertyContent.getElements(".MWFSourceTestRestful");
        if (nodes.length){
            nodes.each(function(node){
                var button = node.getFirst();
                var content = node.getLast();
                //var button = new Element("input", {"type": "button", "value": "Test"}).inject(node);
                button.addEvent("click", function(e){
                    this.testSourceRestful(content);
                }.bind(this));
            }.bind(this));
        }
    },
    testSourceRestful: function(content){
NoSubject's avatar
NoSubject 已提交
960 961 962 963 964 965 966 967
	    var service;
        try {
            service = JSON.parse(this.module.json.contextRoot);
        }catch(e){
            service = {"root": this.module.json.contextRoot, "action":"", "method": "", "url": ""};
        }

        var address = this._getO2Address(service.root);
NoSubject's avatar
NoSubject 已提交
968 969 970 971 972 973 974 975 976 977
        var uri = this._getO2Uri(this.module, address);
        this._invoke(this.module, uri, function(json){
            content.empty();
            MWF.require("MWF.widget.JsonParse", function(){
                var jsonParse = new MWF.widget.JsonParse(json, content, null);
                jsonParse.load();
            }.bind(this));
        }.bind(this));
    },
    _getO2Address: function(contextRoot){
NoSubject's avatar
NoSubject 已提交
978
        var addressObj = layout.serviceAddressList[contextRoot];
NoSubject's avatar
NoSubject 已提交
979 980
        var address = "";
        if (addressObj){
NoSubject's avatar
NoSubject 已提交
981
            address = layout.config.app_protocol+"//"+addressObj.host+(addressObj.port==80 ? "" : ":"+addressObj.port)+addressObj.context;
NoSubject's avatar
NoSubject 已提交
982 983 984
        }else{
            var host = layout.desktop.centerServer.host || window.location.hostname;
            var port = layout.desktop.centerServer.port;
NoSubject's avatar
NoSubject 已提交
985
            address = layout.config.app_protocol+"//"+host+(port=="80" ? "" : ":"+port)+"/x_program_center";
NoSubject's avatar
NoSubject 已提交
986 987 988 989
        }
        return address;
    },
    _getO2Uri: function(module, address){
NoSubject's avatar
NoSubject 已提交
990
        //var uri = module.json.path || module.json.selectPath;
NoSubject's avatar
NoSubject 已提交
991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
        var uri = module.json.path;
        var pars = {};

        MWF.require("MWF.xScript.Macro", null, false);
        var macro = new MWF.Macro["PageContext"]({"businessData": {}, "json": {}, "options": {}});

        if (module.json.parameters){
            Object.each(module.json.parameters, function(v, key){
                if (uri.indexOf("{"+key+"}")!==-1){
                    var reg = new RegExp("{"+key+"}", "g");
                    uri = uri.replace(reg, encodeURIComponent((v && v.code) ? (macro.exec(v.code, this) || "") : v));
                }else{
                    pars[key] = v;
                }
            }.bind(this));
        }

        var data = null;
        if (module.json.requestBody){
            if (module.json.requestBody.code){
                data = macro.exec(module.json.requestBody.code, this)
            }
        }

        if (module.json.httpMethod==="GET" || module.json.httpMethod==="OPTIONS" || module.json.httpMethod==="HEAD" || module.json.httpMethod==="DELETE"){
            var tag = "?";
            if (uri.indexOf("?")!==-1) tag = "&";
            Object.each(pars, function(v, k){
                var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
                uri = uri+tag+k+"="+value;
            }.bind(this));
        }else{
            Object.each(pars, function(v, k){
                if (!data) data = {};
                var value = (v && v.code) ? (macro.exec(v.code, this) || "") : v;
                data[k] = value;
            }.bind(this));
        }
        this.body = data;
        return {"uri": address+uri, "body": data};
    },
    _invoke: function(module, uri, callback){
        MWF.restful(module.json.httpMethod, uri.uri, JSON.encode(uri.body), function(json){
            //this.data = json;
            if (callback) callback(json);
        }.bind(this), true, true);
    },

    loadUnitTypeSelector: function(){
        var nodes = this.propertyContent.getElements(".MWFFormUnitTypeSelector");
        if (nodes.length){
            this.getUnitTypeList(function(){
                nodes.each(function(node){
                    var select = new Element("select").inject(node);
                    select.addEvent("change", function(e){
                        this.setValue(e.target.getParent("div").get("name"), e.target.options[e.target.selectedIndex].value);
                    }.bind(this));
                    this.setUnitTypeSelectOptions(node, select);
                    this.setValue(select.getParent("div").get("name"), select.options[select.selectedIndex].value);
                    // var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node);
                    // refreshNode.addEvent("click", function(e){
                    //     this.getUnitTypeList(function(){
                    //         this.setUnitTypeSelectOptions(node, select);
                    //     }.bind(this), true);
                    // }.bind(this));

                }.bind(this));
            }.bind(this));
        }
    },

    setUnitTypeSelectOptions: function(node, select){
        var name = node.get("name");
        select.empty();
        var option = new Element("option", {"value":"all", "text": this.form.designer.lp.all, "selected": (!this.data[name] || this.data[name]==="all")}).inject(select);
        this.unitTypeList.each(function(unitType){
            var option = new Element("option", {
                "text": unitType,
                "value": unitType,
                "selected": (this.data[name]===unitType)
            }).inject(select);
        }.bind(this));
    },
    getUnitTypeList: function(callback, refresh){
        if (!this.unitTypeList || refresh){
            //MWF.xDesktop.requireApp("Org", "Actions.RestActions", function(){
            //    var action = new MWF.xApplication.Org.Actions.RestActions();
                var action = MWF.Actions.get("x_organization_assemble_control");
                action.listUnitType(function(json){
                    this.unitTypeList = json.data.valueList;
                    if (callback) callback();
                }.bind(this));
            //}.bind(this));
        }else{
            if (callback) callback();
        }
    },

    loadParameterEditor: function(){
        var pars = this.propertyContent.getElements(".MWFParameterArea");
        if (pars){
            pars.each(function(par){
                var name = par.get("name");
                if (!this.data[name]) this.data[name] = {};
                var parObj = this.data[name];
                MWF.xDesktop.requireApp("process.FormDesigner", "widget.ParameterEditor", function(){
                    var parameterEditor = new MWF.xApplication.process.FormDesigner.widget.ParameterEditor(par, this.designer, {
                        //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                        "maxObj": this.designer.formContentNode
                    });
                    parameterEditor.load(parObj, this.data, name);
                }.bind(this));
            }.bind(this));

        }
    },
	
	loadArrayList: function(){
		var arrays = this.propertyContent.getElements(".MWFArraylist");
		arrays.each(function(node){
			var title = node.get("title");
			var name = node.get("name");
			var arr = this.data[name];
			if (!arr) arr = [];
			MWF.require("MWF.widget.Arraylist", function(){
				var arraylist = new MWF.widget.Arraylist(node, {
					"title": title,
					"onChange": function(){
						this.data[name] = arraylist.toArray();
					}.bind(this)
				});
				arraylist.load(arr);
			}.bind(this));
            node.addEvent("keydown", function(e){e.stopPropagation();});
		}.bind(this));
	},

    loadHtmlEditorArea: function(){
        var htmlAreas = this.propertyContent.getElements(".MWFHtmlEditorArea");
        htmlAreas.each(function(node){
            var title = node.get("title");
            var name = node.get("name");
            var scriptContent = this.data[name];
            MWF.require("MWF.widget.HtmlEditorArea", function(){
                var htmlArea = new MWF.widget.HtmlEditorArea(node, {
                    "title": title,
                    //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                    "maxObj": this.designer.formContentNode,
                    "onChange": function(){
                        this.data[name] = htmlArea.getValue();
                        this.changeData(name);
NoSubject's avatar
NoSubject 已提交
1142
                        htmlArea.isChanged = true;
NoSubject's avatar
NoSubject 已提交
1143
                    }.bind(this),
NoSubject's avatar
NoSubject 已提交
1144 1145 1146 1147 1148 1149
                    // "onBlur": function(){
                    //     if (htmlArea.isChanged){
                    //         this.changeData(name, node, "");
                    //         htmlArea.isChanged = false;
                    //     }
                    // }.bind(this),
NoSubject's avatar
NoSubject 已提交
1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
                    "onSave": function(){
                        this.designer.saveForm();
                    }.bind(this)
                });
                htmlArea.load({"code": scriptContent});
            }.bind(this));

        }.bind(this));
    },
    loadStylesList: function(){
U
unknown 已提交
1160
        var _self = this;
NoSubject's avatar
NoSubject 已提交
1161 1162 1163 1164
        var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
        styleSelNodes.each(function(node){
            if (this.module.form.stylesList){
                if (!this.data.formStyleType) this.data.formStyleType = "default";
NoSubject's avatar
NoSubject 已提交
1165
                var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
NoSubject's avatar
NoSubject 已提交
1166
                Object.each(this.module.form.stylesList, function(s, key){
NoSubject's avatar
NoSubject 已提交
1167 1168 1169 1170 1171 1172 1173
                    if( s.mode.contains( mode ) ){
                        new Element("option", {
                            "text": s.name,
                            "value": key,
                            "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
                        }).inject(node)
                    }
NoSubject's avatar
NoSubject 已提交
1174 1175 1176 1177
                }.bind(this));
            }else{
                node.getParent("tr").setStyle("display", "none");
            }
U
unknown 已提交
1178 1179 1180 1181 1182

            var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
            refreshNode.addEvent("click", function(e){
                _self.changeData(this.get("name"), this );
            }.bind(node));
NoSubject's avatar
NoSubject 已提交
1183 1184
        }.bind(this));
    },
U
unknown 已提交
1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
    // loadStylesList: function(){
	//     var _self = this;
    //     var styleSelNodes = this.propertyContent.getElements(".MWFFormStyle");
    //     styleSelNodes.each(function(node){
    //         if (this.module.form.stylesList){
    //             if (!this.data.formStyleType) this.data.formStyleType = "default";
    //             var mode = ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc";
    //             Object.each(this.module.form.stylesList, function(s, key){
    //                 if( s.mode.contains( mode ) ){
    //                     new Element("option", {
    //                         "text": s.name,
    //                         "value": key,
    //                         "selected": ((!this.data.formStyleType && key=="default") || (this.data.formStyleType==key))
    //                     }).inject(node)
    //                 }
    //             }.bind(this));
    //         }else{
    //             node.getParent("tr").setStyle("display", "none");
    //         }
    //
    //         var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(node, "after");
    //         refreshNode.addEvent("click", function(e){
    //             _self.changeData(this.get("name"), this );
    //         }.bind(node));
    //     }.bind(this));
    // },
NoSubject's avatar
NoSubject 已提交
1211 1212 1213 1214
    loadDivTemplateType: function(){
        var nodes = this.propertyContent.getElements(".MWFDivTemplate");
        if (nodes.length){
            var keys = [];
NoSubject's avatar
NoSubject 已提交
1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230
            //if (this.module.form.stylesList) {
            //    if (this.module.form.stylesList[this.module.form.json.formStyleType]){
            //        var styles = this.module.form.stylesList[this.module.form.json.formStyleType][this.module.moduleName];
            //        if (styles) {
            //            Object.each(styles, function (v, k) {
            //                keys.push(k);
            //            }.bind(this));
            //        }
            //    }
            //}
            if (this.module.form.templateStyles && this.module.form.templateStyles[this.module.moduleName]) {
                var styles = this.module.form.templateStyles[this.module.moduleName];
                if (styles) {
                    Object.each(styles, function (v, k) {
                        keys.push(k);
                    }.bind(this));
NoSubject's avatar
NoSubject 已提交
1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263
                }
            }

            nodes.each(function(node){
                node.empty();
                new Element("option", {
                    "text": "default",
                    "value": "default",
                    "selected": (!this.data.templateType || this.data.templateType=="default")
                }).inject(node);
                if (keys.length){
                    keys.each(function(k){
                        new Element("option", {
                            "text": styles[k].name,
                            "value": k,
                            "selected": (this.data.templateType==k)
                        }).inject(node)
                    }.bind(this));
                }else{
                    node.getParent("tr").setStyle("display", "none");
                }
            }.bind(this));
        }

    },
    loadPersonInput: function(){
        var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
        var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
        var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
        var dutyNameNodes = this.propertyContent.getElements(".MWFPersonDuty");
        var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
        var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
        var queryviewNodes = this.propertyContent.getElements(".MWFQueryViewSelect");
U
unknown 已提交
1264
        var queryStatementNodes = this.propertyContent.getElements(".MWFQueryStatementSelect");
NoSubject's avatar
NoSubject 已提交
1265
        var querystatNodes = this.propertyContent.getElements(".MWFQueryStatSelect");
NoSubject's avatar
NoSubject 已提交
1266 1267
        var fileNodes = this.propertyContent.getElements(".MWFImageFileSelect");
        var processFileNodes = this.propertyContent.getElements(".MWFProcessImageFileSelect");
U
unknown 已提交
1268
        var scriptNodes = this.propertyContent.getElements(".MWFScriptSelect");
U
unknown 已提交
1269
        var formStyleNodes = this.propertyContent.getElements(".MWFFormStyleSelect");
U
unknown 已提交
1270 1271
        var dictionaryNodes = this.propertyContent.getElements(".MWFDictionarySelect");

NoSubject's avatar
NoSubject 已提交
1272

NoSubject's avatar
NoSubject 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326
        MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
            personIdentityNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "identity",
                    "names": this.data[node.get("name")],
                    "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
                });
            }.bind(this));

            personUnitNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "unit",
                    "names": this.data[node.get("name")],
                    "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
                });
            }.bind(this));
            dutyNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "duty",
                    "names": this.data[node.get("name")],
                    "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
                    "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
                });
            }.bind(this));

            dutyNameNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "dutyName",
                    "names": this.data[node.get("name")],
                    "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
                });
            }.bind(this));

            viewNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "View",
                    "count": 1,
                    "names": [this.data[node.get("name")]],
                    "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
                });
            }.bind(this));
            cmsviewNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "CMSView",
                    "count": 1,
                    "names": [this.data[node.get("name")]],
                    "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
                });
            }.bind(this));
            queryviewNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "QueryView",
                    "count": 1,
                    "names": [this.data[node.get("name")]],
U
unknown 已提交
1327 1328 1329 1330 1331 1332 1333 1334 1335
                    "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
                });
            }.bind(this));

            queryStatementNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "QueryStatement",
                    "count": 1,
                    "names": [this.data[node.get("name")]],
NoSubject's avatar
NoSubject 已提交
1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348
                    "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
                });
            }.bind(this));

            querystatNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "QueryStat",
                    "count": 1,
                    "names": [this.data[node.get("name")]],
                    "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
                });
            }.bind(this));

U
unknown 已提交
1349 1350 1351
            scriptNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "Script",
NoSubject's avatar
NoSubject 已提交
1352 1353
                    "count": node.dataset["count"] || 1,
                    "names": (!node.dataset["count"] || node.dataset["count"].toInt()==1) ? [this.data[node.get("name")]] : this.data[node.get("name")],
U
unknown 已提交
1354 1355 1356 1357 1358 1359 1360 1361
                    "onChange": function(ids){
                        this.saveScriptSelectItem(node, ids);
                    }.bind(this)
                });
            }.bind(this));

            var _self = this;
            formStyleNodes.each(function(node){
U
unknown 已提交
1362
                debugger;
U
unknown 已提交
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379
                var data = this.data[node.get("name")];
                if( typeOf( data ) === "string" ){
                    for( var key in this.module.form.stylesList ){
                        var s = this.module.form.stylesList[key];
                        if( ((!data && key=="default") || (data==key)) ){
                            data = {
                                name : s.name,
                                id : key
                            };
                            break;
                        }
                    }
                }
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "FormStyle",
                    "count": 1,
                    "names": [data],
U
unknown 已提交
1380 1381 1382 1383 1384
                    "selectorOptions" : {
                        "mode" : ( this.form.options.mode || "" ).toLowerCase() === "mobile" ? "mobile" : "pc"
                    },
                    "validFun" : function (ids) {
                        var flag = true;
U
unknown 已提交
1385
                        if( ids.length === 0 ){
U
unknown 已提交
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420
                            this.designer.notice(MWF.APPFD.LP.mustSelectFormStyle, "error");
                            flag = false;
                        }else if( ids[0].data.type === "script" ){
                            this.designer.actions.getScriptByName(  ids[0].data.name, ids[0].data.application,  function( json ) {
                                debugger;
                                try{
                                    var f = eval("(function(){\n return "+json.data.text+"\n})");
                                    var j = f();
                                    if( typeOf(j) !== "object" ){
                                        this.designer.notice( MWF.APPFD.LP.notValidJson, "error" );
                                        flag = false;
                                    }
                                }catch (e) {
                                    this.designer.notice( MWF.APPFD.LP.notValidJson +""+ e.message, "error" );
                                    flag = false;
                                }
                            }.bind(this), function () {
                                flag = false;
                            }, false);
                        }
                        return flag;
                    }.bind(this),
                    "onChange": function(ids){
                        var d = ids[0].data;
                        var data;
                        if( d.type === "script" ){
                            data = {
                                "type" : "script",
                                "name": d.name,
                                "alias": d.alias,
                                "id": d.id,
                                "appName" : d.appName || d.applicationName,
                                "appId": d.appId,
                                "application": d.application
                            };
U
unknown 已提交
1421
                        }else{
U
unknown 已提交
1422
                            data = d.id;
U
unknown 已提交
1423
                        }
U
unknown 已提交
1424 1425 1426 1427
                        var name = node.get("name");
                        var oldValue = this.data[name];
                        this.data[name] = data;
                        this.changeData(name, node, oldValue);
U
unknown 已提交
1428
                    }.bind(this)
U
unknown 已提交
1429
                });
U
unknown 已提交
1430 1431 1432 1433 1434 1435 1436 1437

                var next = node.getNext();
                if( next && next.get("class") === "MWFScriptSelectRefresh" ){
                    var refreshNode = new Element("div", {"styles": this.form.css.propertyRefreshFormNode}).inject(next);
                    refreshNode.addEvent("click", function(e){
                        _self.changeData(this.get("name"), this );
                    }.bind(node));
                }
U
unknown 已提交
1438 1439
            }.bind(this));

U
unknown 已提交
1440 1441 1442 1443 1444 1445 1446 1447 1448
            dictionaryNodes.each(function(node){
                var data = this.data[node.get("name")];
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "Dictionary",
                    "count": 0,
                    "names": typeOf(data)==="array" ? data : [data],
                    "onChange": function(ids){
                        var data = [];
                        var name = node.get("name");
1449
                        if( ids.length > 0 ){
1450
                            // var d = ids[0].data;
1451
                            ids.each( function (id) {
1452
                                debugger;
1453 1454 1455 1456 1457 1458 1459
                                var d = id.data;
                                data.push({
                                    "type" : "dictionary",
                                    "name": d.name,
                                    "alias": d.alias,
                                    "id": d.id,
                                    "appName" : d.appName || d.applicationName,
1460
                                    "appAlias" : d.appAlias || d.applicationAlias,
1461 1462 1463 1464 1465 1466
                                    "appId": d.appId,
                                    "application": d.application,
                                    "appType" : d.appType
                                })
                            });
                        }
U
unknown 已提交
1467 1468 1469 1470 1471 1472 1473
                        var oldValue = this.data[name];
                        this.data[name] = data;
                        this.changeData(name, node, oldValue);
                    }.bind(this)
                });
            }.bind(this));

NoSubject's avatar
NoSubject 已提交
1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
            fileNodes.each(function(node){
                var d = this.data[node.get("name")];
                var data = d || {};
                //this.form
                if (d && typeOf(d)==="string"){
                    if (this.form.page){
                        data = {"id": d, "portal": this.form.application}
                    }else{
                        data = {"id": d, "application": this.form.application}
                    }
                }
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "PortalFile",
                    "count": 1,
                    "isImage": true,
                    "values": (data.id) ? [data.id] : [],
                    "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
                });
            }.bind(this));
NoSubject's avatar
NoSubject 已提交
1493

NoSubject's avatar
NoSubject 已提交
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512
            processFileNodes.each(function(node){
                var d = this.data[node.get("name")];
                var data = d || {};
                //this.form
                if (d && typeOf(d)==="string"){
                    if (this.form.page){
                        data = {"id": d, "portal": this.form.application}
                    }else{
                        data = {"id": d, "application": this.form.application}
                    }
                }
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "ProcessFile",
                    "count": 1,
                    "isImage": true,
                    "values": (data.id) ? [data.id] : [],
                    "onChange": function(ids){this.saveFileItem(node, ids);}.bind(this)
                });
            }.bind(this));
NoSubject's avatar
NoSubject 已提交
1513 1514 1515 1516


        }.bind(this));
    },
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
    loadDictionaryIncluder : function(){
        var nodes = this.propertyContent.getElements(".MWFDictionaryIncluder");
        if (nodes.length){
            nodes.each(function(node){
                var name = node.get("name");
                MWF.xDesktop.requireApp("process.FormDesigner", "widget.DictionaryIncluder", function(){
                    var dictionaryIncluder = new MWF.xApplication.process.FormDesigner.widget.DictionaryIncluder(node, this.designer, {
                        "onChange": function(){
                            var data = dictionaryIncluder.getData();
                            this.data[name] = data;
                        }.bind(this)
                    });
                    dictionaryIncluder.load(this.data[name])
                }.bind(this));
            }.bind(this));
        }

    },
U
unknown 已提交
1535 1536 1537 1538 1539 1540 1541 1542
    loadScriptIncluder : function(){
        var nodes = this.propertyContent.getElements(".MWFScriptIncluder");
        if (nodes.length){
            nodes.each(function(node){
                var name = node.get("name");
                MWF.xDesktop.requireApp("process.FormDesigner", "widget.ScriptIncluder", function(){
                    var scriptIncluder = new MWF.xApplication.process.FormDesigner.widget.ScriptIncluder(node, this.designer, {
                        "onChange": function(){
U
unknown 已提交
1543 1544
                            var data = scriptIncluder.getData();
                            this.data[name] = data;
U
unknown 已提交
1545 1546 1547 1548 1549 1550 1551 1552
                        }.bind(this)
                    });
                    scriptIncluder.load(this.data[name])
                }.bind(this));
            }.bind(this));
        }

    },
NoSubject's avatar
NoSubject 已提交
1553 1554 1555 1556 1557 1558 1559 1560 1561
    saveFileItem: function(node, ids){
        if (ids[0]){
            var file = ids[0].data;
            this.data[node.get("name")] = file;
        }else{
            this.data[node.get("name")] = null;
        }
        this.changeData(node.get("name"));
    },
NoSubject's avatar
NoSubject 已提交
1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580
    saveViewItem: function(node, ids){
        if (ids[0]){
            var view = ids[0].data;
            var data = {
                "name": view.name,
                "alias": view.alias,
                "id": view.id,
                "appName" : view.appName || view.applicationName || view.query,
                "appId": view.appId,
                "application": view.application || view.query
            };
            this.data[node.get("name")] = data;
        }else{
            this.data[node.get("name")] = null;
        }
        if (this.module._checkView) this.module._checkView();
    },
    removeViewItem: function(node, item){

U
unknown 已提交
1581 1582
    },
    saveScriptSelectItem: function(node, ids){
NoSubject's avatar
NoSubject 已提交
1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
        var count = (node.dataset["count"] || 1).toInt();
        if (count==1){
            if (ids[0]){
                var script = ids[0].data;
                var data = {
                    "appType": script.appType,
                    "type" : "script",
                    "name": script.name,
                    "alias": script.alias,
                    "id": script.id,
                    "appName" : script.appName || script.applicationName,
                    "appId": script.appId,
                    "application": script.application
                };

                var name = node.get("name");
                var oldValue = this.data[name];
                this.data[name] = data;
U
unknown 已提交
1601

NoSubject's avatar
NoSubject 已提交
1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621
                // this.changeJsonDate(name, data );
                this.changeData(name, node, oldValue);
            }else{
                // this.data[node.get("name")] = null;
            }
        }else{
            var scriptValues = [];
            ids.each(function(s){
                var scriptValue = {
                    "appType": s.data.appType,
                    "type" : "script",
                    "name": s.data.name,
                    "alias": s.data.alias,
                    "id": s.data.id,
                    "appName" : s.data.appName || s.data.applicationName,
                    "appId": s.data.appId,
                    "application": s.data.application
                }
                scriptValues.push(scriptValue);
            }.bind(this));
U
unknown 已提交
1622 1623
            var name = node.get("name");
            var oldValue = this.data[name];
NoSubject's avatar
NoSubject 已提交
1624
            this.data[name] = scriptValues;
U
unknown 已提交
1625
            this.changeData(name, node, oldValue);
U
unknown 已提交
1626
        }
NoSubject's avatar
NoSubject 已提交
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716
    },
    removeDutyItem: function(node, item){
        if (item.data.id){
            var values = JSON.decode(this.data[node.get("name")] || []);
            var value = values.filter(function(v){
                return v.id == item.data.id;
            });
            value.each(function(v) {
                values = values.erase(v);
            });
            this.data[node.get("name")] = JSON.encode(values);
        }
        item.node.destroy();
        MWF.release(item);
        delete item;
    },
    addDutyItem: function(node, ids){
        var value = this.data[node.get("name")] || "";
        if (!value) value = "[]";
        var values = JSON.decode(value);
        ids.each(function(id){
            if (id.data.dutyId){
                for (var i=0; i<values.length; i++){
                    if (values[i].dutyId===id.data.dutyId){
                        values[i].name = id.data.name;
                        values[i].code = id.data.code;
                        break;
                    }
                }
            }else{
                id.data.dutyId = new MWF.widget.UUID().toString();
                values.push({"name": id.data.name, "id": id.data.id, "dutyId": id.data.dutyId, "code": id.data.code});
            }
        }.bind(this));
        this.data[node.get("name")] = JSON.encode(values);
    },
    loadFormFieldInput: function(){
        var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
        MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
            fieldNodes.each(function(node){
                new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
                    "type": "formField",
                    "application": this.form.json.application,
                    "fieldType": "person",
                    "names": this.data[node.get("name")],
                    "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
                });
            }.bind(this));
        }.bind(this));
    },
    savePersonItem: function(node, ids){
        var values = [];
        ids.each(function(id){
            values.push(MWF.org.parseOrgData(id.data));
        }.bind(this));
        this.data[node.get("name")] = values;
    },


	loadScriptArea: function(){
		var scriptAreas = this.propertyContent.getElements(".MWFScriptArea");
        var formulaAreas = this.propertyContent.getElements(".MWFFormulaArea");
        this.loadScriptEditor(scriptAreas);
        this.loadScriptEditor(formulaAreas, "formula");
	},
    loadScriptEditor: function(scriptAreas, style){
        scriptAreas.each(function(node){
            var title = node.get("title");
            var name = node.get("name");
            if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
            var scriptContent = this.data[name];

            MWF.require("MWF.widget.ScriptArea", function(){
                var scriptArea = new MWF.widget.ScriptArea(node, {
                    "title": title,
                    //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                    "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
                    "onChange": function(){
                        //this.data[name] = scriptArea.toJson();
                        if (!this.data[name]){
                            this.data[name] = {"code": "", "html": ""};
                            if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
                        }
                        var json = scriptArea.toJson();
                        this.data[name].code = json.code;
                        //this.data[name].html = json.html;
                    }.bind(this),
                    "onSave": function(){
                        this.designer.saveForm();
                    }.bind(this),
NoSubject's avatar
NoSubject 已提交
1717 1718
                    "style": style || "default",
                    "runtime": "web"
NoSubject's avatar
NoSubject 已提交
1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733
                });
                scriptArea.load(scriptContent);
            }.bind(this));

        }.bind(this));
    },

    loadCssArea: function(style){
        var cssAreas = this.propertyContent.getElements(".MWFCssArea");
        cssAreas.each(function(node){
            var title = node.get("title");
            var name = node.get("name");
            if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
            var cssContent = this.data[name];

NoSubject's avatar
NoSubject 已提交
1734 1735
            o2.require("o2.widget.CssArea", function(){
                var cssArea = new o2.widget.CssArea(node, {
NoSubject's avatar
NoSubject 已提交
1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764
                    "title": title,
                    "maxObj": this.designer.formContentNode || this.designer.pageContentNode,
                    "onChange": function(){
                        //this.data[name] = scriptArea.toJson();
                        if (!this.data[name]){
                            this.data[name] = {"code": "", "html": ""};
                            if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
                        }
                        var json = cssArea.toJson();
                        this.data[name].code = json.code;
                        cssArea.isChanged = true;
                        //this.data[name].html = json.html;
                    }.bind(this),
                    "onBlur": function(){
                        if (cssArea.isChanged){
                            this.changeData(name, node, "");
                            cssArea.isChanged = false;
                        }

                    }.bind(this),
                    "onSave": function(){
                        this.designer.saveForm();
                    }.bind(this),
                    "style": style || "default"
                });
                cssArea.load(cssContent);
            }.bind(this));
        }.bind(this));
    },
NoSubject's avatar
NoSubject 已提交
1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792
    loadActionStylesArea: function(){
        var _self = this;
        var actionAreas = this.propertyContent.getElements(".MWFActionStylesArea");
        actionAreas.each(function(node){
            var name = node.get("name");
            var actionStyles = this.data[name];
            MWF.require("MWF.widget.Maplist", function(){
                var maps = [];
                Object.each(actionStyles, function(v, k){
                    var mapNode = new Element("div").inject(node);
                    mapNode.empty();

                    var maplist = new MWF.widget.Maplist(mapNode, {
                        "title": k,
                        "collapse": true,
                        "onChange": function(){
                            var oldData = _self.data[name];
                            maps.each(function(o){
                                _self.data[name][o.key] = o.map.toJson();
                            }.bind(this));
                            _self.changeData(name, node, oldData);
                        }
                    });
                    maps.push({"key": k, "map": maplist});
                    maplist.load(v);
                }.bind(this));
            }.bind(this));

NoSubject's avatar
NoSubject 已提交
1793

NoSubject's avatar
NoSubject 已提交
1794 1795
        }.bind(this));
    },
NoSubject's avatar
NoSubject 已提交
1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834
    loadActionArea: function(){
        var actionAreas = this.propertyContent.getElements(".MWFActionArea");
        actionAreas.each(function(node){
            var name = node.get("name");
            var actionContent = this.data[name];
            MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){

                // debugger;
                // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
                //     "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                //     "noCreate": true,
                //     "noDelete": true,
                //     "noCode": true,
                //     "onChange": function(){
                //         this.data[name] = actionEditor.data;
                //     }.bind(this)
                // });
                // actionEditor.load(this.module.defaultToolBarsData);

                var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
                    "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                    "onChange": function(){
                        this.data[name] = actionEditor.data;
                        this.changeData(name);
                    }.bind(this)
                });
                actionEditor.load(actionContent);
            }.bind(this));

        }.bind(this));

        var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
        actionAreas.each(function(node){
            var name = node.get("name");
            var actionContent = this.data[name] || this.module.defaultToolBarsData;
            MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){

                var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
                    "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
NoSubject's avatar
NoSubject 已提交
1835
                    "isSystemTool" : true,
NoSubject's avatar
NoSubject 已提交
1836
                    "noCreate": true,
NoSubject's avatar
NoSubject 已提交
1837
                    "noDelete": false,
NoSubject's avatar
NoSubject 已提交
1838
                    "noCode": true,
NoSubject's avatar
NoSubject 已提交
1839
                    "noReadShow": true,
1840
                    "target" : node.get("data-target"),
NoSubject's avatar
NoSubject 已提交
1841
                    "noEditShow": true,
NoSubject's avatar
NoSubject 已提交
1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864
                    "onChange": function(){
                        this.data[name] = actionEditor.data;
                        this.changeData(name);
                    }.bind(this)
                });
                actionEditor.load(actionContent);

                // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
                //     "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
                //     "onChange": function(){
                //         this.data[name] = actionEditor.data;
                //     }.bind(this)
                // });
                // actionEditor.load(actionContent);
            }.bind(this));

        }.bind(this));

    },


	loadMaplist: function(){
		var maplists = this.propertyContent.getElements(".MWFMaplist");
1865
		debugger;
NoSubject's avatar
NoSubject 已提交
1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883
		maplists.each(function(node){
			var title = node.get("title");
			var name = node.get("name");
			var collapse = node.get("collapse");
			var mapObj = this.data[name];
			if (!mapObj) mapObj = {};
			MWF.require("MWF.widget.Maplist", function(){
                node.empty();
				var maplist = new MWF.widget.Maplist(node, {
					"title": title,
					"collapse": (collapse) ? true : false,
					"onChange": function(){
						//this.data[name] = maplist.toJson();
						//
                        var oldData = this.data[name];
                        this.changeJsonDate(name, maplist.toJson());
                        this.changeStyle(name, oldData);
                        this.changeData(name);
NoSubject's avatar
NoSubject 已提交
1884 1885 1886 1887 1888 1889
					}.bind(this),
                    "onDelete": function(key){
					    debugger;

                        this.module.deletePropertiesOrStyles(name, key);
                    }.bind(this)
NoSubject's avatar
NoSubject 已提交
1890 1891 1892 1893 1894 1895
				});
				maplist.load(mapObj);
                this.maplists[name] = maplist;
			}.bind(this));
		}.bind(this));
	},
R
roo00 已提交
1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
	//loadPropertyTab: function(){
	//	var tabNodes = this.propertyContent.getElements(".MWFTab");
	//	if (tabNodes.length){
	//		var tmpNode = this.propertyContent.getFirst();
	//		var tabAreaNode = new Element("div", {
	//			"styles": this.form.css.propertyTabNode
	//		}).inject(tmpNode, "before");
	//
	//		MWF.require("MWF.widget.Tab", function(){
	//			var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
	//			tab.load();
	//			var tabPages = [];
	//			tabNodes.each(function(node){
	//			    if (node.getStyle("display")!="none"){
     //                   var page = tab.addTab(node, node.get("title"), false);
     //                   tabPages.push(page);
     //                   page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
     //                   node.inject(page.contentScrollNode);
     //                   this.setScrollBar(page.contentScrollNode, "small", null, null);
     //               }
	//			}.bind(this));
	//			tabPages[0].showTab();
	//
	//			this.propertyTab = tab;
	//
	//			this.designer.resizeNode();
	//		}.bind(this), false);
	//	}
	//},
    loadPropertyTab: function(){
        var tabNodes = this.propertyContent.getElements(".MWFTab");
        var groupObject = {};  //data-group 属性可以表示不同的分组
        if (tabNodes.length){
            tabNodes.each( function(node){
                var group = node.get("data-group") || "default";
                groupObject[group] = groupObject[group] || [];
                groupObject[group].push( node );
            }.bind(this))
        }
        for( var group in groupObject ){
            if( group === "default" ){
                var tmpNode = this.propertyContent.getFirst();
                var tabAreaNode = new Element("div", {
                    "styles": this.form.css.propertyTabNode
                }).inject(tmpNode, "before");

                MWF.require("MWF.widget.Tab", function(){
                    var tab = new MWF.widget.Tab(tabAreaNode, {"style": "formPropertyList"});
                    tab.load();
                    var tabPages = [];
                    groupObject["default"].each(function(node){
                        if (node.getStyle("display")!="none"){
                            var page = tab.addTab(node, node.get("title"), false);
                            tabPages.push(page);
                            page.contentScrollNode = new Element("div", {"styles": {"height": "100%", "overflow": "hidden"}}).inject(page.contentNodeArea);
                            node.inject(page.contentScrollNode);
                            this.setScrollBar(page.contentScrollNode, "small", null, null);
                        }
                    }.bind(this));
                    tabPages[0].showTab();

                    this.propertyTab = tab;

                    this.designer.resizeNode();
                }.bind(this), false);
            }else{
                var tmpNode = groupObject[group][0];
                var tabAreaNode = new Element("div", {
                    "styles": this.form.css.propertyTabNode
                }).inject(tmpNode, "before");
                MWF.require("MWF.widget.Tab", function(){
                    var tab = new MWF.widget.Tab(tabAreaNode, {"style": tmpNode.get("data-style") || "formPropertyList"});
                    tab.load();
                    var tabPages = [];
                    groupObject[group].each(function(node) {
NoSubject's avatar
NoSubject 已提交
1971 1972
                        var page = tab.addTab(node, node.get("title"), false);
                        tabPages.push(page);
R
roo00 已提交
1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
                        node.store("tab", page);
                        if (node.getStyle("display") === "none"){
                            page.disableTab( true );
                            node.show();
                        }
                    }.bind(this));
                    for( var i=0; i<tabPages.length; i++ ){
                        if( !tabPages[i].disabled ){
                            tabPages[i].showTab();
                            break
                        }
NoSubject's avatar
NoSubject 已提交
1984
                    }
R
roo00 已提交
1985 1986 1987 1988
                }.bind(this), false);
            }
        }
    },
NoSubject's avatar
NoSubject 已提交
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000
	
	setEditNodeEvent: function(){
		var property = this;
	//	var inputs = this.process.propertyListNode.getElements(".editTableInput");
		var inputs = this.propertyContent.getElements("input");
		inputs.each(function(input){

			var jsondata = input.get("name");

            if (this.module){
                var id = this.data.pid;
                //var id = this.form.json.id;
U
unknown 已提交
2001 2002
                // input.set("name", this.form.options.mode+id+jsondata);
                input.set("name", id+jsondata);
NoSubject's avatar
NoSubject 已提交
2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127
            }

			if (jsondata){
				var inputType = input.get("type").toLowerCase();
				switch (inputType){
					case "radio":
						input.addEvent("change", function(e){
							property.setRadioValue(jsondata, this);
						});
						input.addEvent("blur", function(e){
							property.setRadioValue(jsondata, this);
						});
                        input.addEvent("keydown", function(e){
                            e.stopPropagation();
                        });
                        property.setRadioValue(jsondata, input);
						break;
					case "checkbox":

						input.addEvent("change", function(e){
							property.setCheckboxValue(jsondata, this);
						});
						input.addEvent("click", function(e){
							property.setCheckboxValue(jsondata, this);
						});
                        input.addEvent("keydown", function(e){
                            e.stopPropagation();
                        });
						break;
					default:
						input.addEvent("change", function(e){
							property.setValue(jsondata, this.value, this);
						});
						input.addEvent("blur", function(e){
							property.setValue(jsondata, this.value, this);
						});
						input.addEvent("keydown", function(e){
							if (e.code==13){
								property.setValue(jsondata, this.value, this);
							}
                            e.stopPropagation();
						});
				}
			}
		}.bind(this));
		
		var selects = this.propertyContent.getElements("select");

		selects.each(function(select){
			var jsondata = select.get("name");
			if (jsondata){
				select.addEvent("change", function(e){
					property.setSelectValue(jsondata, this);
				});
                //property.setSelectValue(jsondata, select);
			}
		});
		
		var textareas = this.propertyContent.getElements("textarea");
		textareas.each(function(input){
			var jsondata = input.get("name");
			if (jsondata){
				input.addEvent("change", function(e){
					property.setValue(jsondata, this.value);
				});
				input.addEvent("blur", function(e){
					property.setValue(jsondata, this.value);
				});
                input.addEvent("keydown", function(e){
                    e.stopPropagation();
                });
			}
		}.bind(this));
		
	},
    changeStyle: function(name, oldData){
        this.module.setPropertiesOrStyles(name, oldData);
    },
    changeData: function(name, input, oldValue){
        this.module._setEditStyle(name, input, oldValue);
    },
    changeJsonDate: function(key, value){
        if (typeOf(key)!=="array") key = [key];
        var o = this.data;
        var len = key.length-1;
        key.each(function(n, i){
            if (!o[n]) o[n] = {};
            if (i<len) o = o[n];
        }.bind(this));
        o[key[len]] = value;

        //this.data[key] = value;
    },
	setRadioValue: function(name, input){
		if (input.checked){
            var i = name.indexOf("*");
            var names = (i==-1) ? name.split(".") : name.substr(i+1, name.length).split(".");

            var value = input.value;
            if (value=="false") value = false;
            if (value=="true") value = true;

            var oldValue = this.data;
            for (var idx = 0; idx<names.length; idx++){
                if (!oldValue[names[idx]]){
                    oldValue = null;
                    break;
                }else{
                    oldValue = oldValue[names[idx]];
                }
            }

			// var value = input.value;
			// if (value==="false") value = false;
			// if (value==="true") value = true;
			//var oldValue = this.data[name];
			this.changeJsonDate(names, value);
            this.changeData(name, input, oldValue);
		}
	},
	setCheckboxValue: function(name, input){
        //var id = this.module.json.id;
        //var id = this.form.json.id;
        var id = this.data.pid;

U
unknown 已提交
2128 2129
		// var checkboxList = $$("input[name='"+this.form.options.mode+id+name+"']");
        var checkboxList = $$("input[name='"+id+name+"']");
NoSubject's avatar
NoSubject 已提交
2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350
		var values = [];
		checkboxList.each(function(checkbox){
			if (checkbox.get("checked")){
				values.push(checkbox.value);
			}
		});
		var oldValue = this.data[name];
		//this.data[name] = values;
        this.changeJsonDate(name, values);
        this.changeData(name, input, oldValue);
	},
	setSelectValue: function(name, select){
		var idx = select.selectedIndex;
		var options = select.getElements("option");
		var value = "";
		if (options[idx]){
			value = options[idx].get("value");
		}
		var oldValue = this.data[name];
		//this.data[name] = value;
        this.changeJsonDate(name, value);
        this.changeData(name, select, oldValue);
	},
	
	setValue: function(name, value, obj){
		if (name==="id"){
			if (value!==this.module.json.id) {
                if (!value) {
                    this.designer.notice(MWF.APPFD.LP.notNullId, "error", this.module.form.designer.propertyContentArea, {
                        x: "right",
                        y: "bottom"
                    });
                    obj.focus();
                    return false;
                } else {
                    var check = this.module.form.checkModuleId(value, this.module.json.type);
                    if (check.elementConflict) {
                        this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {
                            x: "right",
                            y: "bottom"
                        });
                        obj.focus();
                        return false;
                    } else {
                        var json = this.module.form.json.moduleList[this.module.json.id];
                        this.module.form.json.moduleList[value] = json;
                        delete this.module.form.json.moduleList[this.module.json.id];
                    }
                }

                // if (this.module.form.json.moduleList[value]){
				// 	this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
				// 	obj.focus();
				// 	return false;
				// }else{
				//     var flag = false;
                 //    if (this.module.form.subformList){
                 //        Object.each(this.module.form.subformList, function(o, k){
                 //            if (o.subformData.moduleList[value] && o.subformData.moduleList[value] ) flag = true;
                 //        });
                 //    }
                 //    if (flag){
                 //        this.designer.notice(MWF.APPFD.LP.repetitionsId, "error", this.module.form.designer.propertyContentArea, {x:"right", y:"bottom"});
                 //        obj.focus();
                 //        return false;
                 //    }else{
                 //        var json = this.module.form.json.moduleList[this.module.json.id];
                 //        this.module.form.json.moduleList[value]=json;
                 //        delete this.module.form.json.moduleList[this.module.json.id];
                 //    }
				// }
			}
		}
		//var oldValue = this.data[name];

        var names = name.split(".");
        var oldValue = this.data;
        for (var idx = 0; idx<names.length; idx++){
            if (!oldValue[names[idx]]){
                oldValue = null;
                break;
            }else{
                oldValue = oldValue[names[idx]];
            }
        }

		//this.data[name] = value;
        this.changeJsonDate(names, value);
        this.changeData(name, obj, oldValue);
	},
	setEditNodeStyles: function(node){
		var nodes = node.getChildren();
		if (nodes.length){
			nodes.each(function(el){
				var cName = el.get("class");
				if (cName){
					if (this.form.css[cName]) el.setStyles(this.form.css[cName]);
				}
				this.setEditNodeStyles(el);
			}.bind(this));
		}
	},
	loadScriptInput: function(){

		var scriptNodes = this.propertyContent.getElements(".MWFScript");
		scriptNodes.each(function(node){
			MWF.require("MWF.widget.ScriptEditor", function(){
				var script = new MWF.widget.ScriptEditor(node, {
					"onPostSave": function(script){
						this.saveScriptItem(node, script);
					}.bind(this),
					"onQueryDelete": function(script){
						this.deleteScriptItem(node, script);
					}.bind(this)
				});
				this.setScriptItems(script, node);
			}.bind(this));
		}.bind(this));
	},
	deleteScriptItem: function(node, script){
		var jsondata = node.get("name");
		this.data[jsondata].erase(script.data.id);
		this.process.scripts[script.data.id] = null;
		delete this.process.scripts[script.data.id];
		this.process.process.scriptList.erase(script.data);
	},
	saveScriptItem: function(node, script){
		var jsondata = node.get("name");
		var scriptList = this.data[jsondata];
		
		var data = script.data;
		var scriptData = this.process.scripts[script.data.id];
		if (!scriptData){
			this.process.process.scriptList.push(data);
			this.process.scripts[script.data.id] = data;
		}
		if (scriptList.indexOf(data.id) == -1){
			this.data[jsondata].push(data.id);
		}
	},
	setScriptItems: function(script, node){
		var jsondata = node.get("name");
		var scriptList = this.data[jsondata];
		scriptList.each(function(id){
			if (id){
				var data = this.process.scripts[id];
				if (data) script.setScriptItem(data);
			}
		}.bind(this));
	}
});
MWF.xApplication.process.FormDesigner.PropertyMulti = new Class({
    Extends: MWF.xApplication.process.FormDesigner.Property,
    Implements: [Options, Events],

    initialize: function(form, modules, propertyNode, designer, options){
        this.setOptions(options);
        this.modules = modules;
        this.form = form;
    //    this.data = module.json;
        this.data = {};
        this.htmlPath = this.options.path;
        this.designer = designer;
        this.maplists = {};
        this.propertyNode = propertyNode;
    },
    load: function(){
        if (this.fireEvent("queryLoad")){
            MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
                this.htmlString = responseText;
                MWF.require("MWF.widget.JsonTemplate", function(){
                    this.fireEvent("postLoad");
                }.bind(this));
            }.bind(this));
        }
    },
    show: function(){
        if (!this.propertyContent){
            if (this.htmlString){
                this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
                this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
                this.propertyContent.set("html", this.JsonTemplate.load());

                this.setEditNodeEvent();
                this.setEditNodeStyles(this.propertyContent);
                this.loadPropertyTab();
                this.loadMaplist();
                this.loadScriptArea();
                this.loadTreeData();
                this.loadArrayList();
                //this.loadEventsEditor();
                //this.loadHTMLArea();
                //this.loadJSONArea();
//			this.loadScriptInput();
                //MWF.process.widget.EventsEditor
            }
        }else{
            this.propertyContent.setStyle("display", "block");
        }

    },
    hide: function(){
        if (this.propertyContent) this.propertyContent.destroy();
    },
    changeStyle: function(name){
        this.modules.each(function(module){
            module.setPropertiesOrStyles(name);
        }.bind(this));
    },
    changeData: function(name, input, oldValue){

        this.modules.each(function(module){
            module._setEditStyle(name, input, oldValue);
        }.bind(this));
    },
    changeJsonDate: function(key, value){
        //alert(key+": "+value );
        this.modules.each(function(module){
            module.json[key] = value;
        }.bind(this));
    },
NoSubject's avatar
NoSubject 已提交
2351
});