Skip to content

Commit

Permalink
tour di onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
madbob committed Nov 1, 2023
1 parent 7cc357f commit 1153a51
Show file tree
Hide file tree
Showing 15 changed files with 212 additions and 20 deletions.
8 changes: 6 additions & 2 deletions code/app/Console/Commands/FixDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ public function handle()
Artisan::call('db:seed', ['--force' => true, '--class' => 'MovementTypesSeeder']);
Artisan::call('db:seed', ['--force' => true, '--class' => 'ModifierTypesSeeder']);

User::update(['tour' => false]);

foreach(Gas::all() as $gas) {
$registrations_info = $gas->public_registrations;
$registrations_info['manual'] = false;
$gas->setConfig('public_registrations', $registrations_info);
if (isset($registrations_info['manual']) == false) {
$registrations_info['manual'] = false;
$gas->setConfig('public_registrations', $registrations_info);
}
}
}
}
101 changes: 101 additions & 0 deletions code/app/Http/Controllers/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,107 @@ public function picture($id)
});
}

public function startTour(Request $request)
{
$user = $request->user();
$gas = $user->gas;

$steps = [];

/*
Gli identificativi dei pulsanti devono corrispondere a quelli
assegnati in MenuServiceProvider
*/

$steps[] = (object) [
'title' => _i('Benvenuto in GASdotto!'),
'content' => _i("Qui ti diamo qualche suggerimento per utilizzare questo nuovo sito"),
];

$steps[] = (object) [
'title' => _i('I tuoi dati'),
'content' => _i("Cliccando qui accedi al pannello dei tuoi dati personali, da cui poi cambiare il tuo indirizzo email, la tua password di accesso e molto altro."),
'target' => '#menu_profile',
];

if ($user->can('users.admin', $gas)) {
$steps[] = (object) [
'title' => _i('Gli altri utenti'),
'content' => _i("Da qui consulti l'elenco degli utenti, ne modifichi i parametri, e ne puoi invitare di nuovi (o li puoi importare da un file CSV)."),
'target' => '#menu_users',
];
}

if ($user->can('supplier.add', $gas) || $user->can('supplier.modify', null)) {
$steps[] = (object) [
'title' => _i('I fornitori e i listini'),
'content' => _i("Cliccando qui puoi consultare l'elenco dei fornitori, crearne di nuovi, modificarli, e per ciascuno caricare o modificare il relativo listino."),
'target' => '#menu_suppliers',
];
}

if ($user->can('supplier.orders', null) || $user->can('supplier.shippings', null)) {
$steps[] = (object) [
'title' => _i('Gli ordini'),
'content' => _i("Da questa pagina accedi all'elenco degli ordini, da cui crearli e modificarli. Cliccando su ciascun ordine puoi trovare anche la tab 'Consegne' per tenere traccia delle consegne e generare i movimenti contabili di pagamento."),
'target' => '#menu_orders',
];
}

if ($user->can('supplier.book', null)) {
$steps[] = (object) [
'title' => _i('Le prenotazioni'),
'content' => _i("Qui trovi l'elenco degli ordini attualmente in corso, e puoi sottoporre le tue prenotazioni: clicca su ciascun ordine, e specifica la quantità desiderata per ogni prodotto."),
'target' => '#menu_bookings',
];
}

if ($user->can('movements.view', $gas) || $user->can('movements.admin', $gas)) {
$steps[] = (object) [
'title' => _i('La contabilità'),
'content' => _i("In questa pagina trovi tutti i movimenti contabili ed i relativi strumenti di amministrazione."),
'target' => '#menu_accouting',
];
}

if ($user->can('gas.config', $gas)) {
$steps[] = (object) [
'title' => _i('Tutte le configurazioni'),
'content' => _i("Cliccando qui trovi una moltitudine di parametri per personalizare il comportamento di questa istanza GASdotto."),
'target' => '#menu_config',
];
}

$steps[] = (object) [
'title' => _i('Help in linea'),
'content' => _i("Aprendo i diversi pannelli di GASdotto, accanto a molti parametri trovi una icona blu: passandoci sopra il cursore del mouse ti viene mostrato un breve testo descrittivo che te ne illustra i dettagli.") . '<br><img class="img-fluid p-2 mt-2 bg-dark" src="' . asset('images/inline_help.gif') . '">',
];

if ($user->can('users.admin', $gas)) {
$steps[] = (object) [
'title' => _i('Dubbi?'),
'content' => _i("Se hai un dubbio sull'utilizzo di GASdotto, o una segnalazione, o una richiesta, cliccando qui trovi i nostri contatti."),
'target' => '#menu_help'
];
}

return response()->json([
'dialogZ' => 2000,
'nextLabel' => _i('>>'),
'prevLabel' => _i('<<'),
'finishLabel' => _i('Finito'),
'steps' => $steps,
]);
}

public function finishTour(Request $request)
{
$user = $request->user();
$user->tour = true;
$user->save();
return $this->successResponse();
}

private function testInternalFunctionsAccess($requester, $target, $type)
{
$admin_editable = $requester->can('users.admin', $target->gas);
Expand Down
52 changes: 40 additions & 12 deletions code/app/Providers/MenuServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
Da qui viene generato il menu primario, in funzione dei permessi abilitati
per l'utente.
Ad alcune voci viene assegnato un ID, che viene usato per generare il tour
di onboarding in UsersController::startTour()
*/

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
Expand All @@ -10,42 +17,63 @@ class MenuServiceProvider extends ServiceProvider
{
private function commonItems($user, &$menu)
{
$menu['<i class="bi-house"></i> ' . _i('Home')] = route('dashboard');
$menu['<i class="bi-gear"></i> ' . $user->printableName()] = route('profile');
$menu['<i class="bi-house"></i> ' . _i('Home')] = [
'url' => route('dashboard'),
];

$menu['<i class="bi-gear"></i> ' . $user->printableName()] = [
'url' => route('profile'),
'attributes' => ['id' => 'menu_profile'],
];
}

private function accessUsers($user, $gas, &$menu)
{
if ($user->can('users.admin', $gas) || $user->can('users.view', $gas)) {
$menu['<i class="bi-people"></i> ' . _i('Utenti')] = route('users.index');
$menu['<i class="bi-people"></i> ' . _i('Utenti')] = [
'url' => route('users.index'),
'attributes' => ['id' => 'menu_users'],
];
}
}

private function accessSuppliers($user, $gas, &$menu)
{
if ($user->can('supplier.view', $gas) || $user->can('supplier.add', $gas) || $user->can('supplier.modify', null)) {
$menu['<i class="bi-tags"></i> ' . _i('Fornitori')] = route('suppliers.index');
$menu['<i class="bi-tags"></i> ' . _i('Fornitori')] = [
'url' => route('suppliers.index'),
'attributes' => ['id' => 'menu_suppliers'],
];
}
}

private function accessOrders($user, $gas, &$menu)
{
if ($user->can('supplier.orders', null) || $user->can('supplier.shippings', null) || $user->can('order.view', $gas)) {
$menu['<i class="bi-list-task"></i> ' . _i('Ordini')] = route('orders.index');
$menu['<i class="bi-list-task"></i> ' . _i('Ordini')] = [
'url' => route('orders.index'),
'attributes' => ['id' => 'menu_orders'],
];
}
}

private function accessBookings($user, $gas, &$menu)
{
if ($user->can('supplier.book', null)) {
$menu['<i class="bi-bookmark"></i> ' . _i('Prenotazioni')] = route('bookings.index');
$menu['<i class="bi-bookmark"></i> ' . _i('Prenotazioni')] = [
'url' => route('bookings.index'),
'attributes' => ['id' => 'menu_bookings'],
];
}
}

private function accessAccounting($user, $gas, &$menu)
{
if ($user->can('movements.view', $gas) || $user->can('movements.admin', $gas)) {
$menu['<i class="bi-piggy-bank"></i> ' . _i('Contabilità')] = route('movements.index');
$menu['<i class="bi-piggy-bank"></i> ' . _i('Contabilità')] = [
'url' => route('movements.index'),
'attributes' => ['id' => 'menu_accouting'],
];
}
}

Expand All @@ -64,7 +92,10 @@ private function accessNotifications($user, $gas, &$menu)
private function accessConfigs($user, $gas, &$menu)
{
if ($user->can('gas.config', $gas)) {
$menu['<bi class="bi-tools"></i> ' . _i('Configurazioni')] = route('gas.edit', $gas->id);
$menu['<bi class="bi-tools"></i> ' . _i('Configurazioni')] = [
'url' => route('gas.edit', $gas->id),
'attributes' => ['id' => 'menu_config'],
];
}
}

Expand Down Expand Up @@ -102,6 +133,7 @@ private function endMenu($view)
{
$view->with('end_menu', [
'<i class="bi-megaphone-fill"></i>' => ['attributes' => [
'id' => 'menu_help',
'data-bs-toggle' => "modal",
'data-bs-target' => "#feedback-modal",
]],
Expand All @@ -125,8 +157,4 @@ public function boot()
}
});
}

public function register()
{
}
}
28 changes: 28 additions & 0 deletions code/database/migrations/2023_11_01_171441_users_tour.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table) {
$table->boolean('tour')->default(false);
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('tour');
});
}
};
1 change: 1 addition & 0 deletions code/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"@dashboardcode/bsmultiselect": "^1.1.18",
"@sjmc11/tourguidejs": "^0.0.10",
"acorn": "^8.10.0",
"blueimp-file-upload": "^10.32.0",
"bootstrap": "^5.3.2",
Expand Down
2 changes: 1 addition & 1 deletion code/public/css/gasdotto.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/css/gasdotto.css.map

Large diffs are not rendered by default.

Binary file added code/public/images/inline_help.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion code/public/js/gasdotto.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion code/public/js/gasdotto.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions code/public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/gasdotto.js": "/js/gasdotto.js?id=f4f98db84de1206fa15580a42f305bda",
"/css/gasdotto.css": "/css/gasdotto.css?id=fb5adf37fb0db9ce1e72b40389fc1081"
"/js/gasdotto.js": "/js/gasdotto.js?id=af13ef8a3247b36aa81ce3a25a2ad70e",
"/css/gasdotto.css": "/css/gasdotto.css?id=7f8643d8dc2a8ff54e8a5ac03dcfd343"
}
22 changes: 22 additions & 0 deletions code/resources/assets/js/gasdotto.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require('jquery-ui/ui/widgets/autocomplete');
require('jquery-ui-touch-punch');
require('blueimp-file-upload');
import Cookies from 'js-cookie';
import { TourGuideClient } from "@sjmc11/tourguidejs";

require('./aggregation');
require('./jquery.dynamictree');
Expand Down Expand Up @@ -816,4 +817,25 @@ $(document).ready(function() {
});

Bookings.initOnce();

let needs_tour = $('meta[name=needs_tour]').attr('content');
if (needs_tour == '1') {
utils.postAjax({
method: 'GET',
url: 'users/tour/start',
dataType: 'JSON',
success: (data) => {
const tg = new TourGuideClient(data);

tg.onFinish(() => {
utils.postAjax({
method: 'GET',
url: 'users/tour/finish',
});
});

tg.start();
}
});
}
});
5 changes: 5 additions & 0 deletions code/resources/assets/sass/gasdotto.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ $s2bs5-border-color: $border-color;

@import '~jquery-ui/themes/base/all.css';
@import '~chartist/dist/index.css';
@import "~@sjmc11/tourguidejs/src/scss/tour.scss";

html, body {
min-height: 100%;
Expand Down Expand Up @@ -679,6 +680,10 @@ i[class^='bi-hidden-'] {
}
}

.tg-backdrop {
z-index: 1999;
}

@include media-breakpoint-down(lg) {
.btn {
padding: 0.375rem 0.35rem;
Expand Down
1 change: 1 addition & 0 deletions code/resources/views/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<meta name="csrf-token" content="{{ csrf_token() }}"/>
<meta name="absolute_url" content="{{ route('root') }}"/>
<meta name="current_currency" content="{{ currentAbsoluteGas()->currency }}"/>
<meta name="needs_tour" content="{{ $currentuser->tour ? '0' : '1' }}"/>
</head>
<body>
<div id="preloader">
Expand Down
2 changes: 2 additions & 0 deletions code/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
Route::get('users/{id}/bookings', 'UsersController@bookings')->name('users.bookings');
Route::get('users/{id}/stats', 'UsersController@statistics')->name('users.stats');
Route::get('users/{id}/accounting', 'UsersController@accounting')->name('users.accounting');
Route::get('users/tour/start', 'UsersController@startTour')->name('users.tour.start');
Route::get('users/tour/finish', 'UsersController@finishTour')->name('users.tour.finish');

Route::get('friends/{id}/header', 'FriendsController@objhead')->name('friends.objhead');

Expand Down

0 comments on commit 1153a51

Please sign in to comment.