1 /** 2 * The following comment prevents JSLint errors concerning undefined global variables. 3 * It tells JSLint that these identifiers are defined elsewhere. 4 */ 5 /*jslint bitwise:true, browser:true, nomen:true, regexp:true, sloppy:true, white:true */ 6 7 /** The following comment is to prevent jslint errors about 8 * using variables before they are defined. 9 */ 10 /*global $, jQuery, Handlebars, dojox, dojo, console, finesse */ 11 12 /** 13 * @fileOverview JavaScript representation of the Finesse Team REST object. 14 * 15 * @name finesse.restservices.Team 16 * @requires finesse.clientservices.ClientServices 17 * @requires Class 18 * @requires finesse.FinesseBase 19 * @requires finesse.restservices.RestBase 20 * @requires finesse.restservices.RestCollectionBase 21 * @requires finesse.restservices.User 22 * @requires finesse.restservices.Users 23 */ 24 25 var finesse = finesse || {}; 26 finesse.restservices = finesse.restservices || {}; 27 28 /** @private */ 29 finesse.restservices.Team = finesse.restservices.RestBase.extend(/** @lends finesse.restservices.Team.prototype */{ 30 31 _teamLayoutConfig: null, 32 33 /** 34 * @class 35 * JavaScript representation of a Team object. Also exposes methods to operate 36 * on the object against the server. 37 * 38 * @param {Object} options 39 * An object with the following properties:<ul> 40 * <li><b>id:</b> The id of the object being constructed</li> 41 * <li><b>onLoad(this): (optional)</b> when the object is successfully loaded from the server</li> 42 * <li><b>onChange(this): (optional)</b> when an update notification of the object is received</li> 43 * <li><b>onAdd(this): (optional)</b> when a notification that the object is created is received</li> 44 * <li><b>onDelete(this): (optional)</b> when a notification that the object is deleted is received</li> 45 * <li><b>onError(rsp): (optional)</b> if loading of the object fails, invoked with the error response object:<ul> 46 * <li><b>status:</b> {Number} The HTTP status code returned</li> 47 * <li><b>content:</b> {String} Raw string of response</li> 48 * <li><b>object:</b> {Object} Parsed object of response</li> 49 * <li><b>error:</b> {Object} Wrapped exception that was caught:<ul> 50 * <li><b>errorType:</b> {String} Type of error that was caught</li> 51 * <li><b>errorMessage:</b> {String} Message associated with error</li> 52 * </ul></li> 53 * </ul></li> 54 * <li><b>parentObj: (optional)</b> The parent object</li></ul> 55 * @constructs finesse.restservices.Team 56 **/ 57 init: function (options) { 58 this._super(options); 59 }, 60 61 /** 62 * @private 63 * Gets the REST class for the current object - this is the Team class. 64 * @returns {Object} The Team constructor. 65 */ 66 getRestClass: function () { 67 return finesse.restservices.Team; 68 }, 69 70 /** 71 * @private 72 * Gets the REST type for the current object - this is a "Team". 73 * @returns {String} The Team string. 74 */ 75 getRestType: function () { 76 return "Team"; 77 }, 78 79 /** 80 * @private 81 * Override default to indicate that this object doesn't support making 82 * requests. 83 */ 84 supportsSubscriptions: false, 85 86 /** 87 * Getter for the team id. 88 * @returns {String} The team id. 89 */ 90 getId: function () { 91 this.isLoaded(); 92 return this.getData().id; 93 }, 94 95 /** 96 * Getter for the team name. 97 * @returns {String} The team name 98 */ 99 getName: function () { 100 this.isLoaded(); 101 return this.getData().name; 102 }, 103 104 /** 105 * Getter for the team uri. 106 * @returns {String} The team uri 107 */ 108 getUri: function () { 109 this.isLoaded(); 110 return this.getData().uri; 111 }, 112 113 /** 114 * Constructs and returns a collection of users 115 * @param {options} constructor options 116 * @returns {finesse.restservices.Users} Users collection of User objects 117 */ 118 getUsers: function (options) { 119 this.isLoaded(); 120 options = options || {}; 121 122 options.parentObj = this; 123 // We are using getData() instead of getData.Users because the superclass (RestCollectionBase) 124 // for Users needs the "Users" key to validate the provided payload matches the class type. 125 options.data = this.getData(); 126 127 return new finesse.restservices.Users(options); 128 }, 129 130 /** 131 * Getter for a teamNotReadyReasonCodes collection object that is associated with Team. 132 * @param callbacks 133 * @returns {teamNotReadyReasonCodes} 134 * A teamNotReadyReasonCodes collection object. 135 */ 136 getTeamNotReadyReasonCodes: function (callbacks) { 137 var options = callbacks || {}; 138 options.parentObj = this; 139 this.isLoaded(); 140 141 if (!this._teamNotReadyReasonCodes) { 142 this._teamNotReadyReasonCodes = new finesse.restservices.TeamNotReadyReasonCodes(options); 143 } 144 145 return this._teamNotReadyReasonCodes; 146 }, 147 148 /** 149 * Getter for a teamWrapUpReasons collection object that is associated with Team. 150 * @param callbacks 151 * @returns {teamWrapUpReasons} 152 * A teamWrapUpReasons collection object. 153 */ 154 getTeamWrapUpReasons: function (callbacks) { 155 var options = callbacks || {}; 156 options.parentObj = this; 157 this.isLoaded(); 158 159 if (!this._teamWrapUpReasons) { 160 this._teamWrapUpReasons = new finesse.restservices.TeamWrapUpReasons(options); 161 } 162 163 return this._teamWrapUpReasons; 164 }, 165 166 /** 167 * Getter for a teamSignOutReasonCodes collection object that is associated with Team. 168 * @param callbacks 169 * @returns {teamSignOutReasonCodes} 170 * A teamSignOutReasonCodes collection object. 171 */ 172 173 getTeamSignOutReasonCodes: function (callbacks) { 174 var options = callbacks || {}; 175 options.parentObj = this; 176 this.isLoaded(); 177 178 if (!this._teamSignOutReasonCodes) { 179 this._teamSignOutReasonCodes = new finesse.restservices.TeamSignOutReasonCodes(options); 180 } 181 182 return this._teamSignOutReasonCodes; 183 }, 184 185 /** 186 * Getter for a teamPhoneBooks collection object that is associated with Team. 187 * @param callbacks 188 * @returns {teamPhoneBooks} 189 * A teamPhoneBooks collection object. 190 */ 191 getTeamPhoneBooks: function (callbacks) { 192 var options = callbacks || {}; 193 options.parentObj = this; 194 this.isLoaded(); 195 196 if (!this._phonebooks) { 197 this._phonebooks = new finesse.restservices.TeamPhoneBooks(options); 198 } 199 200 return this._phonebooks; 201 }, 202 203 /** 204 * Getter for a teamLayoutConfig object that is associated with Team. 205 * @param callbacks 206 * @returns {teamLayoutConfig} 207 */ 208 getTeamLayoutConfig: function (callbacks) { 209 var options = callbacks || {}; 210 options.parentObj = this; 211 this.isLoaded(); 212 213 console.log("In getTeamLayoutConfig"); 214 if (this._teamLayoutConfig === null) { 215 this._teamLayoutConfig = new finesse.restservices.TeamLayoutConfig(options); 216 } 217 218 return this._teamLayoutConfig; 219 } 220 221 }); 222