1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-29 08:27:55 +00:00
seahub/static/scripts/app/views/organization-repo.js

65 lines
1.9 KiB
JavaScript
Raw Normal View History

2015-03-07 07:56:10 +00:00
define([
'jquery',
'underscore',
'backbone',
2016-03-22 03:47:52 +00:00
'common',
'app/views/widgets/hl-item-view'
], function($, _, Backbone, Common, HLItemView) {
2015-03-07 07:56:10 +00:00
'use strict';
2016-03-22 03:47:52 +00:00
var OrganizationRepoView = HLItemView.extend({
2015-03-07 07:56:10 +00:00
tagName: 'tr',
2015-04-11 07:14:56 +00:00
template: _.template($('#organization-repo-tmpl').html()),
mobileTemplate: _.template($('#organization-repo-mobile-tmpl').html()),
2015-03-07 07:56:10 +00:00
initialize: function() {
2016-03-22 03:47:52 +00:00
HLItemView.prototype.initialize.call(this);
2015-03-07 07:56:10 +00:00
},
2015-04-21 12:18:24 +00:00
render: function() {
2016-03-11 04:10:55 +00:00
var obj = this.model.toJSON();
2017-07-31 09:30:43 +00:00
var icon_size = Common.isHiDPI() ? 48 : 24;
2016-03-11 04:10:55 +00:00
var icon_url = this.model.getIconUrl(icon_size);
var tmpl = $(window).width() >= 768 ? this.template : this.mobileTemplate;
_.extend(obj, {
'icon_url': icon_url,
'icon_title': this.model.getIconTitle()
});
this.$el.html(tmpl(obj));
2015-04-21 12:18:24 +00:00
return this;
},
2015-03-07 07:56:10 +00:00
2015-04-21 12:18:24 +00:00
events: {
'click .cancel-share': 'removeShare'
2015-03-07 07:56:10 +00:00
},
2015-04-22 07:57:53 +00:00
removeShare: function() {
2015-04-21 12:18:24 +00:00
var el = this.$el;
2015-04-22 07:57:53 +00:00
var lib_name = this.model.get('name');
$.ajax({
url: Common.getUrl({
name: 'shared_repos',
2015-04-21 12:18:24 +00:00
repo_id: this.model.get('id')
}) + "?share_type=public",
type: 'DELETE',
beforeSend: Common.prepareCSRFToken,
dataType: 'json',
success: function () {
2015-04-21 12:18:24 +00:00
el.remove();
2016-07-04 07:31:55 +00:00
var msg = gettext('Successfully unshared 1 item.');
2015-04-22 07:57:53 +00:00
Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT);
2015-04-21 12:18:24 +00:00
},
error: function(xhr) {
2015-04-22 07:57:53 +00:00
Common.ajaxErrorHandler(xhr);
}
2015-04-21 12:18:24 +00:00
});
2016-04-12 03:17:27 +00:00
return false;
2015-03-07 07:56:10 +00:00
}
2015-04-21 12:18:24 +00:00
2015-03-07 07:56:10 +00:00
});
return OrganizationRepoView;
});