Skip to content

Firefly III: a personal finances manager

Fix remember tour (hack)

James Coledc4350341551
diff --git a/resources/assets/v3/js/boot/bootstrap.js b/resources/assets/v3/js/boot/bootstrap.js
index 208f95729f..43241c097f 100644
--- a/resources/assets/v3/js/boot/bootstrap.js
+++ b/resources/assets/v3/js/boot/bootstrap.js
@@ -47,7 +47,7 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
// always grab the preference "marker" from Firefly III.
getFreshVariable('lastActivity').then((serverValue) => {
- if(null === serverValue) {
+ if (null === serverValue) {
console.log('Server value is null in getFreshVariable.');
throw new Error('401 in getFreshVariable.');
}
@@ -82,18 +82,16 @@ getFreshVariable('lastActivity').then((serverValue) => {
console.log('Bootstrapped!');
// page may have an introduction necessary to be played.
+ if(!showTour) {
+ return;
+ }
const url = '/';
let site = axios.create({baseURL: url, withCredentials: true});
axios.defaults.withCredentials = true;
axios.defaults.baseURL = url;
-
-
-
- site.get(routeStepsUrl).then(function(data) {
- console.log('Done with loading hints.');
+ site.get(routeStepsUrl).then(function (data) {
let hints = data.data;
- console.log(hints);
const tour = new Shepherd.Tour({
useModalOverlay: true,
@@ -102,8 +100,16 @@ getFreshVariable('lastActivity').then((serverValue) => {
scrollTo: true
}
});
- for(let i=0;i<hints.length;i++) {
- if(hints.hasOwnProperty(i)){
+// cancel, complete
+ tour.on('cancel', (eventOptions) => {
+ site.post(routeForFinishedTour);
+ });
+ tour.on('complete', (eventOptions) => {
+ site.post(routeForFinishedTour);
+ });
+
+ for (let i = 0; i < hints.length; i++) {
+ if (hints.hasOwnProperty(i)) {
let hint = hints[i];
let step = {
@@ -118,10 +124,10 @@ getFreshVariable('lastActivity').then((serverValue) => {
}
]
};
- if(hint.hasOwnProperty('element')) {
+ if (hint.hasOwnProperty('element')) {
step.attachTo = {
element: hint.element,
- on: hint.position
+ on: hint.position
};
}
tour.addStep(step);
@@ -135,9 +141,6 @@ getFreshVariable('lastActivity').then((serverValue) => {
});
-
-
-
});
}).catch((error) => {
console.error('Error while bootstrapping: ' + error);
diff --git a/resources/views/layout/v3/session.blade.php b/resources/views/layout/v3/session.blade.php
index 823f6fe2f6..3407f2b4ed 100644
--- a/resources/views/layout/v3/session.blade.php
+++ b/resources/views/layout/v3/session.blade.php
@@ -370,13 +370,18 @@
{{-- introduction --}}
<!-- intro -->
-<script type="text/javascript" nonce="{{ $JS_NONCE }}">
- var routeForTour = "{{ $current_route_name }}";
- var routeStepsUrl = "{{ route('json.intro', [$current_route_name, $objectType ?? '']) }}";
- var routeForFinishedTour = "{{ route('json.intro.finished', [$current_route_name, $objectType ?? '']) }}";
-</script>
@if(!$shownDemo)
-<!-- <script type="text/javascript" src="v1/js/ff/intro/intro.js?v={{ $FF_BUILD_TIME }}" nonce="{{ $JS_NONCE }}"></script> -->
+ <script type="text/javascript" nonce="{{ $JS_NONCE }}">
+ var showTour = true;
+ var routeForTour = "{{ $current_route_name }}";
+ var routeStepsUrl = "{{ route('json.intro', [$current_route_name, $objectType ?? '']) }}";
+ var routeForFinishedTour = "{{ route('json.intro.finished', [$current_route_name, $objectType ?? '']) }}";
+ </script>
+@endif
+@if($shownDemo)
+ <script type="text/javascript" nonce="{{ $JS_NONCE }}">
+ var showTour = false;
+ </script>
@endif
{{-- date range picker, current template, etc. --}}
@@ -396,7 +401,6 @@
<!-- start: previous color mode -->
-
<!-- end: previous color mode -->
<!--begin::Color Mode Toggle (#6010)-->
@@ -488,11 +492,12 @@
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
</form>
-<div class="modal fade" tabindex="-1" role="dialog" id="customDateRangeModal" aria-hidden="true" x-data="dates" x-bind="eventListeners">
+<div class="modal fade" tabindex="-1" role="dialog" id="customDateRangeModal" aria-hidden="true" x-data="dates"
+ x-bind="eventListeners">
<div class="modal-dialog modal-lg">
<form action="{{ route('daterange') }}?redirect=true" method="POST" id="daterange-form">
- <input type="hidden" name="start" value="" id="customStart" />
- <input type="hidden" name="end" value="" id="customEnd" />
+ <input type="hidden" name="start" value="" id="customStart"/>
+ <input type="hidden" name="end" value="" id="customEnd"/>
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">{{ __('firefly.customRange') }}</h4>