Main.js 5.0 KB
Newer Older
NoSubject's avatar
NoSubject 已提交
1 2 3
MWF.xApplication.TeamWork = MWF.xApplication.TeamWork || {};
MWF.xApplication.TeamWork.Task = MWF.xApplication.TeamWork.Task || {};
MWF.xApplication.TeamWork.Task.options.multitask = true;
J
jinfei 已提交
4 5
// MWF.xDesktop.requireApp("TeamWork", "Task", null, false);
MWF.xDesktop.requireApp("TeamWork", "Common", null, false);
NoSubject's avatar
NoSubject 已提交
6 7 8 9 10 11
MWF.xApplication.TeamWork.Task.Main = new Class({
	Extends: MWF.xApplication.Common.Main,
	Implements: [Options, Events],

	options: {
		"style": "default",
J
jinfei 已提交
12
		"name": "TeamWork.Task",
NoSubject's avatar
NoSubject 已提交
13 14 15 16 17 18 19
		"icon": "icon.png",
		"width": "1000",
		"height": "700",
		"isResize": false,
		"isMax": false,
		"title": MWF.xApplication.TeamWork.Task.LP.title
	},
J
jinfei 已提交
20

NoSubject's avatar
NoSubject 已提交
21 22
	onQueryLoad: function(){
		this.lp = MWF.xApplication.TeamWork.Task.LP;
J
jinfei 已提交
23
		//this.lp = MWF.xApplication.TeamWork.LP; debugger;
24
		this.cssPath = "../x_component_TeamWork/$Task/"+this.options.style+"/css.wcss";
J
jinfei 已提交
25 26 27

		if (!this.status) {
		} else {
28 29 30 31 32 33 34
			// this.options.workId = this.status.workId;
			// this.options.workCompletedId = this.status.workCompletedId;
			// this.options.jobId = this.status.jobId;
			// this.options.priorityWork = this.status.priorityWork;
			// this.options.readonly = (this.status.readonly === "true");
			this.options.taskId = this.status.taskId;
			this.options.project = this.status.project;
NoSubject's avatar
NoSubject 已提交
35
		}
J
jinfei 已提交
36 37

		this.taskId = this.options.taskId || "";
38
		this.projectId = this.options.project || "";
J
jinfei 已提交
39 40 41 42 43 44 45 46 47 48

		MWF.xDesktop.requireApp("TeamWork", "lp.zh-cn", {
			"onRequestFailure": function(){
				//alert("fail")
			}.bind(this),
			"onSuccess": function(json){
				this.lp = MWF.xApplication.TeamWork.LP;
			}.bind(this)
		}, false);

NoSubject's avatar
NoSubject 已提交
49 50
	},
	loadApplication: function(callback) {
J
jinfei 已提交
51 52 53 54 55
		this.rootActions = MWF.Actions.load("x_teamwork_assemble_control");
		this.orgActions = MWF.Actions.load("x_organization_assemble_express");
		//this.actions = this.rootActions.TaskAction;

		this.node = new Element("div").inject(this.content);
NoSubject's avatar
NoSubject 已提交
56 57 58
		//alert(this.taskId)


J
jinfei 已提交
59 60 61 62 63 64 65 66
		MWF.xDesktop.requireApp("TeamWork", "Task", function(){
			//alert("loaded")
			var data = {
				taskId:this.taskId
			};
			var opt={
				"type":"window"
			};
67

J
jinfei 已提交
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
			var task = new MWF.xApplication.TeamWork.Task(this,data,opt);
			task.open();
		}.bind(this));
	},
	setScrollBar: function(node, view, style, offset, callback){
		if (!style) style = "default";
		if (!offset){
			offset = {
				"V": {"x": 0, "y": 0},
				"H": {"x": 0, "y": 0}
			};
		}
		MWF.require("MWF.widget.ScrollBar", function(){
			if(this.scrollbar && this.scrollbar.scrollVAreaNode){
				this.scrollbar.scrollVAreaNode.destroy();
				delete this.scrollbar;
			}
			this.scrollbar = new MWF.widget.ScrollBar(node, {
				"style": style,
				"offset": offset,
				"where": "before",
				"indent": false,
				"distance": 100,
				"friction": 4,
				"onScroll": function (y) {
					var scrollSize = node.getScrollSize();
					var clientSize = node.getSize();
					var scrollHeight = scrollSize.y - clientSize.y;
					if (y + 200 > scrollHeight && view && view.loadElementList) {
						if (! view.isItemsLoaded) view.loadElementList()
					}
				}.bind(this)
			});
			if (callback) callback();
		}.bind(this));
		return false;
	},
	setLoading:function(container){
		var _height = container.getHeight();
		var _width = container.getWidth();
		var loading = new Element("img",{styles:{
				"margin-top":"10px",
				"margin-bottom":"10px",
				"width":"100px",
				"height":"20px"
113 114
			},"src":"../x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
		//var loading = new Element("img",{"src":"../x_component_TeamWork/$Main/default/icon/loading.gif"}).inject(container);
J
jinfei 已提交
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

		loading.setStyles({
			"margin-left":(_width-loading.getWidth())/2+"px"
		})
	},
	showErrorMessage:function(xhr,text,error){
		var errorText = error;
		var errorMessage;
		if (xhr) errorMessage = xhr.responseText;
		if(errorMessage!=""){
			var e = JSON.parse(errorMessage);
			if(e.message){
				this.notice( e.message,"error");
			}else{
				this.notice( errorText,"error");
			}
		}else{
			this.notice(errorText,"error");
		}

	},
	selectCalendar : function( target, container, options, callback ){
		var type = options.type;
		var calendarOptions = {
			"style" : "xform",
			"isTime":  type == "time" || type.toLowerCase() == "datetime",
			"timeOnly": type == "time",
			"target": container,
			"onQueryComplate" : function( dateString ,date ){
				var json={
					"action":"ok",
					"dateString":dateString,
					"date":date
				};
				if( callback )callback( json );
			}.bind(this),
			"onClear":function(){
				var json={
					"action":"clear"
				};
				if(callback) callback(json);
				//if(this.calendar) delete this.calendar;
			}.bind(this),
			"onHide":function(){

			}.bind(this)
		};
		if( options.calendarOptions ){
			calendarOptions = Object.merge( calendarOptions, options.calendarOptions )
		}

		MWF.require("MWF.widget.Calendar", function(){
			this.calendar = new MWF.widget.Calendar( target, calendarOptions);
			this.calendar.show();

		}.bind(this));
	},
172 173 174 175
    recordStatus: function(){
        debugger;
        return {"taskId": this.options.taskId, "project": this.options.project};
    }
NoSubject's avatar
NoSubject 已提交
176 177

});