[issue #347] Fixed bugs. Some changes.

This commit is contained in:
George Vinogradov 2012-04-16 23:22:08 +04:00
parent a68d4a2926
commit 871c8ed1f4
6 changed files with 51 additions and 4 deletions

View File

@ -14,11 +14,16 @@ Rosa.Models.Collaborator = Backbone.Model.extend({
},
changeRole: function(r) {
var self = this;
this._prevState = this.get('role');
this.save({role: r},
{wait: true,
success: function(model, response) {
self.trigger('sync_success');
},
error: function(model, response) {
model.set({role: model._prevState});
self.trigger('sync_failed');
}
});
return this;

View File

@ -55,6 +55,8 @@ Rosa.Views.AddCollaboratorView = Backbone.View.extend({
_.each( items, function( item ) {
self.addOne( ul, item );
});
var factor = (items.length > 10) ? 10 : items.length;
ul.height(ul.children('li').first() * factor);
}
},

View File

@ -1,6 +1,7 @@
Rosa.Views.CollaboratorView = Backbone.View.extend({
template: JST['backbone/templates/collaborators/collaborator'],
tagName: 'tr',
className: 'regular',
events: {
'change input[type="radio"]': 'changeRole',
@ -11,6 +12,8 @@ Rosa.Views.CollaboratorView = Backbone.View.extend({
this.$el.attr('id', 'admin-table-members-row' + this.options.model.get('id') + this.options.model.get('actor_type'));
this.model.on('change', this.render, this);
this.model.on('destroy', this.hide, this);
this.model.on('sync_failed', this.syncError, this);
this.model.on('sync_success', this.syncSuccess, this);
},
render: function() {
@ -33,5 +36,33 @@ Rosa.Views.CollaboratorView = Backbone.View.extend({
hide: function() {
this.remove();
},
syncError: function() {
var self = this;
this.$el.addClass('sync_error');
this.$('td').animate({
'background-color': '#FFFFFF'
}, {
duration: 1500,
easing: 'easeInCirc',
complete: function() {
self.$el.removeClass('sync_error');
}
});
},
syncSuccess: function() {
var self = this;
this.$el.addClass('sync_success');
this.$('td').animate({
'background-color': '#FFFFFF'
}, {
duration: 1500,
easing: 'easeInCirc',
complete: function() {
self.$el.removeClass('sync_success');
}
});
}
});

View File

@ -771,10 +771,19 @@ div.tos_sidebar ul li a {
text-decoration: none;
}
table.tablesorter tbody tr.removed td {
table.tablesorter tbody tr.regular td {
background-color: #FFFFFF;
}
table.tablesorter tbody tr.removed td,
table.tablesorter tbody tr.sync_error td {
background-color: #FFECEC;
}
table.tablesorter tbody tr.sync_success td {
background-color: #E0ECFF;
}
ul.ui-autocomplete li.item {
/* padding: 1px 0; */
}
@ -811,7 +820,7 @@ ul.ui-autocomplete li.item div.collaborator div.name {
}
ul.ui-autocomplete.has_results {
height: 200px;
/* height: 200px; */
overflow: auto;
}

View File

@ -83,7 +83,7 @@ class Collaborator
def actor_name
if @actor.present?
@actor.instance_of?(User) ? "#{@actor.uname} (#{@actor.name})" : @actor.uname
@actor.instance_of?(User) ? "#{@actor.uname}#{ @actor.try(:name) and !@actor.name.empty? ? " (#{@actor.name})" : ''}" : @actor.uname
else
nil
end

View File

@ -12,4 +12,4 @@
= link_to t("layout.projects.sections"), sections_project_path(@project)
- if can? :manage_collaborators, @project
%li{:class => (act == :edit && contr == :collaborators) ? 'active' : ''}
= link_to t("layout.projects.edit_collaborators"), edit_project_collaborators_path(@project)
= link_to t("layout.projects.edit_collaborators"), project_collaborators_path(@project)