1 /* 2 * ***** BEGIN LICENSE BLOCK ***** 3 * Zimbra Collaboration Suite Web Client 4 * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. 5 * 6 * The contents of this file are subject to the Common Public Attribution License Version 1.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at: https://www.zimbra.com/license 9 * The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 10 * have been added to cover use of software over a computer network and provide for limited attribution 11 * for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B. 12 * 13 * Software distributed under the License is distributed on an "AS IS" basis, 14 * WITHOUT WARRANTY OF ANY KIND, either express or implied. 15 * See the License for the specific language governing rights and limitations under the License. 16 * The Original Code is Zimbra Open Source Web Client. 17 * The Initial Developer of the Original Code is Zimbra, Inc. All rights to the Original Code were 18 * transferred by Zimbra, Inc. to Synacor, Inc. on September 14, 2015. 19 * 20 * All portions of the code are Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016 Synacor, Inc. All Rights Reserved. 21 * ***** END LICENSE BLOCK ***** 22 */ 23 24 /** 25 * Creates an empty task view. 26 * @constructor 27 * @class 28 * Simple read-only view of a task. It looks more or less like a message - 29 * the notes have their own area at the bottom, and everything else goes into a 30 * header section at the top. 31 * 32 * @author Parag Shah 33 * 34 * @param parent [DwtComposite] parent widget 35 * @param posStyle [constant] positioning style 36 * @param controller [ZmController] owning controller 37 */ 38 ZmTaskView = function(parent, posStyle, controller) { 39 40 var id = ZmId.getViewId(ZmId.VIEW_TASK, null, parent._htmlElId); 41 ZmCalItemView.call(this, parent, posStyle, controller, id); 42 }; 43 44 ZmTaskView.prototype = new ZmCalItemView; 45 ZmTaskView.prototype.constructor = ZmTaskView; 46 ZmTaskView.prototype.isZmTaskView = true; 47 48 // Public methods 49 50 ZmTaskView.prototype.toString = 51 function() { 52 return "ZmTaskView"; 53 }; 54 55 ZmTaskView.prototype.getTitle = 56 function() { 57 return [ZmMsg.zimbraTitle, this._calItem.getName()].join(": "); 58 }; 59 60 ZmTaskView.prototype.close = 61 function() { 62 this._controller._app.popView(); 63 }; 64 65 ZmTaskView.prototype.setSelectionHdrCbox = function(check) {}; 66 67 ZmTaskView.prototype._getSubs = 68 function(calItem) { 69 var subject = calItem.getName(); 70 var location = calItem.location; 71 var isException = calItem._orig ? calItem._orig.isException : calItem.isException; 72 var startDate = calItem.startDate ? AjxDateFormat.getDateInstance().format(calItem.startDate) : null; 73 var dueDate = calItem.endDate ? AjxDateFormat.getDateInstance().format(calItem.endDate) : null; 74 var priority = calItem.priority ? ZmCalItem.getLabelForPriority(calItem.priority) : null; 75 var status = calItem.status ? ZmCalItem.getLabelForStatus(calItem.status) : null; 76 var pComplete = calItem.pComplete; 77 var recurStr = calItem.isRecurring() ? calItem.getRecurBlurb() : null; 78 var attachStr = this._getAttachString(calItem); 79 var alarm = calItem.alarm; 80 var remindDate = calItem.remindDate ? AjxDateFormat.getDateInstance().format(calItem.remindDate) : null; 81 var remindTime = calItem.remindDate ? AjxDateFormat.getTimeInstance(AjxDateFormat.SHORT).format(calItem.remindDate) : ""; 82 83 if (this._objectManager) { 84 this._objectManager.setHandlerAttr(ZmObjectManager.DATE, 85 ZmObjectManager.ATTR_CURRENT_DATE, 86 calItem.startDate); 87 88 subject = this._objectManager.findObjects(subject, true); 89 if (location) location = this._objectManager.findObjects(location, true); 90 if (startDate) startDate = this._objectManager.findObjects(startDate, true); 91 if (dueDate) dueDate = this._objectManager.findObjects(dueDate, true); 92 } 93 94 return { 95 id: this._htmlElId, 96 subject: subject, 97 location: location, 98 isException: isException, 99 startDate: startDate, 100 dueDate: dueDate, 101 priority: priority, 102 status: status, 103 pComplete: pComplete, 104 recurStr: recurStr, 105 attachStr: attachStr, 106 remindDate: remindDate, 107 remindTime: remindTime, 108 alarm: alarm, 109 folder: appCtxt.getTree(ZmOrganizer.TASKS).getById(calItem.folderId), 110 folderLabel: ZmMsg.folder, 111 isTask:true, 112 _infoBarId:this._infoBarId 113 }; 114 }; 115 116 // Private / protected methods 117 118 ZmTaskView.prototype._renderCalItem = 119 function(calItem) { 120 121 if(this._controller.isReadingPaneOn() && !this._newTab) { 122 this._lazyCreateObjectManager(); 123 124 var subs = this._getSubs(calItem); 125 var editBtnCellId = this._htmlElId + "_editBtnCell"; 126 this._hdrTableId = this._htmlElId + "_hdrTable"; 127 128 var el = this.getHtmlElement(); 129 el.innerHTML = AjxTemplate.expand("tasks.Tasks#ReadOnlyView", subs); 130 this._setTags(calItem); 131 132 // content/body 133 var hasHtmlPart = (calItem.notesTopPart && calItem.notesTopPart.getContentType() == ZmMimeTable.MULTI_ALT); 134 var mode = (hasHtmlPart && appCtxt.get(ZmSetting.VIEW_AS_HTML)) 135 ? ZmMimeTable.TEXT_HTML : ZmMimeTable.TEXT_PLAIN; 136 137 var bodyPart = calItem.getNotesPart(mode); 138 139 if (!bodyPart && calItem.message){ 140 bodyPart = calItem.message.getInviteDescriptionContentValue(ZmMimeTable.TEXT_PLAIN); 141 } 142 143 if (bodyPart) { 144 this._msg = this._msg || this._calItem._currentlyLoaded; 145 if (mode === ZmMimeTable.TEXT_PLAIN) { 146 bodyPart = AjxStringUtil.convertToHtml(bodyPart); 147 } 148 this._makeIframeProxy({container: el, html:bodyPart, isTextMsg:(mode == ZmMimeTable.TEXT_PLAIN)}); 149 } 150 } else { 151 ZmCalItemView.prototype._renderCalItem.call(this, calItem); 152 } 153 Dwt.setLoadedTime("ZmTaskItem"); 154 calItem.addChangeListener(this._taskChangeListener.bind(this)); 155 156 }; 157 158 ZmTaskView.prototype._taskChangeListener = 159 function(ev){ 160 if(ev.event == ZmEvent.E_TAGS || ev.type == ZmEvent.S_TAG) { 161 this._setTags(this._calItem); 162 } 163 }; 164 165 ZmTaskView.prototype._getItemCountType = function() { 166 return ZmId.ITEM_TASK; 167 };