diff --git a/app/assets/javascripts/activities/index.js b/app/assets/javascripts/activities/index.js new file mode 100644 index 000000000..78471e4e6 --- /dev/null +++ b/app/assets/javascripts/activities/index.js @@ -0,0 +1,19 @@ +'use strict'; + +(function() { + function initActivitiesButton() { + $(document).ready(function() { + $(document).find('.btn-more-activities') + .on('ajax:success', function(e, data) { + $(data.html).insertAfter($('#list-activities li').last()); + if(data.more_url) { + $(this).attr('href', data.more_url); + } else { + $(this).remove(); + } + }); + }); + } + initActivitiesButton(); + +})(); diff --git a/app/assets/javascripts/navigation.js b/app/assets/javascripts/navigation.js index 4e731df63..bce30d4ad 100644 --- a/app/assets/javascripts/navigation.js +++ b/app/assets/javascripts/navigation.js @@ -104,57 +104,10 @@ }); } - function initActivitiesButton() { - $(document.body).ready(function() { - // Activity feed modal in main navigation menu - var activityModal = $('#activity-modal'); - var activityModalBody = activityModal.find('.modal-body'); - var initMoreBtn = function() { - activityModalBody.find('.btn-more-activities') - .on('ajax:success', function(e, data) { - $(data.html).insertBefore($(this).parents('li')); - if(data.more_url) { - $(this).attr('href', data.more_url); - } else { - $(this).remove(); - } - }); - }; - - notificationAlertClose(); - - $('#main-menu .btn-activity') - .on('ajax:before', function() { - activityModal.modal('show'); - }) - .on('ajax:success', function(e, data) { - activityModalBody.html(data.html); - initMoreBtn(); - }); - - activityModal.on('hidden.bs.modal', function() { - activityModalBody.html(''); - }); - }); - - $(document).ajaxComplete(function() { - notificationAlertClose(); - }); - - function notificationAlertClose() { - $('#notifications .alert').on('closed.bs.alert', function() { - $('#content-wrapper') - .addClass('alert-hidden') - .removeClass('alert-shown'); - }); - } - } - // init loadDropdownNotifications(); loadUnseenNotificationsNumber(); toggleNotificationBellPosition(); focusSearchInput(); initGlobalSwitchForm(); - initActivitiesButton(); })(); diff --git a/app/assets/stylesheets/themes/scinote.scss b/app/assets/stylesheets/themes/scinote.scss index fe368ab50..1d6252158 100644 --- a/app/assets/stylesheets/themes/scinote.scss +++ b/app/assets/stylesheets/themes/scinote.scss @@ -4,7 +4,6 @@ /** Layout **/ body, -#activity-modal, #main-nav, #notifications, #notifications .alert { @@ -1126,11 +1125,8 @@ ul.double-line > li { left: 8px; } -#activity-modal { - .modal-body { - background-color: $color-concrete; - color: $color-mine-shaft; - } +#global-activity-page { + margin-top: 50px; } /** Activity list resembling Bootstrap wells */ diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index 1563bf73f..fe43522a3 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -2,15 +2,17 @@ class ActivitiesController < ApplicationController include ActivityHelper def index + @vars = local_vars respond_to do |format| format.json do render json: { more_url: local_vars.fetch(:more_activities_url), html: render_to_string( - partial: 'index.html.erb', locals: local_vars + partial: 'list.html.erb', locals: @vars ) } end + format.html end end diff --git a/app/views/activities/_activity.html.erb b/app/views/activities/_activity.html.erb index 0e1af449a..e4865539a 100644 --- a/app/views/activities/_activity.html.erb +++ b/app/views/activities/_activity.html.erb @@ -1,6 +1,6 @@
  • - <%= l activity.created_at, format: '%H:%M' %> + <%= l activity.created_at, format: :full %> <%= activity_truncate(activity.message) %> diff --git a/app/views/activities/_index.html.erb b/app/views/activities/_index.html.erb deleted file mode 100644 index fd119ff3a..000000000 --- a/app/views/activities/_index.html.erb +++ /dev/null @@ -1,17 +0,0 @@ - diff --git a/app/views/activities/_list.html.erb b/app/views/activities/_list.html.erb index 2a8740869..c29b1b43c 100644 --- a/app/views/activities/_list.html.erb +++ b/app/views/activities/_list.html.erb @@ -1,26 +1,3 @@ -<% if activities.first_page? %> - <% if activities.first.created_at.to_date == Date.today %> -
  • - - <%=t "activities.index.today" %> - -
  • - <% else %> -
  • - - <%= activities.first.created_at.strftime('%d.%m.%Y') %> - -
  • - <% end %> -<% end %> <% activities.each_with_index do |activity, index| %> - <% prevDate = calculate_previous_date(activities, index, previous_activity_created_at) %> - <% if activity.created_at.to_date < prevDate %> -
  • - - <%= activity.created_at.strftime('%d.%m.%Y') %> - -
  • - <% end %> - <%= render 'activities/activity.html.erb', activity: activity %> + <%= render 'activity.html.erb', activity: activity %> <% end %> diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb new file mode 100644 index 000000000..1db715a76 --- /dev/null +++ b/app/views/activities/index.html.erb @@ -0,0 +1,25 @@ +<% provide :head_title, t('nav.label.activities') %> + +
    +
    + + <% if @vars[:more_activities_url].present? && @vars[:page] == 1 %> + + <% end %> +
    +
    + +<%= javascript_include_tag 'activities/index.js' %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ec1165f14..f9c2ae09b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -29,22 +29,6 @@ - - - <%= render "shared/about_modal" %> diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb index b9a35a257..b1caa120d 100644 --- a/app/views/shared/_navigation.html.erb +++ b/app/views/shared/_navigation.html.erb @@ -73,7 +73,7 @@ <% end %>
  • - + <%= t('nav.label.activities') %> diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 855f7bb2e..a4d9c0cd0 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -82,6 +82,7 @@ Rails.application.config.assets.precompile += %w(repositories/repository_datatable.js) Rails.application.config.assets.precompile += %w(repositories/my_module_repository.js) +Rails.application.config.assets.precompile += %w(activities/index.js) # Libraries needed for Handsontable formulas Rails.application.config.assets.precompile += %w(lodash.js)