diff --git a/app/assets/javascripts/backbone/models/collaborator.js b/app/assets/javascripts/backbone/models/collaborator.js index 6b6f77720..f23263b7c 100644 --- a/app/assets/javascripts/backbone/models/collaborator.js +++ b/app/assets/javascripts/backbone/models/collaborator.js @@ -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; diff --git a/app/assets/javascripts/backbone/views/add_collaborator_view.js b/app/assets/javascripts/backbone/views/add_collaborator_view.js index dcb771b81..6745ceb42 100644 --- a/app/assets/javascripts/backbone/views/add_collaborator_view.js +++ b/app/assets/javascripts/backbone/views/add_collaborator_view.js @@ -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); } }, diff --git a/app/assets/javascripts/backbone/views/collaborator_view.js b/app/assets/javascripts/backbone/views/collaborator_view.js index 1b2b092c2..08760694a 100644 --- a/app/assets/javascripts/backbone/views/collaborator_view.js +++ b/app/assets/javascripts/backbone/views/collaborator_view.js @@ -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'); + } + }); } }); diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index e864f63f1..ea6b5294c 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -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; } diff --git a/app/models/collaborator.rb b/app/models/collaborator.rb index c27e30883..83eda9794 100644 --- a/app/models/collaborator.rb +++ b/app/models/collaborator.rb @@ -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 diff --git a/app/views/projects/_sidebar.html.haml b/app/views/projects/_sidebar.html.haml index 48e3f03d8..a0ce94f88 100644 --- a/app/views/projects/_sidebar.html.haml +++ b/app/views/projects/_sidebar.html.haml @@ -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)