2015-03-07 07:56:10 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
2015-04-03 04:15:41 +00:00
|
|
|
'common'
|
|
|
|
], function($, _, Backbone, Common) {
|
2015-03-07 07:56:10 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var OrganizationRepoView = Backbone.View.extend({
|
|
|
|
tagName: 'tr',
|
|
|
|
|
2015-04-11 07:14:56 +00:00
|
|
|
template: _.template($('#organization-repo-tmpl').html()),
|
2015-03-07 07:56:10 +00:00
|
|
|
|
|
|
|
initialize: function() {
|
|
|
|
},
|
|
|
|
|
2015-04-21 12:18:24 +00:00
|
|
|
render: function() {
|
|
|
|
this.$el.html(this.template(this.model.toJSON()));
|
|
|
|
return this;
|
|
|
|
},
|
2015-03-07 07:56:10 +00:00
|
|
|
|
2015-04-21 12:18:24 +00:00
|
|
|
events: {
|
|
|
|
'mouseenter': 'highlight',
|
|
|
|
'mouseleave': 'rmHighlight',
|
|
|
|
'click .cancel-share': 'removeShare'
|
2015-03-07 07:56:10 +00:00
|
|
|
},
|
|
|
|
|
2015-04-21 12:18:24 +00:00
|
|
|
highlight: function() {
|
|
|
|
this.$el.addClass('hl').find('.op-icon').removeClass('vh');
|
2015-03-07 07:56:10 +00:00
|
|
|
},
|
|
|
|
|
2015-04-21 12:18:24 +00:00
|
|
|
rmHighlight: function() {
|
|
|
|
this.$el.removeClass('hl').find('.op-icon').addClass('vh');
|
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');
|
2015-10-19 07:04:37 +00:00
|
|
|
$.ajax({
|
|
|
|
url: Common.getUrl({
|
2015-04-22 03:02:07 +00:00
|
|
|
name: 'ajax_unset_inner_pub_repo',
|
2015-04-21 12:18:24 +00:00
|
|
|
repo_id: this.model.get('id')
|
|
|
|
}),
|
2015-10-19 07:04:37 +00:00
|
|
|
type: 'POST',
|
2015-04-21 12:18:24 +00:00
|
|
|
data: {
|
|
|
|
'permission': this.model.get('permission')
|
|
|
|
},
|
2015-10-19 07:04:37 +00:00
|
|
|
beforeSend: Common.prepareCSRFToken,
|
|
|
|
dataType: 'json',
|
|
|
|
success: function () {
|
2015-04-21 12:18:24 +00:00
|
|
|
el.remove();
|
2015-04-22 07:57:53 +00:00
|
|
|
var msg = gettext('Successfully unshared {placeholder}').replace('{placeholder}', '<span class="op-target">' + Common.HTMLescape(lib_name) + '</span>');
|
|
|
|
Common.feedback(msg, 'success', Common.SUCCESS_TIMOUT);
|
2015-04-21 12:18:24 +00:00
|
|
|
},
|
2015-10-19 07:04:37 +00:00
|
|
|
error: function(xhr) {
|
2015-04-22 07:57:53 +00:00
|
|
|
Common.ajaxErrorHandler(xhr);
|
|
|
|
}
|
2015-04-21 12:18:24 +00:00
|
|
|
});
|
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;
|
|
|
|
});
|