Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(9)

Delta Between Two Patch Sets: app/store/charm.js

Issue 7947045: Add editorial request for browser sidebar.
Left Patch Set: Created 12 years ago
Right Patch Set: Add editorial request for browser sidebar. Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « app/models/charm.js ('k') | app/subapps/browser/browser.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 'use strict'; 1 'use strict';
2 2
3 /** 3 /**
4 * Provide the CharmStore class. 4 * Provide the CharmStore class.
5 * 5 *
6 * @module store 6 * @module store
7 * @submodule store.charm 7 * @submodule store.charm
8 */ 8 */
9 9
10 YUI.add('juju-charm-store', function(Y) { 10 YUI.add('juju-charm-store', function(Y) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 137
138 138
139 /** 139 /**
140 * Api helper for the updated charmworld api v0. 140 * Api helper for the updated charmworld api v0.
141 * 141 *
142 * @class Charmworld0 142 * @class Charmworld0
143 * @extends {Base} 143 * @extends {Base}
144 * 144 *
145 */ 145 */
146 ns.Charmworld0 = Y.Base.create('charmworld0', Y.Base, [], { 146 ns.Charmworld0 = Y.Base.create('charmworld0', Y.Base, [], {
147 _api_root: '/api/0/', 147 _apiRoot: '/api/0/',
148 148
149 /** 149 /**
150 * Send the actual request and handle response from the api. 150 * Send the actual request and handle response from the api.
151 * 151 *
152 * @method _makeRequest 152 * @method _makeRequest
153 * @param {Object} args any query params and arguments required. 153 * @param {Object} args any query params and arguments required.
154 * @private 154 * @private
155 * 155 *
156 */ 156 */
157 _makeRequest: function(apiEndpoint, callbacks, args) { 157 _makeRequest: function(apiEndpoint, callbacks, args) {
(...skipping 21 matching lines...) Expand all
179 callbacks.failure(res, io_request); 179 callbacks.failure(res, io_request);
180 } 180 }
181 } 181 }
182 }); 182 });
183 }, 183 },
184 184
185 /** 185 /**
186 * Given a result list, turn that into a BrowserCharmList object for the 186 * Given a result list, turn that into a BrowserCharmList object for the
187 * application to use. 187 * application to use.
188 * 188 *
189 * @method _results_to_charmlist 189 * @method _resultsToCharmlist
190 * @param {Object} JSON decoded data from response. 190 * @param {Object} JSON decoded data from response.
191 * @private 191 * @private
192 * 192 *
193 */ 193 */
194 results_to_charmlist: function(data) { 194 resultsToCharmlist: function(data) {
195 return new Y.juju.models.BrowserCharmList({ 195 return new Y.juju.models.BrowserCharmList({
196 items: data 196 items: data
197 }); 197 });
198 }, 198 },
199 199
200 /** 200 /**
201 * Initialize the API helper. Constructs a reusable datasource for all 201 * Initialize the API helper. Constructs a reusable datasource for all
202 * calls. 202 * calls.
203 * 203 *
204 * @method initializer 204 * @method initializer
205 * @param {Object} cfg configuration object. 205 * @param {Object} cfg configuration object.
206 * 206 *
207 */ 207 */
208 initializer: function(cfg) { 208 initializer: function(cfg) {
209 // @todo this isn't set on initial load so we have to manually hit the 209 // @todo this isn't set on initial load so we have to manually hit the
210 // setter to get datasource filled in. Must be a better way. 210 // setter to get datasource filled in. Must be a better way.
211 this.set('api_host', cfg.api_host); 211 this.set('apiHost', cfg.apiHost);
212 }, 212 },
213 213
214 /** 214 /**
215 * Fetch the sidebar editoral content from the charmworld api. 215 * Fetch the sidebar editoral content from the charmworld api.
216 * 216 *
217 * @method sidebar_editorial 217 * @method sidebarEditorial
218 * @return {Object} data loaded from the api call. 218 * @return {Object} data loaded from the api call.
219 * 219 *
220 */ 220 */
221 sidebar_editorial: function(callbacks, bindScope) { 221 sidebarEditorial: function(callbacks, bindScope) {
222 if (bindScope) { 222 if (bindScope) {
223 callbacks.success = Y.bind(callbacks.success, bindScope); 223 callbacks.success = Y.bind(callbacks.success, bindScope);
224 callbacks.failure = Y.bind(callbacks.failure, bindScope); 224 callbacks.failure = Y.bind(callbacks.failure, bindScope);
225 } 225 }
226 226
227 var res = this._makeRequest('sidebar_editorial', callbacks); 227 var res = this._makeRequest('sidebarEditorial', callbacks);
228 } 228 }
229 }, { 229 }, {
230 ATTRS: { 230 ATTRS: {
231 /** 231 /**
232 * Required attribute for the host to talk to for api calls. 232 * Required attribute for the host to talk to for api calls.
233 * 233 *
234 * @attribute api_host 234 * @attribute apiHost
235 * @default undefined 235 * @default undefined
236 * @type {String} 236 * @type {String}
237 * 237 *
238 */ 238 */
239 api_host: { 239 apiHost: {
240 required: true, 240 required: true,
241 setter: function(val) { 241 setter: function(val) {
242 // Make sure we update the datasource if our api_host changes. 242 // Make sure we update the datasource if our apiHost changes.
243 var source = val + this._api_root; 243 var source = val + this._apiRoot;
244 this.set('datasource', new Y.DataSource.IO({ source: source })); 244 this.set('datasource', new Y.DataSource.IO({ source: source }));
245 return val; 245 return val;
246 } 246 }
247 }, 247 },
248 248
249 /** 249 /**
250 * Auto constructed datasource object based on the api_host attribute. 250 * Auto constructed datasource object based on the apiHost attribute.
251 * @attribute datasource 251 * @attribute datasource
252 * @type {Datasource} 252 * @type {Datasource}
253 * 253 *
254 */ 254 */
255 datasource: {} 255 datasource: {}
256 } 256 }
257 }); 257 });
258 258
259 }, '0.1.0', { 259 }, '0.1.0', {
260 requires: [ 260 requires: [
261 'datasource-io', 261 'datasource-io',
262 'json-parse', 262 'json-parse',
263 'juju-charm-id', 263 'juju-charm-id',
264 'juju-charm-models', 264 'juju-charm-models',
265 'querystring-stringify' 265 'querystring-stringify'
266 ] 266 ]
267 }); 267 });
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b