62 lines
No EOL
1.3 KiB
JavaScript
62 lines
No EOL
1.3 KiB
JavaScript
define([
|
|
"storage_utils",
|
|
|
|
"model/file",
|
|
|
|
"underscore",
|
|
"backbone",
|
|
],
|
|
function(storage_utils,
|
|
FileModel){
|
|
/**
|
|
* Collection to store all the files.
|
|
*/
|
|
var FilesCollection = Backbone.Collection.extend({
|
|
model: FileModel,
|
|
|
|
/**
|
|
* See Bakcbone documentation.
|
|
*
|
|
* @param models - not used
|
|
* @param options - options for intializing the collection
|
|
*/
|
|
initialize:function(models, options){
|
|
if(options.clNum){
|
|
this.clNum = options.clNum;
|
|
}
|
|
|
|
if(options.workspace){
|
|
this.workspace = options.workspace;
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Overload Backbone fetch to use storage utils command instead of ajax call
|
|
*/
|
|
fetch: function(){
|
|
var files = storage_utils.getFiles(this.clNum, this.workspace);
|
|
|
|
this.reset(files);
|
|
},
|
|
|
|
/**
|
|
* Format all the files selected by the user.
|
|
*
|
|
* @return - the formated files
|
|
*/
|
|
getFormatedFiles: function(){
|
|
var formated_files = "";
|
|
|
|
var selected_files = this.where({"is_selected": true});
|
|
|
|
//if files limit is reached "selected_files" == "all_files"
|
|
for(var i = 0, length = selected_files.length ; i < length ; i++){
|
|
formated_files += "\n\t" + selected_files[i].get("depotFile");
|
|
}
|
|
|
|
return formated_files;
|
|
},
|
|
});
|
|
|
|
return FilesCollection;
|
|
}); |