Skip to content

Commit

Permalink
Code refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Jul 17, 2024
1 parent e8ac5ba commit 5fb6909
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 91 deletions.
6 changes: 3 additions & 3 deletions resources/js/partials/flashmessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@

FlashMessage.TOAST_DEFAULTS = {
toast: true,
position: 'bottom-start',
position: 'top-end',
showConfirmButton: false,
timer: 0,
timerProgressBar: true,
showClass: {
popup: 'animated fadeInLeft'
popup: 'animated fadeInRight'
},
hideClass: {
popup: 'animated fadeOutLeft'
popup: 'animated fadeOutRight'
},
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
Expand Down
5 changes: 2 additions & 3 deletions resources/lang/en/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,11 @@
'label_site_email' => 'Restaurant Email',
'label_site_logo' => 'Restaurant Logo',
'label_timezone' => 'Default Timezone',
'label_site_currency' => 'Default Currency',
'label_currency_converter' => 'Default Currency Converter',
'label_currency_converter_oer_api_key' => 'Currency Converter (Open Exchange Rates API) App ID',
'label_currency_converter_fixer_api_key' => 'Currency Converter (Fixer.io API) App ID',
'label_currency_refresh_interval' => 'Exchange Rates Refresh Interval',
'label_detect_language' => 'Detect Browser Language',
'label_site_language' => 'Default Language',
'label_customer_group' => 'Customer Group',
'label_country' => 'Country',
'label_maps_api_key' => 'Google Maps API Key',
Expand Down Expand Up @@ -461,10 +459,11 @@
'alert_delete_setup_files' => '<b>SECURITY WARNING!</b> Delete the setup files to stop someone else from overwriting your site.',

'help_timezone' => 'The default timezone. Choose a city in the same timezone as your restaurant.',
'help_language' => 'You can set the default language for your site from the <em>Manage > Settings > Languages</em> page',
'help_detect_language' => 'Enable or disable user browser language detection. If enabled your site will be translated to the browser language.',
'help_maps_api_key' => 'An API Key is required to use Google Maps and/or Geocoding. <a target="_blank" href="https://developers.google.com/maps/documentation/javascript/get-api-key#get-an-api-key">Where can I find my Google Maps API Key?</a> Enable Google Maps Geocoding API and Google Maps JavaScript API in your Google Developer account',
'help_default_geocoder' => 'Tell the system which geocoder service to use when geocoding addresses. \'Chain\' is a special geocoder that runs both google and open street maps geocoder and stops once it gets a valid response.',
'help_site_currency' => 'Enable more currencies from Localisation > Currencies.',
'help_site_currency' => 'You can set the default currency for your site from the <em>Manage > Settings > Currencies</em> page',
'help_currency_converter_oer_api' => 'You can <a target="_blank" href="https://openexchangerates.org/signup/">sign up here</a> for your Open Exchange Rates API.',
'help_currency_converter_fixer_api' => 'You can <a target="_blank" href="https://fixer.io/signup/">sign up here</a> for your Fixer.io API.',
'help_special_category' => 'Select which category to use automatically for special menus',
Expand Down
2 changes: 2 additions & 0 deletions resources/models/system/generalsettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
'language' => [
'label' => 'lang:igniter::system.settings.text_tab_title_language',
'tab' => 'lang:igniter::system.settings.text_tab_site',
'comment' => 'lang:igniter::system.settings.help_language',
'type' => 'section',
],
'detect_language' => [
Expand All @@ -88,6 +89,7 @@
'label' => 'lang:igniter::system.settings.text_tab_title_currency',
'tab' => 'lang:igniter::system.settings.text_tab_site',
'type' => 'section',
'comment' => 'lang:igniter::system.settings.help_site_currency',
],
'currency_converter[api]' => [
'label' => 'lang:igniter::system.settings.label_currency_converter',
Expand Down
37 changes: 32 additions & 5 deletions resources/scss/components/_alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,26 @@ body:not(.swal2-toast-shown) {

&.swal2-toast {
padding: 0.6em 1em;
border-bottom: 2px solid transparent;
border-top: 2px solid transparent;

&.swal2-icon-error, &.swal2-icon-danger {
border-bottom-color: var(--bs-danger);
background-color: var(--bs-danger);
color: $white;
}

&.swal2-icon-success {
border-bottom-color: var(--bs-success);
background-color: var(--bs-success);
color: $white;
}

&.swal2-icon-info {
border-bottom-color: var(--bs-info);
background-color: var(--bs-info);
color: $white;
}

&.swal2-icon-warning {
border-bottom-color: var(--bs-warning);
background-color: var(--bs-warning);
color: $white;
}

.swal2-icon {
Expand All @@ -48,6 +52,11 @@ body:not(.swal2-toast-shown) {
height: 1.5em;
margin: 0;
border-width: 0;
color: $white;
}

.swal2-html-container {
font-size: $font-size-base;
}
}

Expand Down Expand Up @@ -79,3 +88,21 @@ body:not(.swal2-toast-shown) {
width: auto !important;
}
}

div:where(.swal2-icon) {
&.swal2-success {
color: var(--bs-success);
}

&.swal2-error, &.swal2-danger {
color: var(--bs-danger);
}

&.swal2-info {
color: var(--bs-info);
}

&.swal2-warning {
color: var(--bs-warning);
}
}
2 changes: 1 addition & 1 deletion resources/views/admin/_layouts/default.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<div class="d-flex page-container h-100">
@if(AdminAuth::isLogged())
<div class="sidebar border-right overflow-y-auto">
<div id="sidebarMenu" class="offcanvas-lg offcanvas-end px-2 py-3">
<div id="sidebarMenu" class="offcanvas-lg offcanvas-start px-2 py-3">
<div class="offcanvas-header">
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#sidebarMenu" aria-label="Close"></button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ class="col col-sm-{{ $widget->getWidth() }} my-3"
<div class="widget-item card {{ $widget->getCssClass() }} bg-white p-3 shadow-sm">
<div class="widget-item-action">
<a class="btn shadow-none handle pull-left"><i class="fa fa-arrows-alt"></i></a>
@if($this->canManage)
<a
class="btn shadow-none pull-right"
data-control="remove-widget"
aria-hidden="true"
><i class="fa fa-trash-alt text-danger"></i></a>
@endif
<a
class="btn shadow-none pull-right"
data-control="remove-widget"
aria-hidden="true"
><i class="fa fa-trash-alt text-danger"></i></a>
<a
class="btn shadow-none pull-right"
data-control="edit-widget"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,57 @@ class="modal slideInDown fade"
</div>
</div>
</div>
@if($this->canManage || $this->canSetDefault)
<div class="toolbar-action d-flex justify-content-between p-3">
@if($this->canManage)
<div class="btn-group">
<div class="toolbar-action d-flex justify-content-between p-3">
<div class="btn-group">
<button
type="button"
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#newWidgetModal"
data-request="{{ $this->getEventHandler('onLoadAddPopup') }}"
tabindex="-1"
><i class="fa fa-plus"></i>&nbsp;&nbsp;@lang('igniter::admin.dashboard.button_add_widget')</button>
<button
type="button"
class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split"
data-bs-toggle="dropdown"
data-bs-display="static"
aria-expanded="false"
><span class="visually-hidden">Toggle Dropdown</span></button>
<ul class="dropdown-menu">
<li>
@if($this->canSetDefault)
<button
type="button"
class="dropdown-item"
data-request="{{ $this->getEventHandler('onSetAsDefault') }}"
data-request-confirm="@lang('igniter::admin.dashboard.alert_set_default_confirm')"
data-attach-loading
tabindex="-1"
>@lang('igniter::admin.dashboard.button_set_default')</button>
@endif
<button
type="button"
class="btn btn-primary"
data-bs-toggle="modal"
data-bs-target="#newWidgetModal"
data-request="{{ $this->getEventHandler('onLoadAddPopup') }}"
class="dropdown-item text-danger"
data-request="{{ $this->getEventHandler('onResetWidgets') }}"
data-request-confirm="@lang('igniter::admin.alert_warning_confirm')"
data-attach-loading
title="@lang('igniter::admin.dashboard.button_reset_widgets')"
tabindex="-1"
><i class="fa fa-plus"></i>&nbsp;&nbsp;@lang('igniter::admin.dashboard.button_add_widget')</button>
<button
type="button"
class="btn btn-outline-primary dropdown-toggle dropdown-toggle-split"
data-bs-toggle="dropdown"
data-bs-display="static"
aria-expanded="false"
><span class="visually-hidden">Toggle Dropdown</span></button>
<ul class="dropdown-menu">
<li>
@if($this->canSetDefault)
<button
type="button"
class="dropdown-item"
data-request="{{ $this->getEventHandler('onSetAsDefault') }}"
data-request-confirm="@lang('igniter::admin.dashboard.alert_set_default_confirm')"
data-attach-loading
tabindex="-1"
>@lang('igniter::admin.dashboard.button_set_default')</button>
@endif
<button
type="button"
class="dropdown-item text-danger"
data-request="{{ $this->getEventHandler('onResetWidgets') }}"
data-request-confirm="@lang('igniter::admin.alert_warning_confirm')"
data-attach-loading
title="@lang('igniter::admin.dashboard.button_reset_widgets')"
tabindex="-1"
>@lang('admin::lang.dashboard.button_reset_widgets')</button>
</li>
</ul>
</div>
@endif
<button
id="{{ $this->alias }}-daterange"
class="btn btn-light text-reset pull-right"
data-control="daterange"
data-start-date="{{ $startDate }}"
data-end-date="{{ $endDate }}"
>
<i class="fa fa-calendar"></i>&nbsp;&nbsp;
<span class="d-none d-md-inline">{{$startDate->isoFormat($dateRangeFormat).' - '.$endDate->isoFormat($dateRangeFormat)}}</span>&nbsp;&nbsp;
<i class="fa fa-caret-down"></i>
</button>
>@lang('admin::lang.dashboard.button_reset_widgets')</button>
</li>
</ul>
</div>
@endif
<button
id="{{ $this->alias }}-daterange"
class="btn btn-light text-reset pull-right"
data-control="daterange"
data-start-date="{{ $startDate }}"
data-end-date="{{ $endDate }}"
>
<i class="fa fa-calendar"></i>&nbsp;&nbsp;
<span
class="d-none d-md-inline">{{$startDate->isoFormat($dateRangeFormat).' - '.$endDate->isoFormat($dateRangeFormat)}}</span>&nbsp;&nbsp;
<i class="fa fa-caret-down"></i>
</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
@endif

@if($field->comment)
<p class="help-block">@lang($field->comment)</p>
<p class="help-block mt-2">@lang($field->comment)</p>
@endif
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class="form-check-input"
@foreach($columns as $key => $column)
@continue($column->type == 'button')
<td
class="list-col-index-{{ $loop->index }} list-col-name-{{ $column->getName() }} list-col-type-{{ $column->type }} {{ $column->cssClass }}"
class="list-col-index-{{ $loop->index }} list-col-name-{{ $column->getName() }} list-col-type-{{ $column->type }} {{ $column->cssClass }} text-nowrap"
@if($loop->last)colspan="4"@endif
>
{!! $this->getColumnValue($record, $column) !!}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/system/settings/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@foreach($settings as $item => $categories)
@continue(!count($categories))
@unless($item == 'core')
<h4 class="py-2 my-4 border-bottom">{{ ucwords($item) }}</h4>
<h4 class="py-2 my-4 border-bottom"></h4>
@endunless

<div class="row g-3">
Expand Down
16 changes: 0 additions & 16 deletions src/Admin/Widgets/DashboardContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ public function onAddWidget(): array

public function onResetWidgets(): array
{
if (!$this->canManage) {
throw new FlashException(lang('igniter::admin.alert_access_denied'));
}

$this->resetWidgets();

$this->resetSession();
Expand All @@ -212,10 +208,6 @@ public function onSetAsDefault()

public function onUpdateWidget(): array
{
if (!$this->canManage) {
throw new FlashException(lang('igniter::admin.alert_access_denied'));
}

$alias = post('alias');

$widget = $this->findWidgetByAlias($alias);
Expand Down Expand Up @@ -246,10 +238,6 @@ public function onRemoveWidget()

protected function addWidget(string $widgetAlias, BaseDashboardWidget $widget, mixed $size)
{
if (!$this->canManage) {
throw new FlashException(lang('igniter::admin.alert_access_denied'));
}

$widgets = $this->getWidgetsFromUserPreferences();

$nextPriority = collect($widgets)->max('priority') + 1;
Expand Down Expand Up @@ -379,10 +367,6 @@ protected function resetWidgets()

protected function removeWidget(string $alias)
{
if (!$this->canManage) {
throw new FlashException(lang('igniter::admin.alert_access_denied'));
}

$widgets = $this->getWidgetsFromUserPreferences();

if (isset($widgets[$alias])) {
Expand Down

0 comments on commit 5fb6909

Please sign in to comment.