1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-26 23:17:58 +00:00
seahub/static/scripts/app/views/shared-repo.js
Daniel Pan cf1017513a Code clean (#1217)
* Use API to create file/folder instead of Ajax
* Remove sub_repo AJAX api
* Remove repo delete AJAX function
* Remove get_group_basic_info
* Add comment for get_unenc_group_repos
* Remove ajax_repo_change_basic_info and ajax_repo_transfer_owner
* Remove ajax_unset_inner_pub_repe and RepoPublic
* Remove ajax star/unstar a file
* update be shared repo api
* update test public repo
* Remove ajax_repo_remove_share
2016-06-20 18:34:30 +08:00

63 lines
1.9 KiB
JavaScript

define([
'jquery',
'underscore',
'backbone',
'common',
'app/views/widgets/hl-item-view'
], function($, _, Backbone, Common, HLItemView) {
'use strict';
var SharedRepoView = HLItemView.extend({
tagName: 'tr',
template: _.template($('#shared-repo-tmpl').html()),
events: {
'click .unshare-btn': 'removeShare'
},
initialize: function() {
HLItemView.prototype.initialize.call(this);
},
removeShare: function(e) {
var _this = this,
success_callback = function(data) {
Common.feedback(gettext('Success'), 'success', Common.SUCCESS_TIMOUT);
_this.$el.remove();
_this.collection.remove(_this.model, {silent: true});
if (_this.collection.length == 0) {
$('#repos-shared-to-me table').hide();
$('#repos-shared-to-me .empty-tips').show();
}
};
$.ajax({
url: Common.getUrl({name: 'beshared_repo', repo_id: this.model.get('id')})
+ "?share_type=personal&from=" + encodeURIComponent(this.model.get('owner')),
type: 'DELETE',
beforeSend: Common.prepareCSRFToken,
dataType: 'json',
success: success_callback
});
return false;
},
render: function() {
var obj = this.model.toJSON();
var icon_size = Common.isHiDPI() ? 96 : 24;
var icon_url = this.model.getIconUrl(icon_size);
_.extend(obj, {
'icon_url': icon_url,
'icon_title': this.model.getIconTitle()
});
this.$el.html(this.template(obj));
return this;
}
});
return SharedRepoView;
});