1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-30 08:53:49 +00:00
seahub/static/scripts/app/collections/repos.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

define([
'underscore',
'backbone',
2016-03-09 12:54:33 +00:00
'common',
'app/models/repo'
2016-03-09 12:54:33 +00:00
], function(_, Backbone, Common, Repo) {
'use strict';
var RepoCollection = Backbone.Collection.extend({
model: Repo,
2015-02-04 13:57:26 +00:00
type: 'mine',
2016-03-09 12:54:33 +00:00
url: function() {
return Common.getUrl({name: 'repos'});
},
2015-02-04 13:57:26 +00:00
initialize: function(options) {
2015-02-01 06:15:00 +00:00
//console.log('init RepoCollection');
2015-02-04 13:57:26 +00:00
if (options) {
this.type = options.type ? options.type : 'mine';
}
2015-01-31 05:17:47 +00:00
},
fetch: function(options) {
// override default fetch url
options = options ? _.clone(options) : {};
2016-03-09 12:54:33 +00:00
options.url = this.url() + '?type=' + this.type;
2015-01-31 05:17:47 +00:00
//call Backbone's fetch
return Backbone.Collection.prototype.fetch.call(this, options);
},
create: function(model, options) {
// override default create url
options = options ? _.clone(options) : {};
2016-03-19 02:36:18 +00:00
options.url = this.url() + '?from=web';
//call Backbone's create
return Backbone.Collection.prototype.create.call(this, model, options);
}
});
2015-02-01 06:15:00 +00:00
return RepoCollection;
});