akaunting 3.0 (the last dance)
This commit is contained in:
94
app/View/Components/Index/Bulkaction.php
Normal file
94
app/View/Components/Index/Bulkaction.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use App\Events\Common\BulkActionsAdding;
|
||||
|
||||
class Bulkaction extends Component
|
||||
{
|
||||
public $class;
|
||||
|
||||
public $text = '';
|
||||
|
||||
public $path = '';
|
||||
|
||||
public $actions = [];
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $class, string $text = '', string $path = '', $actions = []
|
||||
) {
|
||||
$this->class = $class;
|
||||
$this->text = $text;
|
||||
$this->path = $path;
|
||||
$this->actions = $this->getActions($actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.bulkaction.index');
|
||||
}
|
||||
|
||||
protected function getActions($actions)
|
||||
{
|
||||
if (! empty($actions)) {
|
||||
return $actions;
|
||||
}
|
||||
|
||||
if (class_exists($this->class)) {
|
||||
$bulk_action = app($this->class);
|
||||
|
||||
event(new BulkActionsAdding($bulk_action));
|
||||
|
||||
$this->text = $bulk_action->text;
|
||||
|
||||
if (is_array($bulk_action->path)) {
|
||||
$this->path = route('bulk-actions.action', $bulk_action->path);
|
||||
} else {
|
||||
$this->path = url('common/bulk-actions/' . $bulk_action->path);
|
||||
}
|
||||
} else {
|
||||
$bulk_action = new \stdClass();
|
||||
$bulk_action->text = '';
|
||||
$bulk_action->path = '';
|
||||
$bulk_action->actions = [];
|
||||
$bulk_action->icons = [];
|
||||
|
||||
event(new BulkActionsAdding($bulk_action));
|
||||
|
||||
if (is_array($bulk_action->path)) {
|
||||
$this->path = route('bulk-actions.action', $bulk_action->path);
|
||||
} else {
|
||||
$this->path = url('common/bulk-actions/' . $bulk_action->path);
|
||||
}
|
||||
}
|
||||
|
||||
$actions = [];
|
||||
|
||||
if ($bulk_action->actions) {
|
||||
foreach ($bulk_action->actions as $key => $action) {
|
||||
if ((isset($action['permission']) && ! user()->can($action['permission']))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (empty($action['icon']) && array_key_exists($key, $bulk_action->icons)) {
|
||||
$action['icon'] = $bulk_action->icons[$key];
|
||||
}
|
||||
|
||||
$actions[$key] = $action;
|
||||
}
|
||||
}
|
||||
|
||||
return $actions;
|
||||
}
|
||||
}
|
120
app/View/Components/Index/Category.php
Normal file
120
app/View/Components/Index/Category.php
Normal file
@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Category extends Component
|
||||
{
|
||||
/**
|
||||
* The Category model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $model;
|
||||
|
||||
/**
|
||||
* The Category name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* The Category background color.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $backgroundColor;
|
||||
|
||||
/**
|
||||
* The Category background style.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $backgroundStyle;
|
||||
|
||||
/**
|
||||
* The Category text color.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $textColor;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$model = false, $name = '', $backgroundColor = '', $textColor = ''
|
||||
) {
|
||||
$this->model = $model;
|
||||
|
||||
$this->name = $this->getName($name, $model);
|
||||
$this->backgroundColor = $this->getBackgroundColor($backgroundColor, $model);
|
||||
$this->textColor = $this->getTextColor($textColor, $this->backgroundColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.category');
|
||||
}
|
||||
|
||||
protected function getName($name, $model)
|
||||
{
|
||||
if (! empty($name)) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
if (! empty($model)) {
|
||||
$name = $model->name;
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
protected function getBackgroundColor($backgroundColor, $model)
|
||||
{
|
||||
if (! empty($backgroundColor)) {
|
||||
return $backgroundColor;
|
||||
}
|
||||
|
||||
if (! empty($model)) {
|
||||
if (Str::contains($model->color, ['#'])) {
|
||||
$this->backgroundStyle = $model->color;
|
||||
|
||||
return $backgroundColor;
|
||||
}
|
||||
|
||||
$backgroundColor = 'bg-' . $model->color;
|
||||
}
|
||||
|
||||
return $backgroundColor;
|
||||
}
|
||||
|
||||
protected function getTextColor($textColor, $backgroundColor)
|
||||
{
|
||||
if (! empty($textColor)) {
|
||||
return $textColor;
|
||||
}
|
||||
|
||||
if (! empty($backgroundColor)) {
|
||||
$x = explode('-', $backgroundColor);
|
||||
|
||||
$textColor = 'text-black';
|
||||
|
||||
if ($x[1] >= 500) {
|
||||
$textColor = 'text-white';
|
||||
}
|
||||
}
|
||||
|
||||
return $textColor;
|
||||
}
|
||||
}
|
43
app/View/Components/Index/Country.php
Normal file
43
app/View/Components/Index/Country.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Country extends Component
|
||||
{
|
||||
/**
|
||||
* The Country country.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $country;
|
||||
|
||||
/**
|
||||
* The Country code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($code) {
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->country = trans('countries.' . $this->code);
|
||||
|
||||
return view('components.index.country');
|
||||
}
|
||||
}
|
45
app/View/Components/Index/Currency.php
Normal file
45
app/View/Components/Index/Currency.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Currency extends Component
|
||||
{
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $currency;
|
||||
|
||||
/**
|
||||
* The Currency code.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $code;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($code) {
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$code = ($this->code) ? $this->code : setting('default.currency');
|
||||
|
||||
$this->currency = config('money.' . $code . '.name');
|
||||
|
||||
return view('components.index.currency');
|
||||
}
|
||||
}
|
63
app/View/Components/Index/Ddefault.php
Normal file
63
app/View/Components/Index/Ddefault.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Ddefault extends Component
|
||||
{
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Tooltip position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $position;
|
||||
|
||||
/**
|
||||
* Tooltip in default icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Tooltip in default icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $iconType;
|
||||
|
||||
/**
|
||||
* defaultd text type name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $text;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$position = 'right', $icon = 'lock', $iconType = '-round', $text = ''
|
||||
) {
|
||||
$this->id = 'tooltip-default-' . mt_rand(1, time());
|
||||
$this->position = $position;
|
||||
$this->icon = $icon;
|
||||
$this->iconType = $iconType;
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.default');
|
||||
}
|
||||
}
|
80
app/View/Components/Index/Disable.php
Normal file
80
app/View/Components/Index/Disable.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class Disable extends Component
|
||||
{
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* Tooltip position.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $position;
|
||||
|
||||
/**
|
||||
* Tooltip in disable icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $icon;
|
||||
|
||||
/**
|
||||
* Tooltip in disable icon.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $iconType;
|
||||
|
||||
/**
|
||||
* Disabled text type name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $text;
|
||||
|
||||
/**
|
||||
* Full disable text.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $disableText;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$position = 'right', $icon = 'unpublished', $iconType = '-round', $text = '', $disableText = ''
|
||||
) {
|
||||
$this->id = 'tooltip-disable-' . mt_rand(1, time());
|
||||
$this->position = $position;
|
||||
$this->icon = $icon;
|
||||
$this->iconType = $iconType;
|
||||
$this->disableText = $this->getDisableText($text, $disableText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.disable');
|
||||
}
|
||||
|
||||
protected function getDisableText($text, $disableText)
|
||||
{
|
||||
if (! empty($disableText)) {
|
||||
return $disableText;
|
||||
}
|
||||
|
||||
return trans('general.disabled_type', ['type' => Str::lower($text)]);
|
||||
}
|
||||
}
|
121
app/View/Components/Index/Search.php
Normal file
121
app/View/Components/Index/Search.php
Normal file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Search extends Component
|
||||
{
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var bool|string
|
||||
*/
|
||||
public $searchString;
|
||||
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var bool|string
|
||||
*/
|
||||
public $bulkAction;
|
||||
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $action;
|
||||
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $route;
|
||||
|
||||
/**
|
||||
* The Currency currency.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $url;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$searchString = false, $bulkAction = false, $action = false, $route = false, $url = false
|
||||
) {
|
||||
$this->searchString = $searchString;
|
||||
$this->bulkAction = $bulkAction;
|
||||
$this->action = $this->getAction($action, $route, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.search');
|
||||
}
|
||||
|
||||
protected function getAction($action, $route, $url)
|
||||
{
|
||||
if (! empty($action)) {
|
||||
return $action;
|
||||
}
|
||||
|
||||
if (! empty($route)) {
|
||||
return $this->getRouteAction($route);
|
||||
}
|
||||
|
||||
if (! empty($url)) {
|
||||
return $this->getUrlAction($url);
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "url" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getUrlAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
return url($options[0], array_slice($options, 1));
|
||||
}
|
||||
|
||||
return url($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the action for a "route" option.
|
||||
*
|
||||
* @param array|string $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getRouteAction($options)
|
||||
{
|
||||
if (is_array($options)) {
|
||||
$parameters = array_slice($options, 1);
|
||||
|
||||
if (array_keys($options) === [0, 1]) {
|
||||
$parameters = head($parameters);
|
||||
}
|
||||
|
||||
return route($options[0], $parameters);
|
||||
}
|
||||
|
||||
return route($options);
|
||||
}
|
||||
}
|
56
app/View/Components/Index/Status.php
Normal file
56
app/View/Components/Index/Status.php
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Status extends Component
|
||||
{
|
||||
/** @var string */
|
||||
public $backgroundColor;
|
||||
|
||||
/** @var string */
|
||||
public $textColor;
|
||||
|
||||
/** @var string */
|
||||
public $status;
|
||||
|
||||
/** @var string */
|
||||
public $textStatus;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
string $backgroundColor = '', string $textColor = '',
|
||||
string $status = '', string $textStatus = ''
|
||||
) {
|
||||
$this->backgroundColor = ! empty($backgroundColor) ? $backgroundColor : 'bg-lilac-900';
|
||||
$this->textColor = ! empty($textColor) ? $textColor : 'text-purple';
|
||||
$this->status = $status;
|
||||
$this->textStatus = $this->getTextStatus($textStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.status');
|
||||
}
|
||||
|
||||
protected function getTextStatus($textStatus)
|
||||
{
|
||||
if (! empty($textStatus)) {
|
||||
return $textStatus;
|
||||
}
|
||||
|
||||
$textStatus = trans('documents.statuses.' . $this->status);
|
||||
|
||||
return $textStatus;
|
||||
}
|
||||
}
|
31
app/View/Components/Index/Summary.php
Normal file
31
app/View/Components/Index/Summary.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\View\Components\Index;
|
||||
|
||||
use App\Abstracts\View\Component;
|
||||
|
||||
class Summary extends Component
|
||||
{
|
||||
public $items;
|
||||
|
||||
/**
|
||||
* Create a new component instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(
|
||||
$items = []
|
||||
) {
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the view / contents that represent the component.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View|string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
return view('components.index.summary');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user