Statement.js 5.3 KB
Newer Older
U
unknown 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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
MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
MWF.xDesktop.requireApp("process.FormDesigner", "Module.View", null, false);
MWF.xApplication.process.FormDesigner.Module.Statement = MWF.FCStatement = new Class({
	Extends: MWF.FCView,
	options: {
		"style": "default",
		"propertyPath": "../x_component_process_FormDesigner/Module/Statement/statement.html"
	},
	
	initialize: function(form, options){
		this.setOptions(options);
		
		this.path = "../x_component_process_FormDesigner/Module/Statement/";
		this.cssPath = "../x_component_process_FormDesigner/Module/Statement/"+this.options.style+"/css.wcss";

        this.imagePath_default = "../x_component_query_ViewDesigner/$Statement/";
        this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";

		this._loadCss();
		this.moduleType = "element";
		this.moduleName = "statement";

		this.form = form;
		this.container = null;
		this.containerNode = null;
	},
	_createMoveNode: function(){
		this.moveNode = new Element("div", {
			"MWFType": "statement",
			"id": this.json.id,
			"styles": this.css.moduleNodeMove,
			"events": {
				"selectstart": function(){
					return false;
				}
			}
		}).inject(this.form.container);
	},
	_createNode: function(){
		this.node = this.moveNode.clone(true, true);
		this.node.setStyles(this.css.moduleNode);
		this.node.set("id", this.json.id);
		this.node.addEvent("selectstart", function(){
			return false;
		});
U
unknown 已提交
46

U
unknown 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
		this.iconNode = new Element("div", {
			"styles": this.css.iconNode
		}).inject(this.node);
		new Element("div", {
			"styles": this.css.iconNodeIcon
		}).inject(this.iconNode);
		new Element("div", {
			"styles": this.css.iconNodeText,
			"text": "Statement"
		}).inject(this.iconNode);

		this.iconNode.addEvent("click", function(){
            this._checkView();
        }.bind(this));
	},
    _createViewNode: function(callback){

        if (!this.viewNode) this.viewNode = new Element("div", {"styles": this.css.viewNode}).inject(this.node);
        if( !this.actionbarNode)this.actionbarNode = new Element("div.actionbarNode",{}).inject( this.viewNode, "top" );

        this.node.setStyle("background", "transparent");


        this.viewTable = new Element("table", {
            "styles": this.css.viewTitleTableNode,
            "border": "0px",
            "cellPadding": "0",
            "cellSpacing": "0"
        }).inject(this.viewNode);
        this.viewLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);

        if (this.json.select!="no"){
            this.viewSelectCell = new Element("td", {
                "styles": this.css.viewTitleCellNode
            }).inject(this.viewLine);
            this.viewSelectCell.setStyle("width", "10px");
        }

U
unknown 已提交
85 86
        MWF.Actions.get("x_query_assemble_designer").getStatement(this.json["queryStatement"].id, function(json){
            var viewData = JSON.decode(json.data.view);
U
unknown 已提交
87 88 89 90 91 92 93

            this.viewData = viewData;
            if( this.json.actionbar === "show" ){
                this.actionbarList = [];
                this._showActionbar();
            }

U
unknown 已提交
94
            var columnList = viewData.data ? (viewData.data.selectEntryList || viewData.data.selectList) : [];
U
unknown 已提交
95 96 97 98 99 100 101 102 103 104 105 106 107 108
            columnList.each(function(column){
                if (!column.hideColumn){
                    var viewCell = new Element("td", {
                        "styles": this.css.viewTitleCellNode,
                        "text": column.displayName
                    }).inject(this.viewLine);
                }
            }.bind(this));

            if (callback) callback();
        }.bind(this));
        this._setViewNodeTitle();
    },
    _checkView: function(callback){
U
unknown 已提交
109
        if (this.json["queryStatement"] && this.json["queryStatement"]!="none"){
U
unknown 已提交
110 111 112 113 114 115 116 117 118 119 120 121
            this.iconNode.setStyle("display", "none");
            if (this.viewNode) this.viewNode.destroy();
            this.viewNode = null;
            this._createViewNode(function(){
                if (callback) callback();
            }.bind(this));
        }else{
            this.iconNode.setStyle("display", "block");
            if (this.viewNode) this.viewNode.destroy();
            this.node.setStyles(this.css.moduleNode);
            if (callback) callback();
        }
U
unknown 已提交
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
    },
    _setEditStyle: function(name, input, oldValue){
        if (name=="queryStatement"){
            if (this.json[name]!=oldValue) this._checkView();
        }
        if (name=="select") this._checkSelect();
        if (name=="isTitle") this._checkTitle();
        if (name=="titleStyles") this._setTitleStyles();

        if (name=="name"){
            var title = this.json.name || this.json.id;
            var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
            this.treeNode.setText("<"+text+"> "+title);
        }
        if (name=="id"){
            if (!this.json.name){
                var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
                this.treeNode.setText("<"+text+"> "+this.json.id);
            }
            this.treeNode.setTitle(this.json.id);
            this.node.set("id", this.json.id);
        }
        if(name=="actionbar"){
            this.json.actionbar === "show" ? this._showActionbar() : this._hideActionbar();
        }

        this._setEditStyle_custom(name, input, oldValue);

U
unknown 已提交
150 151
    }
});