Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sampoyigi committed Jul 14, 2021
2 parents 6f37d75 + 628a222 commit 03cd0b1
Show file tree
Hide file tree
Showing 44 changed files with 238 additions and 155 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Please report bugs using the [GitHub issue tracker](https://github.com/tastyigni
- [Blog](https://tastyigniter.com/blog) for tips and latest developments in the food industry.

## Contributing
We would love your help building TastyIgniter! Please read the [Contributing Guidelines](CONTRIBUTING.md) to learn how you can help.
We would love your help building TastyIgniter! Please read the [Contributing Guidelines](.github/CONTRIBUTING.md) to learn how you can help.

Thank you to all the people who already contributed to TastyIgniter!

Expand Down
4 changes: 2 additions & 2 deletions app/admin/actions/LocationAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function locationApplyScope($query)
if (is_null($ids = AdminLocation::getIdOrAll()))
return;

(bool)$this->getConfig('addAbsenceConstraint', FALSE)
(bool)$this->getConfig('addAbsenceConstraint', TRUE)
? $query->whereHasOrDoesntHaveLocation($ids)
: $query->whereHasLocation($ids);
}
Expand All @@ -74,7 +74,7 @@ protected function locationBindEvents()
});

Event::listen('admin.filter.extendQuery', function ($filterWidget, $query, $scope) {
if (array_key_exists('locationAware', $scope->config)
if (array_get($scope->config, 'locationAware') === TRUE
AND (bool)$this->getConfig('applyScopeOnListQuery', TRUE)
) $this->locationApplyScope($query);
});
Expand Down
16 changes: 13 additions & 3 deletions app/admin/assets/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -17595,6 +17595,18 @@ body.dragging .dragged {
padding-bottom: calc(0.5rem - 5px);
border-radius: 3px !important;
font-size: 0.9375rem;
box-shadow: none;
border: 1px solid transparent;
}
.btn-group-toggle .btn:focus, .btn-group-toggle .btn.focus {
background-color: transparent !important;
box-shadow: none;
border: 1px solid transparent;
}
.btn-group-toggle .btn:active, .btn-group-toggle .btn.active {
background-color: #E8E9EF !important;
border: 1px solid #D2D4DF !important;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 1px 1px rgba(0, 3, 41, 0.075);
}
.form-group .select2-container {
width: 100% !important;
Expand Down Expand Up @@ -17657,6 +17669,7 @@ body.dragging .dragged {
}
.select2-results__option {
border-radius: 3px;
margin-bottom: 0.3rem;
}
.sidebar {
position: fixed;
Expand Down Expand Up @@ -18897,9 +18910,6 @@ html {
min-height: 100%;
height: 100%;
}
body {
margin-bottom: 50px;
}
body.page {
height: 100%;
overflow: hidden;
Expand Down
16 changes: 16 additions & 0 deletions app/admin/assets/scss/components/_button-group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,21 @@
padding-bottom: calc(#{$input-padding-y-lg} - 5px);
border-radius: $input-border-radius !important;
font-size: $input-font-size;
box-shadow: none;
border: 1px solid transparent;

&:focus,
&.focus {
background-color: transparent !important;
box-shadow: none;
border: 1px solid transparent;
}

&:active,
&.active {
background-color: $gray-200 !important;
border: 1px solid $input-border-color !important;
@include box-shadow($btn-box-shadow);
}
}
}
1 change: 1 addition & 0 deletions app/admin/assets/scss/components/_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@
}
.select2-results__option {
border-radius: $input-border-radius;
margin-bottom: .3rem;
}
6 changes: 1 addition & 5 deletions app/admin/assets/scss/utilities/_utilities.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ html {
height: 100%;
}

body {
margin-bottom: 50px;
}

body.page {
height: 100%;
overflow: hidden;
Expand All @@ -22,4 +18,4 @@ body.page {
.page-y-spacer {
padding-top: $page-padding-y;
padding-bottom: $page-padding-y;
}
}
24 changes: 13 additions & 11 deletions app/admin/classes/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,7 @@ public function getAll()
if ($this->getAuth()->isSuperUser())
return null;

return $this->getAuth()
->locations()
->pluck('location_id')
->all();
return $this->getLocations()->pluck('location_id')->all();
}

public function getIdOrAll()
Expand All @@ -98,14 +95,12 @@ public function listLocations()
if ($this->getAuth()->isSuperUser())
return $this->createLocationModel()->getDropdownOptions();

return $this->getAuth()
->locations()
->pluck('location_name', 'location_id');
return $this->getLocations()->pluck('location_name', 'location_id');
}

public function getDefaultLocation()
{
if (!$staffLocation = $this->getAuth()->locations()->first())
if (!$staffLocation = $this->getLocations()->first())
return null;

return $staffLocation->getKey();
Expand All @@ -116,7 +111,7 @@ public function hasOneLocation()
if ($this->isSingleMode())
return TRUE;

return $this->getAuth()->locations()->count() === 1;
return $this->getLocations()->count() === 1;
}

public function hasLocations()
Expand All @@ -127,7 +122,14 @@ public function hasLocations()
if ($this->getAuth()->isSuperUser())
return TRUE;

return $this->getAuth()->locations()->count() > 1;
return $this->getLocations()->count() > 1;
}

protected function getLocations()
{
return $this->getAuth()
->locations()
->where('location_status', TRUE);
}

/**
Expand All @@ -143,7 +145,7 @@ protected function isAttachedToAuth($id)
if ($this->getAuth()->isSuperUser())
return TRUE;

return $this->getAuth()->locations()->contains(function ($model) use ($id) {
return $this->getLocations()->contains(function ($model) use ($id) {
return $model->location_id === $id;
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/classes/ScheduleItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct($name, array $data = [])
{
$this->name = $name;
$this->type = array_get($data, 'type', '24_7');
$this->days = array_get($data, 'days', []);
$this->days = array_get($data, 'days') ?: [];
$this->open = array_get($data, 'open', '00:00');
$this->close = array_get($data, 'close', '23:59');
$this->timesheet = $this->timesheet(array_get($data, 'timesheet', []));
Expand Down
13 changes: 10 additions & 3 deletions app/admin/formwidgets/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ class Connector extends BaseFormWidget
*/
public $sortable = FALSE;

/**
* @var bool Items can be edited.
*/
public $editable = TRUE;

public $popupSize;

public function initialize()
Expand All @@ -68,6 +73,7 @@ public function initialize()
'formName',
'form',
'prompt',
'editable',
'sortable',
'nameFrom',
'descriptionFrom',
Expand Down Expand Up @@ -112,6 +118,7 @@ public function prepareVars()
$this->vars['fieldItems'] = $this->processLoadValue() ?? [];

$this->vars['prompt'] = $this->prompt;
$this->vars['editable'] = $this->editable;
$this->vars['sortable'] = $this->sortable;
$this->vars['nameFrom'] = $this->nameFrom;
$this->vars['partial'] = $this->partial;
Expand Down Expand Up @@ -211,15 +218,15 @@ protected function processSaveValue($value)
$sortedIndexes = (array)post($this->sortableInputName);
$sortedIndexes = array_flip($sortedIndexes);

$value = [];
$results = [];
foreach ($items as $index => $item) {
$value[$index] = [
$results[$index] = [
$item->getKeyName() => $item->getKey(),
$this->sortColumnName => $sortedIndexes[$item->getKey()],
];
}

return $value;
return $results;
}

protected function makeItemFormWidget($model, $context)
Expand Down
2 changes: 1 addition & 1 deletion app/admin/formwidgets/DatePicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function loadAssets()
$this->addCss('vendor/datepicker/bootstrap-datepicker.min.css', 'bootstrap-datepicker-css');
$this->addJs('vendor/datepicker/bootstrap-datepicker.min.js', 'bootstrap-datepicker-js');
if (setting('default_language') != 'en')
$this->addJs('vendor/datepicker/bootstrap-datepicker/locales/bootstrap-datepicker.'.strtolower(str_replace('_', '-', setting('default_language'))).'.min.js', 'bootstrap-datepicker-js');
$this->addJs('vendor/datepicker/locales/bootstrap-datepicker.'.strtolower(str_replace('_', '-', setting('default_language'))).'.min.js', 'bootstrap-datepicker-js');
$this->addCss('css/datepicker.css', 'datepicker-css');
$this->addJs('js/datepicker.js', 'datepicker-js');
}
Expand Down
2 changes: 1 addition & 1 deletion app/admin/formwidgets/RecordEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function initialize()
'modelClass',
'addonLeft',
'addonRight',
'hideAddButton',
'hideCreateButton',
'hideEditButton',
'hideDeleteButton',
'addLabel',
Expand Down
23 changes: 1 addition & 22 deletions app/admin/formwidgets/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

use Admin\Classes\BaseFormWidget;
use Admin\Classes\FormField;
use Admin\Facades\AdminLocation;
use Admin\Traits\LocationAwareWidget;
use DB;
use Exception;
use Igniter\Flame\Location\Models\AbstractLocation;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation as RelationBase;

Expand Down Expand Up @@ -75,6 +73,7 @@ public function initialize()
'relationFrom',
'nameFrom',
'emptyOption',
'scope',
]);

if (isset($this->config['select'])) {
Expand All @@ -95,8 +94,6 @@ public function getSaveValue($value)
return FormField::NO_SAVE_DATA;
}

$value = $this->processSaveValue($value);

if (is_string($value) && !strlen($value)) {
return null;
}
Expand Down Expand Up @@ -223,22 +220,4 @@ protected function getRelationObject()

return $model->{$attribute}();
}

protected function processSaveValue($value)
{
if ($value)
return $value;

[$model, $attribute] = $this->resolveModelAttribute($this->valueFrom);
$relatedModel = $model->makeRelation($attribute);

if (!$relatedModel instanceof AbstractLocation OR !AdminLocation::hasOneLocation())
return $value;

$relationType = $model->getRelationType($attribute);

return in_array($relationType, ['belongsTo', 'hasOne'])
? AdminLocation::getId()
: [AdminLocation::getId()];
}
}
7 changes: 5 additions & 2 deletions app/admin/formwidgets/connector/assets/js/connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

Connector.DEFAULTS = {
alias: undefined,
editable: true,
sortableHandle: '.connector-item-handle',
sortableContainer: '.field-connector-items',
}

Connector.prototype.init = function () {
this.$el.on('click', '[data-control="load-item"]', $.proxy(this.onLoadItem, this))
if (this.options.editable)
this.$el.on('click', '[data-control="load-item"]', $.proxy(this.onLoadItem, this))

this.$el.on('click', '[data-control="delete-item"]', $.proxy(this.onDeleteItem, this))

this.bindSorting()
Expand Down Expand Up @@ -108,4 +111,4 @@
$('[data-control="connector"]', document).connector()
});

}(window.jQuery);
}(window.jQuery);
1 change: 1 addition & 0 deletions app/admin/formwidgets/connector/connector.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class="field-connector"
data-alias="{{ $this->alias }}"
data-sortable-container="#{{ $this->getId('items') }}"
data-sortable-handle=".{{ $this->getId('items') }}-handle"
data-editable="{{ $editable ? 'true' : 'false' }}"
>
<div
id="{{ $this->getId('items') }}"
Expand Down
3 changes: 2 additions & 1 deletion app/admin/formwidgets/maparea/assets/js/maparea.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
handle: this.options.sortableHandle,
}

this.$sortable = Sortable.create(this.$sortableContainer.get(0), sortableOptions)
if (this.$sortableContainer.get(0))
this.$sortable = Sortable.create(this.$sortableContainer.get(0), sortableOptions)
}

MapArea.prototype.onModalShown = function (event, $modalEl) {
Expand Down
3 changes: 2 additions & 1 deletion app/admin/formwidgets/repeater/assets/js/repeater.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
fallbackClass: "sortable-fallback", // Class name for the cloned DOM Element when using forceFallback
}

this.$sortable = Sortable.create(this.$sortableContainer.get(0), sortableOptions)
if (this.$sortableContainer.get(0))
this.$sortable = Sortable.create(this.$sortableContainer.get(0), sortableOptions)
}

Repeater.prototype.unbind = function () {
Expand Down
2 changes: 1 addition & 1 deletion app/admin/language/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@
'label_delivery_condition' => 'Delivery Condition',

'error_no_zero_total' => 'The %s can not be a value zero on conditions other than \'on all orders\'.',
'alert_delivery_area' => 'Add at least one delivery area to allow your customers to find this location.',
'alert_delivery_area' => 'Add at least one delivery area to allow your customers find this location.',
'alert_set_default' => 'Location set as default',
'alert_missing_map_center' => 'Map is missing center coordinates, please enter an address then click save.',
'alert_missing_map_config' => 'Missing Google Maps Javascript Library, please provide your maps api key on the general system settings page.',
Expand Down
3 changes: 3 additions & 0 deletions app/admin/models/Menus_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ public function isAvailable($datetime = null)
}
}

if (is_bool($eventResults = $this->fireSystemEvent('admin.menu.isAvailable', [$datetime, $isAvailable], TRUE)))
$isAvailable = $eventResults;

return $isAvailable;
}
}
Loading

0 comments on commit 03cd0b1

Please sign in to comment.