mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-03 03:00:14 +00:00
Built a new routine for intro tours.
This commit is contained in:
@@ -67,10 +67,16 @@ class Controller extends BaseController
|
||||
|
||||
// get shown-intro-preference:
|
||||
if (auth()->check()) {
|
||||
$key = 'shown_demo_' . Route::currentRouteName();
|
||||
$route = Route::currentRouteName();
|
||||
$key = 'shown_demo_' . $route;
|
||||
$config = config('intro.' . $route);
|
||||
$shownDemo = Preferences::get($key, false)->data;
|
||||
if (is_null($config) || (is_array($config) && count($config) === 0)) {
|
||||
// no demo when no data for demo.
|
||||
$shownDemo = true;
|
||||
}
|
||||
View::share('shownDemo', $shownDemo);
|
||||
View::share('current_route_name', Route::currentRouteName());
|
||||
View::share('current_route_name', $route);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
67
app/Http/Controllers/Json/IntroController.php
Normal file
67
app/Http/Controllers/Json/IntroController.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* IntroController.php
|
||||
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
||||
* This software may be modified and distributed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International License.
|
||||
*
|
||||
* See the LICENSE file for details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Json;
|
||||
|
||||
use Preferences;
|
||||
use Response;
|
||||
|
||||
/**
|
||||
* Class IntroController
|
||||
*
|
||||
* @package FireflyIII\Http\Controllers\Json
|
||||
*/
|
||||
class IntroController
|
||||
{
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function getIntroSteps(string $route)
|
||||
{
|
||||
$elements = config(sprintf('intro.%s', $route));
|
||||
$steps = [];
|
||||
if (is_array($elements) && count($elements) > 0) {
|
||||
foreach ($elements as $key => $options) {
|
||||
$currentStep = $options;
|
||||
|
||||
// point to HTML element when not an intro or outro:
|
||||
if (!in_array($key, ['intro', 'outro'])) {
|
||||
$currentStep['element'] = '#' . $key;
|
||||
}
|
||||
|
||||
// get the text:
|
||||
$currentStep['intro'] = trans('intro.' . $route . '_' . $key);
|
||||
|
||||
// save in array:
|
||||
$steps[] = $currentStep;
|
||||
}
|
||||
}
|
||||
|
||||
return Response::json($steps);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $route
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
public function postFinished(string $route)
|
||||
{
|
||||
$key = 'shown_demo_' . $route;
|
||||
Preferences::set($key, true);
|
||||
|
||||
return Response::json(['result' => sprintf('Reported demo watched for route "%s".', $route)]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user