#set($layout = 'None.vm')
var newTagTemplate = "$link.contextPath/ajp/TagListNewTag.vhtml";
var tagTypeListTemplate = "$link.contextPath/ajp/TagListTagTypeList.html";

var newTagTypeTemplate = "$link.contextPath/ajp/TagTypeListNewTagType.vhtml";

var tagListTemplate = "$link.contextPath/ajp/TaskDetailTagList.html";
var tagSelecterTemplate = "$link.contextPath/ajp/TaskDetailTagSelecter.html";
var commentListTemplate = "$link.contextPath/ajp/TaskDetailCommentList.html";
var linkedTaskListTemplate = "$link.contextPath/ajp/TaskDetailLinkedTaskList.vhtml";
var linkedTaskTagSelecterTemplate = "$link.contextPath/ajp/TaskDetailLinkedTaskTagSelecter.html";
/**
 * タスク詳細閲覧用通常リクエストを作成する
 */
function buildViewUrl(taskId) {
	var url = "$link.setAction('/view')";
	url += '?' + $H({taskId:taskId}).toQueryString();
	return url;
}
/// REST /////////////////////////////////////////////////////////
/**
 * タスク削除用RESTリクエストを作成する
 */
function buildDeleteTaskRequest(targetTaskId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/delete')";
	req.param = $H({taskId:targetTaskId}).toQueryString();
	req.method = 'POST';
	
	return req;
}
/**
 * タスク状態更新用RESTリクエストを作成する
 */
function buildUpdateStatusRequest(targetTaskId, updateStatusId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/changeStatus')";
	req.param = $H({taskId:targetTaskId, statusId:updateStatusId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タスク優先度更新用RESTリクエストを作成する
 */
function buildUpdatePriorityRequest(taskId, priority) {
	var req = Class.create();
	req.url = "$link.setRelative('/')" + taskId + "/rest/update/priority/" + priority;
	req.method = 'POST';
	return req;
}
/**
 * タスクのタグ編集用RESTリクエストを作成する
 */
function buildEditTagListRequest(targetTaskId, tagList) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/editTagList')";
	req.param = $H({taskId:targetTaskId, tagList:tagList}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タスク内容編集用RESTリクエストを作成する
 */
function buildEditContentsRequest(targetTaskId, contents) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/editContents')";
	req.param = $H({taskId:targetTaskId, contents:contents}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * ファイル削除用RESTリクエストを作成する
 */
function buildDeleteFileRequest(targetFileId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/deleteFile')";
	req.param = $H({fileId:targetFileId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * コメント追加用RESTリクエストを作成する
 */
function buildAddCommentRequest(targetTaskId, commentator, comment) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/addComment')";
	req.param = $H({
		taskId:targetTaskId,
		commentator:commentator,
		comment:comment}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * プロパティ編集用RESTリクエストを作成する
 */
function buildEditPropertyRequest(property) {
	var req = Class.create();
	req.url = "$link.setRelative('/')" + property.taskId + "/rest/update/property";
	req.param = $H({
		estimatedManHour: property.estimatedManHour,
		deadEndDate: property.deadEndDate}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タスク関連リンク削除用RESTリクエストを作成する
 */
function buildUnlinkTaskRequest(fromTaskId, toTaskId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/unlink')";
	req.param = $H({
		srcTaskId:fromTaskId,
		destTaskId: toTaskId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * 関連タスクリンク用RESTリクエストを作成する
 */
function buildLinkTaskRequest(fromTaskId, toTaskId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/link')";
	req.param = $H({
		srcTaskId:fromTaskId,
		destTaskId: toTaskId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * 関連タスク追加用RESTリクエストを作成する
 */
function buildAddLinkedTaskRequest(parentTaskId, contents, tagList) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/addLinkedTask')";
	req.param = $H({
		taskId:parentTaskId,
		contents:contents,
		tagList:tagList}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タグ状態更新用RESTリクエストを作成する
 */
function buildToggleTagActivityRequest(tagId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tag/toggleActivity')";
	req.param = $H({tagId:tagId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タグ削除用RESTリクエストを作成する
 */
function buildDeleteTagRequest(tagId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tag/delete')";
	req.param = $H({tagId:tagId}).toQueryString();
	req.method = 'POST';
	return req;
}
/**
 * タグの種別変更用RESTリクエストを作成する
 */
function buildChangeTypeOfTagRequest(tagId, tagTypeId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tag/changeType')";
	req.param = $H({tagId:tagId, tagTypeId:tagTypeId}).toQueryString();
	req.method = 'POST';
	return req;
}
function buildDeleteTagTypeRequest(tagTypeId) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tagType/delete')";
	req.param = $H({tagTypeId:tagTypeId}).toQueryString();
	req.method = 'POST';
	return req;
}
function buildChangeTagTypeStyleRequest(tagTypeId, styleClass) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tagType/changeStyle')";
	req.param = $H({tagTypeId:tagTypeId, styleClass:styleClass}).toQueryString();
	req.method = 'POST';
	return req;
}
function buildEditTagType(tagTypeId, name, sortOrder) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tagType/edit')";
	req.param = $H({tagTypeId:tagTypeId, name:name, sortOrder:sortOrder}).toQueryString();
	req.method = 'POST';
	return req;
}
function buildAddTagType(name, sortOrder) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tagType/add')";
	req.param = $H({name:name, sortOrder:sortOrder}).toQueryString();
	req.method = 'POST';
	return req;
}
function buildAddTag(name) {
	var req = Class.create();
	req.url = "$link.setAction('/rest/tag/add')";
	req.param = $H({name:name}).toQueryString();
	req.method = 'POST';
	return req;
}