Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add memorization of user's position in planning navigation #281

Merged
merged 1 commit into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ gem 'bootstrap4-datetime-picker-rails'
gem 'cocoon', '~> 1.2', '>= 1.2.12' # Dynamic nested forms
gem 'devise', '~> 4.7' # Users login/registration management
gem 'devise_invitable', '~> 2.0.0'
gem 'draper'
gem 'draper' # decorators manager
gem 'dry-transaction'
gem 'httparty' # Http requests
gem 'ice_cube' # Calendar events recurrence (for Missions)
gem 'js_cookie_rails' # Cookie manager for js
gem 'leaflet-rails' # GeoMap generator
gem 'mailjet' # Production mailer API
gem 'pundit' # Authorization management
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
js_cookie_rails (2.2.0)
railties (>= 3.1)
json (2.3.1)
kaminari (1.2.1)
activesupport (>= 4.1.0)
Expand Down Expand Up @@ -597,6 +599,7 @@ DEPENDENCIES
image_processing (~> 1.9, >= 1.9.3)
jbuilder (~> 2.5)
jquery-rails
js_cookie_rails
leaflet-rails
letter_opener
listen (>= 3.0.5, < 3.2)
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@
//= require thredded
//= require thredded-custom
//= require flash_messages_on_xhr
//= require js.cookie
4 changes: 4 additions & 0 deletions app/assets/javascripts/fullCalendar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//= require full_calendar
//= require js.cookie

document.addEventListener('turbolinks:load', () => {
const calendarEl = document.getElementById('calendar');
Expand All @@ -8,6 +9,7 @@ document.addEventListener('turbolinks:load', () => {
themeSystem: 'bootstrap',
height: 'auto',
defaultView: 'timeGridWeek',
defaultDate: Cookies.get('positionInPlanning'), // The displayed date when the calendar is loaded
allDaySlot: false,
firstDay: 1,
locale: 'fr',
Expand Down Expand Up @@ -41,6 +43,8 @@ document.addEventListener('turbolinks:load', () => {
return weekTypes[weekCountBetweenReferenceAndCurrentHour % 4];
};

Cookies.set('positionInPlanning', info.view.currentStart);

if (info.view.type === 'timeGridWeek') {
const currentStart = new Date(info.view.currentStart);
document.getElementsByClassName('fc-center')[0].firstChild.textContent += ` ${weekType(currentStart)}`;
Expand Down