shared dashboards

This commit is contained in:
denisdulici
2020-01-07 17:15:00 +03:00
parent dcab115207
commit 2436898f04
33 changed files with 806 additions and 457 deletions

View File

@@ -1,212 +0,0 @@
<template>
<akaunting-modal
:title="title"
:show="display"
@cancel="onCancel"
v-if="display">
<template #modal-body>
<div class="modal-body text-left">
<div class="row">
<div class="col-md-12">
<base-input
v-model="form.name"
:label="text.name"
prepend-icon="fas fa-tag"
:placeholder="text.name"
inputGroupClasses="input-group-merge"
></base-input>
</div>
<!--
<akaunting-radio-group
:name="'enabled'"
:text="text.enabled"
:value="form.enabled"
@change="onEnabled"
:enable="text.yes"
:disable="text.no"
:col="'col-md-12'"
></akaunting-radio-group>
-->
</div>
</div>
</template>
<template #card-footer>
<div class="row">
<div class="col-md-12">
<div class="float-right">
<button type="button" class="btn btn-icon btn-outline-secondary" @click="onCancel">
<span class="btn-inner--icon"><i class="fas fa-times"></i></span>
<span class="btn-inner--text">{{ text.cancel }}</span>
</button>
<button :disabled="form.loading" type="button" class="btn btn-icon btn-success button-submit" @click="onSave">
<div v-if="form.loading" class="aka-loader-frame"><div class="aka-loader"></div></div>
<span v-if="!form.loading" class="btn-inner--icon"><i class="fas fa-save"></i></span>
<span v-if="!form.loading" class="btn-inner--text">{{ text.save }}</span>
</button>
</div>
</div>
</div>
</template>
</akaunting-modal>
</template>
<script>
import AkauntingModal from "./AkauntingModal";
import AkauntingRadioGroup from './forms/AkauntingRadioGroup';
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import Form from './../plugins/form';
import BulkAction from './../plugins/bulk-action';
import NProgressAxios from './../plugins/nprogress-axios';
export default {
name: 'akaunting-dashobard',
components: {
AkauntingModal,
AkauntingRadioGroup
},
props: {
show: Boolean,
title: {
type: String,
default: '',
description: "Modal header title"
},
text: {},
name: {
type: String,
default: ''
},
enabled: Number,
type: {
type: String,
default: 'create',
description: "Modal header title"
},
dashboard_id: {
type: Number,
default: 0,
description: "Modal header title"
},
},
data() {
return {
form: {
loading: false,
name: this.name,
enabled: this.enabled
},
display: this.show
};
},
methods: {
closeModal() {
this.$emit("update:show", false);
this.$emit("close");
},
onSave() {
this.form.loading = true;
let data = Object.assign({}, this.form);
delete data.loading;
var self = this;
var path = url + '/common/dashboards';
if ((self.type != 'create')) {
path = url + '/common/dashboards/' + self.dashboard_id;
data['_method'] = 'PATCH';
}
axios.post(path, data)
.then(function (response) {
self.form.loading = false;
if (response.data.redirect) {
self.form.loading = true;
window.location.href = response.data.redirect;
}
self.form.response = response.data;
})
.catch(function (error) {
this.errors.record(error.response.data.errors);
self.form.loading = false;
});
},
onCancel() {
this.display = false;
this.form.name = '';
this.form.enabled = 1;
this.$emit("cancel");
},
onEnabled(value) {
this.form.enabled = value;
}
},
watch: {
show(val) {
let documentClasses = document.body.classList;
if (val) {
documentClasses.add("modal-open");
} else {
documentClasses.remove("modal-open");
}
}
}
}
</script>
<style>
.loader10 {
width: 28px;
height: 28px;
border-radius: 50%;
position: relative;
animation: loader10 0.9s ease alternate infinite;
animation-delay: 0.36s;
top: 50%;
margin: -42px auto 0;
}
.loader10::after, .loader10::before {
content: '';
position: absolute;
width: 28px;
height: 28px;
border-radius: 50%;
animation: loader10 0.9s ease alternate infinite;
}
.loader10::before {
left: -40px;
animation-delay: 0.18s;
}
.loader10::after {
right: -40px;
animation-delay: 0.54s;
}
@keyframes loader10 {
0% {
box-shadow: 0 28px 0 -28px #0052ec;
}
100% {
box-shadow: 0 28px 0 #0052ec;
}
}
</style>

View File

@@ -11,9 +11,11 @@ import Vue from 'vue';
import DashboardPlugin from './../../plugins/dashboard-plugin';
import Global from './../../mixins/global';
import Form from './../../plugins/form';
import BulkAction from './../../plugins/bulk-action';
import {getQueryVariable} from './../../plugins/functions';
import AkauntingDashboard from './../../components/AkauntingDashboard';
import AkauntingWidget from './../../components/AkauntingWidget';
import {DatePicker, Tooltip} from 'element-ui';
@@ -29,7 +31,6 @@ const dashboard = new Vue({
components: {
[DatePicker.name]: DatePicker,
[Tooltip.name]: Tooltip,
AkauntingDashboard,
AkauntingWidget
},
@@ -39,13 +40,6 @@ const dashboard = new Vue({
data: function () {
return {
dashboard_modal: false,
dashboard: {
name: '',
enabled: 1,
type: 'create',
dashboard_id: 0
},
widget_modal: false,
widgets: {},
widget: {
@@ -57,7 +51,8 @@ const dashboard = new Vue({
sort: 0,
},
filter_date: [],
form: new Form('dashboard'),
bulk_action: new BulkAction('dashboards')
};
},
@@ -75,33 +70,6 @@ const dashboard = new Vue({
},
methods:{
// Create Dashboard form open
onCreateDashboard() {
this.dashboard_modal = true;
this.dashboard.name = '';
this.dashboard.enabled = 1;
this.dashboard.type = 'create';
this.dashboard.dashboard_id = 0;
},
// Edit Dashboard information
onEditDashboard(dashboard_id) {
var self = this;
axios.get(url + '/common/dashboards/' + dashboard_id + '/edit')
.then(function (response) {
self.dashboard.name = response.data.name;
self.dashboard.enabled = response.data.enabled;
self.dashboard.type = 'edit';
self.dashboard.dashboard_id = dashboard_id;
self.dashboard_modal = true;
})
.catch(function (error) {
self.dashboard_modal = false;
});
},
// Get All Widgets
getWidgets() {
var self = this;
@@ -140,13 +108,6 @@ const dashboard = new Vue({
},
onCancel() {
this.dashboard_modal = false;
this.dashboard.name = '';
this.dashboard.enabled = 1;
this.dashboard.type = 'create';
this.dashboard.dashboard_id = 0;
this.widget_modal = false;
this.widget.id = 0;

View File

@@ -4,12 +4,10 @@ return [
'domain' => 'Domain',
'logo' => 'Logo',
'manage' => 'Manage Companies',
'all' => 'All Companies',
'error' => [
'not_user_company' => 'Error: You are not allowed to change this company!',
'delete_active' => 'Error: Can not delete active company, please, change it first!',
'delete_active' => 'Error: Can not delete the active company. Please, switch to another first!',
],
];

View File

@@ -0,0 +1,10 @@
<?php
return [
'error' => [
'not_user_dashboard' => 'Error: You are not allowed to change this dashboard!',
'delete_last' => 'Error: Can not delete the last dashboard. Please, create a new one first!',
],
];

View File

@@ -52,7 +52,6 @@ return [
'sales' => 'Sale|Sales',
'purchases' => 'Purchases|Purchases',
'dashboard' => 'Dashboard',
'welcome' => 'Welcome',
'banking' => 'Banking',
'general' => 'General',
@@ -142,6 +141,8 @@ return [
'cash' => 'Cash',
'group_by' => 'Group By',
'accounting' => 'Accounting',
'sort' => 'Sort',
'width' => 'Width',
'month' => 'Month',
'year' => 'Year',
@@ -161,6 +162,7 @@ return [
'send' => 'Send :type',
'get' => 'Get :type',
'add' => 'Add :type',
'manage' => 'Manage :type',
],
'form' => [

View File

@@ -0,0 +1,41 @@
@extends('layouts.admin')
@section('title', trans('general.title.new', ['type' => trans_choice('general.dashboards', 1)]))
@section('content')
<div class="card">
{!! Form::open([
'id' => 'dashboard',
'route' => 'dashboards.store',
'@submit.prevent' => 'onSubmit',
'@keydown' => 'form.errors.clear($event.target.name)',
'files' => true,
'role' => 'form',
'class' => 'form-loading-button',
'novalidate' => true,
]) !!}
<div class="card-body">
<div class="row">
{{ Form::textGroup('name', trans('general.name'), 'font') }}
@permission('read-auth-users')
{{ Form::checkboxGroup('users', trans_choice('general.users', 2), $users, 'name') }}
@endpermission
{{ Form::radioGroup('enabled', trans('general.enabled'), true) }}
</div>
</div>
<div class="card-footer">
<div class="row float-right">
{{ Form::saveButtons('common/dashboards') }}
</div>
</div>
{!! Form::close() !!}
</div>
@endsection
@push('scripts_start')
<script src="{{ asset('public/js/common/dashboards.js?v=' . version('short')) }}"></script>
@endpush

View File

@@ -0,0 +1,44 @@
@extends('layouts.admin')
@section('title', trans('general.title.edit', ['type' => trans_choice('general.dashboards', 1)]))
@section('content')
<div class="card">
{!! Form::model($dashboard, [
'id' => 'dashboard',
'method' => 'PATCH',
'route' => ['dashboards.update', $dashboard->id],
'@submit.prevent' => 'onSubmit',
'@keydown' => 'form.errors.clear($event.target.name)',
'files' => true,
'role' => 'form',
'class' => 'form-loading-button',
'novalidate' => true,
]) !!}
<div class="card-body">
<div class="row">
{{ Form::textGroup('name', trans('general.name'), 'font') }}
@permission('read-auth-users')
{{ Form::checkboxGroup('users', trans_choice('general.users', 2), $users, 'name') }}
@endpermission
{{ Form::radioGroup('enabled', trans('general.enabled'), $dashboard->enabled) }}
</div>
</div>
@permission('update-common-dashboards')
<div class="card-footer">
<div class="row float-right">
{{ Form::saveButtons('common/dashboards') }}
</div>
</div>
@endpermission
{!! Form::close() !!}
</div>
@endsection
@push('scripts_start')
<script src="{{ asset('public/js/common/dashboards.js?v=' . version('short')) }}"></script>
@endpush

View File

@@ -0,0 +1,92 @@
@extends('layouts.admin')
@section('title', trans_choice('general.dashboards', 2))
@permission('create-common-dashboards')
@section('new_button')
<span><a href="{{ route('dashboards.create') }}" class="btn btn-success btn-sm btn-alone"><span class="fa fa-plus"></span> &nbsp;{{ trans('general.add_new') }}</a></span>
@endsection
@endpermission
@section('content')
<div class="card">
<div class="card-header border-bottom-0" v-bind:class="[bulk_action.show ? 'bg-gradient-primary' : '']">
{!! Form::open([
'route' => 'dashboards.index',
'role' => 'form',
'method' => 'GET',
'class' => 'mb-0'
]) !!}
<div class="row" v-if="!bulk_action.show">
<div class="col-12 d-flex align-items-center">
<span class="font-weight-400 d-none d-lg-block mr-2">{{ trans('general.search') }}:</span>
<akaunting-search></akaunting-search>
</div>
</div>
{{ Form::bulkActionRowGroup('general.dashboards', $bulk_actions, 'common/dashboards') }}
{!! Form::close() !!}
</div>
<div class="table-responsive">
<table class="table table-flush table-hover">
<thead class="thead-light">
<tr class="row table-head-line">
<th class="col-sm-2 col-md-2 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionAllGroup() }}</th>
<th class="col-xs-4 col-sm-3 col-md-6 col-lg-7 col-xl-7 long-texts">@sortablelink('name', trans('general.name'))</th>
<th class="col-xs-4 col-sm-3 col-md-2 col-lg-2 col-xl-2">@sortablelink('enabled', trans('general.enabled'))</th>
<th class="col-xs-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 text-center">{{ trans('general.actions') }}</th>
</tr>
</thead>
<tbody>
@foreach($dashboards as $item)
<tr class="row align-items-center border-top-1">
<td class="col-sm-2 col-md-2 col-lg-1 col-xl-1 d-none d-sm-block">{{ Form::bulkActionGroup($item->id, $item->name) }}</td>
<td class="col-xs-4 col-sm-3 col-md-6 col-lg-7 col-xl-7 long-texts"><a class="text-success" href="{{ route('dashboards.edit', $item->id) }}">{{ $item->name }}</a></td>
<td class="col-xs-4 col-sm-3 col-md-2 col-lg-2 col-xl-2">
@if (user()->can('update-common-dashboards'))
{{ Form::enabledGroup($item->id, $item->name, $item->enabled) }}
@else
@if ($item->enabled)
<badge rounded type="success">{{ trans('general.enabled') }}</badge>
@else
<badge rounded type="danger">{{ trans('general.disabled') }}</badge>
@endif
@endif
</td>
<td class="col-xs-4 col-sm-2 col-md-2 col-lg-2 col-xl-2 text-center">
<div class="dropdown">
<a class="btn btn-neutral btn-sm text-light items-align-center py-2" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-ellipsis-h text-muted"></i>
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
@if ($item->enabled)
<a class="dropdown-item" href="{{ route('dashboards.switch', $item->id) }}">{{ trans('general.switch') }}</a>
<div class="dropdown-divider"></div>
@endif
<a class="dropdown-item" href="{{ route('dashboards.edit', $item->id) }}">{{ trans('general.edit') }}</a>
@permission('delete-common-dashboards')
<div class="dropdown-divider"></div>
{!! Form::deleteLink($item, 'common/dashboards') !!}
@endpermission
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="card-footer table-action">
<div class="row">
@include('partials.admin.pagination', ['items' => $dashboards])
</div>
</div>
</div>
@endsection
@push('scripts_start')
<script src="{{ asset('public/js/common/dashboards.js?v=' . version('short')) }}"></script>
@endpush

View File

@@ -3,6 +3,7 @@
@section('title', $dashboard->name)
@section('dashboard_action')
@permission(['create-common-widgets', 'read-common-dashboards'])
<span class="dashboard-action">
<div class="dropdown">
<a class="btn btn-sm items-align-center py-2 mt--1" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -10,41 +11,32 @@
</a>
<div class="dropdown-menu dropdown-menu-left dropdown-menu-arrow">
{!! Form::button(trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]), array(
@permission('create-common-widgets')
{!! Form::button(trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]), [
'type' => 'button',
'class' => 'dropdown-item',
'title' => trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]),
'@click' => 'onCreateWidget()'
)) !!}
{!! Form::button(trans('general.title.edit', ['type' => trans_choice('general.dashboard', 1)]), array(
'type' => 'button',
'class' => 'dropdown-item',
'title' => trans('general.title.edit', ['type' => trans_choice('general.dashboard', 1)]),
'@click' => 'onEditDashboard(' . $dashboard->id . ')'
)) !!}
@if ($dashboards->count() > 1)
{!! Form::deleteLink($dashboard, 'common/dashboards') !!}
@endif
'@click' => 'onCreateWidget()',
]) !!}
@endpermission
@permission('read-common-dashboards')
<div class="dropdown-divider"></div>
{!! Form::button(trans('general.title.add', ['type' => trans_choice('general.dashboard', 1)]), array(
'type' => 'button',
'class' => 'dropdown-item',
'title' => trans('general.title.add', ['type' => trans_choice('general.dashboard', 1)]),
'@click' => 'onCreateDashboard()'
)) !!}
@permission('create-common-dashboards')
<a class="dropdown-item" href="{{ route('dashboards.create') }}">{{ trans('general.title.create', ['type' => trans_choice('general.dashboards', 1)]) }}</a>
@endpermission
<a class="dropdown-item" href="{{ route('dashboards.index') }}">{{ trans('general.title.manage', ['type' => trans_choice('general.dashboards', 2)]) }}</a>
@endpermission
</div>
</div>
</span>
@endpermission
@php
$text = json_encode([
'name' => trans('general.name'),
'type' => 'Type',
'width' => 'Width',
'sort' => 'Sort',
'type' => trans_choice('general.types', 1),
'width' => trans('general.width'),
'sort' => trans('general.sort'),
'enabled' => trans('general.enabled'),
'yes' => trans('general.yes'),
'no' => trans('general.no'),
@@ -54,24 +46,12 @@
$placeholder = json_encode([
'name' => trans('general.form.enter', ['field' => trans('general.name')]),
'type' => trans('general.form.enter', ['field' => 'Type']),
'width' => trans('general.form.enter', ['field' => 'Width']),
'sort' => trans('general.form.enter', ['field' => 'Sort'])
'type' => trans('general.form.enter', ['field' => trans_choice('general.types', 1)]),
'width' => trans('general.form.enter', ['field' => trans('general.width')]),
'sort' => trans('general.form.enter', ['field' => trans('general.sprt')])
]);
@endphp
<akaunting-dashboard
v-if="dashboard_modal"
:title="'{{ trans('general.dashboard') }}'"
:show="dashboard_modal"
:name="dashboard.name"
:enabled="dashboard.enabled"
:type="dashboard.type"
:dashboard_id="dashboard.dashboard_id"
:text="{{ $text }}"
@cancel="onCancel">
</akaunting-dashboard>
<akaunting-widget
v-if="widget_modal"
:title="'{{ trans_choice('general.widgets', 1) }}'"
@@ -181,5 +161,5 @@
@endsection
@push('scripts_start')
<script src="{{ asset('public/js/common/dashboard.js?v=' . version('short')) }}"></script>
<script src="{{ asset('public/js/common/dashboards.js?v=' . version('short')) }}"></script>
@endpush

View File

@@ -23,7 +23,7 @@
<div class="dropdown-divider"></div>
<a href="{{ route('companies.index') }}" class="dropdown-item">
<i class="fas fa-cogs"></i>
<span>{{ trans('companies.manage') }}</span>
<span>{{ trans('general.title.manage', ['type' => trans_choice('general.companies', 2)]) }}</span>
</a>
@endpermission
</div>

View File

@@ -1,3 +1,4 @@
@permission(['update-common-widgets', 'delete-common-widgets'])
<div class="card-header{{ !empty($header_class) ? ' ' . $header_class : '' }}">
<div class="row align-items-center">
@@ -13,17 +14,22 @@
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
@permission('update-common-widgets')
{!! Form::button(trans('general.edit'), [
'type' => 'button',
'class' => 'dropdown-item',
'title' => trans('general.edit'),
'@click' => 'onEditWidget(' . $model->id . ')'
]) !!}
@endpermission
@permission('delete-common-widgets')
<div class="dropdown-divider"></div>
{!! Form::deleteLink($model, 'common/widgets') !!}
@endpermission
</div>
</div>
</span>
</div>
</div>
</div>
@endpermission

View File

@@ -1,3 +1,4 @@
@permission(['update-common-widgets', 'delete-common-widgets'])
<span>
<div class="dropdown card-action-button">
<a class="btn btn-sm items-align-center py-2 mr-0 shadow-none--hover" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@@ -5,14 +6,19 @@
</a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-arrow">
@permission('update-common-widgets')
{!! Form::button(trans('general.edit'), [
'type' => 'button',
'class' => 'dropdown-item',
'title' => trans('general.edit'),
'@click' => 'onEditWidget(' . $model->id . ')'
]) !!}
@endpermission
@permission('delete-common-widgets')
<div class="dropdown-divider"></div>
{!! Form::deleteLink($model, 'common/widgets') !!}
@endpermission
</div>
</div>
</span>
</span>
@endpermission