2015-07-24 03:37:57 +00:00
|
|
|
define([
|
|
|
|
'jquery',
|
|
|
|
'underscore',
|
|
|
|
'backbone',
|
2015-07-28 11:54:57 +00:00
|
|
|
'common'
|
|
|
|
], function($, _, Backbone, Common) {
|
2015-07-24 03:37:57 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var DetailsView = Backbone.View.extend({
|
|
|
|
|
|
|
|
id: 'ls-ch',
|
|
|
|
|
|
|
|
template: _.template($('#details-popup-tmpl').html()),
|
2015-07-28 11:54:57 +00:00
|
|
|
detailItemTemplate: _.template($('#detail-item-tmpl').html()),
|
2015-07-24 03:37:57 +00:00
|
|
|
|
|
|
|
initialize: function (options) {
|
|
|
|
this.repo_id = options['repo_id'];
|
|
|
|
this.cmmt_id = options['cmmt_id'];
|
|
|
|
|
|
|
|
this.$el.html(this.template()).modal({autoResize:true});
|
|
|
|
$('#simplemodal-container').css({'width':'auto', 'height':'auto'});
|
|
|
|
|
|
|
|
this.getDetails();
|
|
|
|
},
|
|
|
|
|
|
|
|
getDetails: function () {
|
2015-07-29 12:18:28 +00:00
|
|
|
var _this = this;
|
2015-07-24 03:37:57 +00:00
|
|
|
|
|
|
|
Common.ajaxGet({
|
2015-07-29 12:18:28 +00:00
|
|
|
get_url: Common.getUrl({
|
|
|
|
name:'get_history_changes',
|
|
|
|
repo_id: this.repo_id
|
|
|
|
}),
|
|
|
|
data: {'commit_id': this.cmmt_id},
|
2015-07-24 03:37:57 +00:00
|
|
|
after_op_success: function (data) {
|
|
|
|
_this.$('.loading-tip').hide();
|
|
|
|
_this.$('.commit-time').html(data['date_time']);
|
|
|
|
|
2015-07-29 12:18:28 +00:00
|
|
|
var showDetails = function(params) {
|
|
|
|
_this.$el.append(_this.detailItemTemplate({
|
|
|
|
"details_title": params.title,
|
|
|
|
"details": params.content
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
if (data['new'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("New files"),
|
|
|
|
'content': data['new']
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (data['removed'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("Deleted files"),
|
|
|
|
'content': data['removed']
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (data['renamed'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("Renamed or Moved files"),
|
|
|
|
'content': data['renamed']
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (data['modified'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("Modified files"),
|
|
|
|
'content': data['modified']
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (data['newdir'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("New directories"),
|
|
|
|
'content': data['newdir']
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (data['deldir'].length > 0) {
|
|
|
|
showDetails({
|
|
|
|
'title': gettext("Deleted directories"),
|
|
|
|
'content': data['deldir']
|
|
|
|
});
|
|
|
|
}
|
2015-07-24 03:37:57 +00:00
|
|
|
|
2015-07-29 12:18:28 +00:00
|
|
|
// most of the time, no 'cmt_desc'
|
|
|
|
if (data['cmt_desc']) {
|
|
|
|
_this.$el.append('<p>' + Common.HTMLescape(data['cmt_desc']) + '</p>');
|
2015-07-24 03:37:57 +00:00
|
|
|
}
|
2015-07-29 12:18:28 +00:00
|
|
|
|
2015-07-24 03:37:57 +00:00
|
|
|
$(window).resize();
|
|
|
|
},
|
2015-07-29 12:18:28 +00:00
|
|
|
after_op_error: function(xhr) {
|
|
|
|
var err_msg;
|
|
|
|
if (xhr.responseText) {
|
|
|
|
err_msg = $.parseJSON(xhr.responseText).error;
|
|
|
|
} else {
|
|
|
|
err_msg = gettext("Failed. Please check the network.");
|
|
|
|
}
|
|
|
|
_this.$el.html('<p class="error">' + err_msg + '</p>');
|
2015-07-28 11:54:57 +00:00
|
|
|
setTimeout(function() { $.modal.close(); }, 2500);
|
2015-07-24 03:37:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return DetailsView;
|
|
|
|
})
|