@@ -11,7 +11,8 @@ import sort from '../util/sorter';
1111import FileAPI from '../api/File' ;
1212import WebLinkAPI from '../api/WebLink' ;
1313import Cache from '../util/Cache' ;
14- import { FIELDS_TO_FETCH , CACHE_PREFIX_FOLDER , X_REP_HINTS } from '../constants' ;
14+ import getFields from '../util/fields' ;
15+ import { CACHE_PREFIX_FOLDER , X_REP_HINTS } from '../constants' ;
1516import getBadItemError from '../util/error' ;
1617import type {
1718 BoxItem ,
@@ -66,6 +67,16 @@ class Folder extends Item {
6667 */
6768 errorCallback : Function ;
6869
70+ /**
71+ * @property {boolean }
72+ */
73+ includePreviewFields : boolean ;
74+
75+ /**
76+ * @property {boolean }
77+ */
78+ includePreviewSidebarFields : boolean ;
79+
6980 /**
7081 * Creates a key for the cache
7182 *
@@ -217,7 +228,7 @@ class Folder extends Item {
217228 params : {
218229 offset : this . offset ,
219230 limit : LIMIT_ITEM_FETCH ,
220- fields : FIELDS_TO_FETCH
231+ fields : getFields ( this . includePreviewFields , this . includePreviewSidebarFields )
221232 } ,
222233 headers : { 'X-Rep-Hints' : X_REP_HINTS }
223234 } )
@@ -228,12 +239,14 @@ class Folder extends Item {
228239 /**
229240 * Gets a box folder and its items
230241 *
231- * @param {string } id Folder id
232- * @param {string } sortBy sort by field
233- * @param {string } sortDirection sort direction
234- * @param {Function } successCallback Function to call with results
235- * @param {Function } errorCallback Function to call with errors
236- * @param {boolean } forceFetch Bypasses the cache
242+ * @param {string } id - Folder id
243+ * @param {string } sortBy - sort by field
244+ * @param {string } sortDirection - sort direction
245+ * @param {Function } successCallback - Function to call with results
246+ * @param {Function } errorCallback - Function to call with errors
247+ * @param {boolean|void } [forceFetch] - Bypasses the cache
248+ * @param {boolean|void } [includePreview] - Optionally include preview fields
249+ * @param {boolean|void } [includePreviewSidebar] - Optionally include preview sidebar fields
237250 * @return {void }
238251 */
239252 folder (
@@ -242,7 +255,9 @@ class Folder extends Item {
242255 sortDirection : SortDirection ,
243256 successCallback : Function ,
244257 errorCallback : Function ,
245- forceFetch : boolean = false
258+ forceFetch : boolean = false ,
259+ includePreviewFields : boolean = false ,
260+ includePreviewSidebarFields : boolean = false
246261 ) : void {
247262 if ( this . isDestroyed ( ) ) {
248263 return ;
@@ -256,6 +271,8 @@ class Folder extends Item {
256271 this . errorCallback = errorCallback ;
257272 this . sortBy = sortBy ;
258273 this . sortDirection = sortDirection ;
274+ this . includePreviewFields = includePreviewFields ;
275+ this . includePreviewSidebarFields = includePreviewSidebarFields ; // implies preview
259276
260277 // Clear the cache if needed
261278 if ( forceFetch ) {
@@ -316,7 +333,7 @@ class Folder extends Item {
316333 return Promise . reject ( ) ;
317334 }
318335
319- const url = `${ this . getUrl ( ) } ?fields=${ FIELDS_TO_FETCH } ` ;
336+ const url = `${ this . getUrl ( ) } ?fields=${ getFields ( ) } ` ;
320337 return this . xhr
321338 . post ( {
322339 url,
0 commit comments