From ba227b3d1be7afba5724784ae6f9efe397f8f683 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:38:07 +0100 Subject: [PATCH 01/23] Simplify locationAware config value to boolean --- app/admin/actions/LocationAwareController.php | 2 +- app/admin/models/config/categories_model.php | 4 ++-- app/admin/models/config/mealtimes_model.php | 4 ++-- app/admin/models/config/menus_model.php | 5 +++-- app/admin/models/config/orders_model.php | 4 ++-- app/admin/models/config/reservations_model.php | 4 ++-- app/admin/models/config/staffs_model.php | 4 ++-- app/admin/models/config/tables_model.php | 4 ++-- app/admin/traits/LocationAwareWidget.php | 10 ++-------- 9 files changed, 18 insertions(+), 23 deletions(-) diff --git a/app/admin/actions/LocationAwareController.php b/app/admin/actions/LocationAwareController.php index 48cb7454cf..2eff24a253 100644 --- a/app/admin/actions/LocationAwareController.php +++ b/app/admin/actions/LocationAwareController.php @@ -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); }); diff --git a/app/admin/models/config/categories_model.php b/app/admin/models/config/categories_model.php index e7823ad03d..c4f6d7e74d 100644 --- a/app/admin/models/config/categories_model.php +++ b/app/admin/models/config/categories_model.php @@ -11,7 +11,7 @@ 'scope' => 'whereHasLocation', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'status' => [ 'label' => 'lang:admin::lang.text_filter_status', @@ -64,7 +64,7 @@ 'type' => 'text', 'relation' => 'locations', 'select' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, 'invisible' => TRUE, ], 'priority' => [ diff --git a/app/admin/models/config/mealtimes_model.php b/app/admin/models/config/mealtimes_model.php index c41bcb7372..91ed8ef240 100644 --- a/app/admin/models/config/mealtimes_model.php +++ b/app/admin/models/config/mealtimes_model.php @@ -7,7 +7,7 @@ 'scope' => 'whereHasLocation', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'status' => [ 'label' => 'lang:admin::lang.text_filter_status', @@ -70,7 +70,7 @@ 'type' => 'text', 'relation' => 'locations', 'select' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, 'invisible' => TRUE, ], ]; diff --git a/app/admin/models/config/menus_model.php b/app/admin/models/config/menus_model.php index 33dd68c91c..247bab492a 100644 --- a/app/admin/models/config/menus_model.php +++ b/app/admin/models/config/menus_model.php @@ -11,7 +11,7 @@ 'scope' => 'whereHasLocation', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'category' => [ 'label' => 'lang:admin::lang.menus.text_filter_category', @@ -78,7 +78,7 @@ 'relation' => 'locations', 'select' => 'location_name', 'invisible' => TRUE, - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'menu_price' => [ 'label' => 'lang:admin::lang.menus.column_price', @@ -180,6 +180,7 @@ 'span' => 'right', 'valueFrom' => 'locations', 'nameFrom' => 'location_name', + 'scope' => 'isEnabled', ], 'minimum_qty' => [ 'label' => 'lang:admin::lang.menus.label_minimum_qty', diff --git a/app/admin/models/config/orders_model.php b/app/admin/models/config/orders_model.php index a750f9f422..3a1663131d 100644 --- a/app/admin/models/config/orders_model.php +++ b/app/admin/models/config/orders_model.php @@ -21,7 +21,7 @@ 'conditions' => 'location_id = :filtered', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'status' => [ 'label' => 'lang:admin::lang.text_filter_status', @@ -85,7 +85,7 @@ 'relation' => 'location', 'select' => 'location_name', 'searchable' => TRUE, - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'full_name' => [ 'label' => 'lang:admin::lang.orders.column_customer_name', diff --git a/app/admin/models/config/reservations_model.php b/app/admin/models/config/reservations_model.php index d5696d5dd6..5b4c182f28 100644 --- a/app/admin/models/config/reservations_model.php +++ b/app/admin/models/config/reservations_model.php @@ -21,7 +21,7 @@ 'conditions' => 'location_id = :filtered', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'status' => [ 'label' => 'lang:admin::lang.text_filter_status', @@ -81,7 +81,7 @@ 'relation' => 'location', 'select' => 'location_name', 'searchable' => TRUE, - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'full_name' => [ 'label' => 'lang:admin::lang.label_name', diff --git a/app/admin/models/config/staffs_model.php b/app/admin/models/config/staffs_model.php index 4d3ee8431a..b3b4f14f7f 100644 --- a/app/admin/models/config/staffs_model.php +++ b/app/admin/models/config/staffs_model.php @@ -11,7 +11,7 @@ 'scope' => 'whereHasLocation', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'role' => [ 'label' => 'lang:admin::lang.staff.text_filter_role', @@ -95,7 +95,7 @@ 'relation' => 'locations', 'select' => 'location_name', 'searchable' => TRUE, - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'last_login' => [ 'label' => 'lang:admin::lang.staff.column_last_login', diff --git a/app/admin/models/config/tables_model.php b/app/admin/models/config/tables_model.php index 51f18de441..27a2155629 100644 --- a/app/admin/models/config/tables_model.php +++ b/app/admin/models/config/tables_model.php @@ -11,7 +11,7 @@ 'scope' => 'whereHasLocation', 'modelClass' => 'Admin\Models\Locations_model', 'nameFrom' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'status' => [ 'label' => 'lang:admin::lang.text_filter_status', @@ -78,7 +78,7 @@ 'type' => 'text', 'relation' => 'locations', 'select' => 'location_name', - 'locationAware' => 'hide', + 'locationAware' => TRUE, ], 'is_joinable' => [ 'label' => 'lang:admin::lang.tables.label_joinable', diff --git a/app/admin/traits/LocationAwareWidget.php b/app/admin/traits/LocationAwareWidget.php index 761eb0a437..6156d5c69d 100644 --- a/app/admin/traits/LocationAwareWidget.php +++ b/app/admin/traits/LocationAwareWidget.php @@ -4,20 +4,14 @@ use Admin\Facades\AdminLocation; use Admin\Models\Locations_model; -use Exception; trait LocationAwareWidget { protected function isLocationAware($config) { - $locationAware = $config['locationAware'] ?? 'skip'; - if (!in_array($locationAware, ['skip', 'show', 'hide'])) - throw new Exception('Valid values for [locationAware] property are (none,show,hide)'); + $locationAware = $config['locationAware'] ?? FALSE; - if ($this->controller->getUserLocation()) - return $locationAware == 'hide'; - - return $locationAware == 'show'; + return $locationAware AND $this->controller->getUserLocation(); } /** From f5006ff39f7a3745f895e48bead9a67e3b959df9 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sat, 12 Jun 2021 11:18:17 +0100 Subject: [PATCH 02/23] Revert "After menu create check if we have locations, and if not attach current (#759)" This reverts commit b29c02f39d7b0a37c2b3a8d39ddfed6fdc85f0c0. --- app/admin/formwidgets/Relation.php | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/app/admin/formwidgets/Relation.php b/app/admin/formwidgets/Relation.php index 92567f5026..1474b20a91 100644 --- a/app/admin/formwidgets/Relation.php +++ b/app/admin/formwidgets/Relation.php @@ -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; @@ -95,8 +93,6 @@ public function getSaveValue($value) return FormField::NO_SAVE_DATA; } - $value = $this->processSaveValue($value); - if (is_string($value) && !strlen($value)) { return null; } @@ -223,22 +219,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()]; - } } From ebc04cac62dd32585c2ebbaf4507a543037da36d Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:47:03 +0100 Subject: [PATCH 03/23] Minor refactor --- app/admin/classes/Location.php | 24 +++++++++++++----------- app/admin/formwidgets/Relation.php | 1 + app/admin/traits/Locationable.php | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/app/admin/classes/Location.php b/app/admin/classes/Location.php index 918eada147..52aed8212a 100644 --- a/app/admin/classes/Location.php +++ b/app/admin/classes/Location.php @@ -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() @@ -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(); @@ -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() @@ -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); } /** @@ -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; }); } diff --git a/app/admin/formwidgets/Relation.php b/app/admin/formwidgets/Relation.php index 1474b20a91..f30209a928 100644 --- a/app/admin/formwidgets/Relation.php +++ b/app/admin/formwidgets/Relation.php @@ -73,6 +73,7 @@ public function initialize() 'relationFrom', 'nameFrom', 'emptyOption', + 'scope', ]); if (isset($this->config['select'])) { diff --git a/app/admin/traits/Locationable.php b/app/admin/traits/Locationable.php index e7115ca3d0..3ca2687335 100644 --- a/app/admin/traits/Locationable.php +++ b/app/admin/traits/Locationable.php @@ -137,6 +137,6 @@ protected function locationableRelationExists() return !is_null($this->{$relationName}); } - return count($this->{$relationName}); + return count($this->{$relationName}) > 0; } } From 79c6216076ef72e1e1a5fee3f6e02aebd6f656b2 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 25 Jun 2021 21:53:53 +0100 Subject: [PATCH 04/23] Loose locationable constraints to include records not attached to a location --- app/admin/actions/LocationAwareController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/actions/LocationAwareController.php b/app/admin/actions/LocationAwareController.php index 2eff24a253..34b0876576 100644 --- a/app/admin/actions/LocationAwareController.php +++ b/app/admin/actions/LocationAwareController.php @@ -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); } From d731f4e3376b27c27d3428c48ffac314f91b7f31 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Fri, 2 Jul 2021 08:41:57 +0100 Subject: [PATCH 05/23] Set orders_model appends attributes #816 Signed-off-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/models/Orders_model.php | 2 ++ app/admin/models/Reservations_model.php | 2 ++ app/admin/traits/LogsStatusHistory.php | 2 ++ 3 files changed, 6 insertions(+) diff --git a/app/admin/models/Orders_model.php b/app/admin/models/Orders_model.php index ccfba8c8c6..41c1f5d563 100644 --- a/app/admin/models/Orders_model.php +++ b/app/admin/models/Orders_model.php @@ -56,6 +56,8 @@ class Orders_model extends Model */ public $timestamps = TRUE; + public $appends = ['customer_name', 'order_type_name', 'formatted_address']; + protected $casts = [ 'customer_id' => 'integer', 'location_id' => 'integer', diff --git a/app/admin/models/Reservations_model.php b/app/admin/models/Reservations_model.php index 6e551e8426..40c360e514 100644 --- a/app/admin/models/Reservations_model.php +++ b/app/admin/models/Reservations_model.php @@ -78,6 +78,8 @@ class Reservations_model extends Model protected $purgeable = ['tables']; + public $appends = ['customer_name', 'duration', 'table_name']; + public static $allowedSortingColumns = [ 'reservation_id asc', 'reservation_id desc', 'reserve_date asc', 'reserve_date desc', diff --git a/app/admin/traits/LogsStatusHistory.php b/app/admin/traits/LogsStatusHistory.php index 83882bb485..093fc4cbc6 100644 --- a/app/admin/traits/LogsStatusHistory.php +++ b/app/admin/traits/LogsStatusHistory.php @@ -17,6 +17,8 @@ public static function bootLogsStatusHistory() 'Admin\Models\Status_history_model', 'name' => 'object', 'delete' => TRUE, ]; + $model->appends[] = 'status_name'; + $model->addCasts([ 'status_id' => 'integer', 'status_updated_at' => 'dateTime', From 79c64c50f8532744b8f8cd03e4bd02d8e268a670 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sun, 4 Jul 2021 19:21:24 +0100 Subject: [PATCH 06/23] Fix Time Restriction must be integer prevent save if Pre-Order is enabled. (#808) remove disable triggers make nullable rule Co-authored-by: Sam Poyigi Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/models/config/locations_model.php | 10 ---------- app/admin/requests/Location.php | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/app/admin/models/config/locations_model.php b/app/admin/models/config/locations_model.php index 26c66d1bd6..8f22e32fc0 100644 --- a/app/admin/models/config/locations_model.php +++ b/app/admin/models/config/locations_model.php @@ -314,11 +314,6 @@ 'lang:admin::lang.locations.text_asap_only', 'lang:admin::lang.locations.text_later_only', ], - 'trigger' => [ - 'action' => 'disable', - 'field' => 'options[future_orders][enable_delivery]', - 'condition' => 'checked', - ], ], 'collection_order' => [ @@ -394,11 +389,6 @@ 'lang:admin::lang.locations.text_asap_only', 'lang:admin::lang.locations.text_later_only', ], - 'trigger' => [ - 'action' => 'disable', - 'field' => 'options[future_orders][enable_collection]', - 'condition' => 'checked', - ], ], 'reservation' => [ diff --git a/app/admin/requests/Location.php b/app/admin/requests/Location.php index 4956a14dba..267f3affa9 100644 --- a/app/admin/requests/Location.php +++ b/app/admin/requests/Location.php @@ -35,8 +35,8 @@ public function rules() ['options.future_orders.enable_collection', 'admin::lang.locations.label_future_collection_order', 'boolean'], ['options.future_orders.delivery_days', 'admin::lang.locations.label_future_delivery_days', 'integer'], ['options.future_orders.collection_days', 'admin::lang.locations.label_future_collection_days', 'integer'], - ['options.delivery_time_restriction', 'admin::lang.locations.label_delivery_time_restriction', 'integer|max:2'], - ['options.collection_time_restriction', 'admin::lang.locations.label_collection_time_restriction', 'integer|max:2'], + ['options.delivery_time_restriction', 'admin::lang.locations.label_delivery_time_restriction', 'nullable|integer|max:2'], + ['options.collection_time_restriction', 'admin::lang.locations.label_collection_time_restriction', 'nullable|integer|max:2'], ['options.payments.*', 'admin::lang.locations.label_payments'], ['options.reservation_time_interval', 'admin::lang.locations.label_reservation_time_interval|min:5', 'integer'], ['options.reservation_lead_time', 'admin::lang.locations.label_reservation_lead_time|min:5', 'integer'], From a3f43c0df7c4489ddc253b93a92a142d34bad11c Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sun, 4 Jul 2021 19:33:39 +0100 Subject: [PATCH 07/23] Update recordeditor hideCreateButton config name (#810) Incorrectly named Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/formwidgets/RecordEditor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/formwidgets/RecordEditor.php b/app/admin/formwidgets/RecordEditor.php index 8e0a21601c..ce6ccac4df 100644 --- a/app/admin/formwidgets/RecordEditor.php +++ b/app/admin/formwidgets/RecordEditor.php @@ -56,7 +56,7 @@ public function initialize() 'modelClass', 'addonLeft', 'addonRight', - 'hideAddButton', + 'hideCreateButton', 'hideEditButton', 'hideDeleteButton', 'addLabel', From 1d7c326246a31570c67cb5a4195daf8bd1bc3ed7 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Sun, 4 Jul 2021 19:49:38 +0100 Subject: [PATCH 08/23] Fix can't save schedule with no delivery-plan #809 --- app/admin/classes/ScheduleItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/classes/ScheduleItem.php b/app/admin/classes/ScheduleItem.php index 7d6df391c0..adb4e8e2d1 100644 --- a/app/admin/classes/ScheduleItem.php +++ b/app/admin/classes/ScheduleItem.php @@ -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', [])); From 35f900055b40c7d32625591462c9a5d0ab69755e Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sun, 4 Jul 2021 20:01:44 +0100 Subject: [PATCH 09/23] Use start/end of day on charts (#820) Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/traits/HasChartDatasets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/traits/HasChartDatasets.php b/app/admin/traits/HasChartDatasets.php index 183ba972f4..d500d9910f 100644 --- a/app/admin/traits/HasChartDatasets.php +++ b/app/admin/traits/HasChartDatasets.php @@ -79,9 +79,9 @@ protected function queryDatasets($config, $start, $end) protected function getDatePeriod($start, $end) { return new DatePeriod( - Carbon::parse($start), + Carbon::parse($start)->startOfDay(), new DateInterval('P1D'), - Carbon::parse($end) + Carbon::parse($end)->endOfDay() ); } From 2a32cbac1038b006bfec719e5211da813a5347a6 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sun, 4 Jul 2021 20:04:27 +0100 Subject: [PATCH 10/23] Fix 802 (#803) * Fix working day display * StyleCI * Set start of week * refactor Co-authored-by: Sam Poyigi Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/models/Working_hours_model.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/admin/models/Working_hours_model.php b/app/admin/models/Working_hours_model.php index 33df4780f3..526b93804e 100644 --- a/app/admin/models/Working_hours_model.php +++ b/app/admin/models/Working_hours_model.php @@ -49,9 +49,9 @@ public function parseRecord($row) public function getWeekDaysOptions() { - return array_map(function ($day) { - return now()->setDay($day)->isoFormat(lang('system::lang.moment.weekday_format')); - }, self::$weekDays); + return collect(self::$weekDays)->map(function ($day, $index) { + return now()->startOfWeek()->setDay($index)->isoFormat(lang('system::lang.moment.weekday_format')); + })->all(); } public function getTimesheetOptions($value, $data) From 93d353f380a4fb69721e3fec4dbe4851929e3185 Mon Sep 17 00:00:00 2001 From: Arif Iqbal Date: Mon, 5 Jul 2021 00:13:16 +0500 Subject: [PATCH 11/23] Fixed link to Contributing Guidelines page on readme.md (#821) Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b419fcf3ac..6e4dcbf60f 100644 --- a/README.md +++ b/README.md @@ -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! From abe016a98d5474563798ec2ee8d3843f9b53795b Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Sun, 4 Jul 2021 20:15:55 +0100 Subject: [PATCH 12/23] Add canEdit to connector modal (#812) * Add canEdit to connector modal * Apply logic through Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/formwidgets/Connector.php | 2 ++ app/admin/formwidgets/connector/assets/js/connector.js | 6 ++++-- app/admin/formwidgets/connector/connector.blade.php | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/admin/formwidgets/Connector.php b/app/admin/formwidgets/Connector.php index 08063dd5c3..01f77e99d1 100644 --- a/app/admin/formwidgets/Connector.php +++ b/app/admin/formwidgets/Connector.php @@ -73,6 +73,7 @@ public function initialize() 'descriptionFrom', 'partial', 'popupSize', + 'canEdit', ]); $fieldName = $this->formField->getName(FALSE); @@ -117,6 +118,7 @@ public function prepareVars() $this->vars['partial'] = $this->partial; $this->vars['descriptionFrom'] = $this->descriptionFrom; $this->vars['sortableInputName'] = $this->sortableInputName; + $this->vars['canEdit'] = $this->canEdit ?? true; } public function onLoadRecord() diff --git a/app/admin/formwidgets/connector/assets/js/connector.js b/app/admin/formwidgets/connector/assets/js/connector.js index d83c571ccf..a4358ce5ce 100644 --- a/app/admin/formwidgets/connector/assets/js/connector.js +++ b/app/admin/formwidgets/connector/assets/js/connector.js @@ -21,7 +21,9 @@ } Connector.prototype.init = function () { - this.$el.on('click', '[data-control="load-item"]', $.proxy(this.onLoadItem, this)) + if (this.options.canEdit) + 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() @@ -108,4 +110,4 @@ $('[data-control="connector"]', document).connector() }); -}(window.jQuery); \ No newline at end of file +}(window.jQuery); diff --git a/app/admin/formwidgets/connector/connector.blade.php b/app/admin/formwidgets/connector/connector.blade.php index 2534379954..94404001d3 100644 --- a/app/admin/formwidgets/connector/connector.blade.php +++ b/app/admin/formwidgets/connector/connector.blade.php @@ -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="{{ $canEdit }}" >
Date: Sun, 4 Jul 2021 20:30:42 +0100 Subject: [PATCH 13/23] Add isAvailable event for extendability (#811) * Add isAvailable event for extendability * Missing bracket * refactor * rename to afterIsAvailable * Leave as isAvailable Co-authored-by: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> --- app/admin/models/Menus_model.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/admin/models/Menus_model.php b/app/admin/models/Menus_model.php index defdab891f..4520b470ce 100644 --- a/app/admin/models/Menus_model.php +++ b/app/admin/models/Menus_model.php @@ -349,6 +349,9 @@ public function isAvailable($datetime = null) } } + if (!is_null($eventResults = $this->fireSystemEvent('admin.menu.isAvailable', [$datetime, $isAvailable], TRUE))) + $isAvailable = (bool)$eventResults; + return $isAvailable; } } From b569aef05a3dc33f4c43c9e9ce9e928377dd39b1 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Sun, 4 Jul 2021 20:40:05 +0100 Subject: [PATCH 14/23] Minor UI adjustments --- app/admin/assets/css/admin.css | 13 +++++++++++++ .../assets/scss/components/_button-group.scss | 16 ++++++++++++++++ app/admin/assets/scss/components/_select.scss | 1 + 3 files changed, 30 insertions(+) diff --git a/app/admin/assets/css/admin.css b/app/admin/assets/css/admin.css index 13159f425c..ae0e8ccb90 100755 --- a/app/admin/assets/css/admin.css +++ b/app/admin/assets/css/admin.css @@ -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; @@ -17657,6 +17669,7 @@ body.dragging .dragged { } .select2-results__option { border-radius: 3px; + margin-bottom: 0.3rem; } .sidebar { position: fixed; diff --git a/app/admin/assets/scss/components/_button-group.scss b/app/admin/assets/scss/components/_button-group.scss index 57a004aa9c..4f26235880 100644 --- a/app/admin/assets/scss/components/_button-group.scss +++ b/app/admin/assets/scss/components/_button-group.scss @@ -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); + } } } diff --git a/app/admin/assets/scss/components/_select.scss b/app/admin/assets/scss/components/_select.scss index 1139f68ca8..ac161ae29d 100644 --- a/app/admin/assets/scss/components/_select.scss +++ b/app/admin/assets/scss/components/_select.scss @@ -62,4 +62,5 @@ } .select2-results__option { border-radius: $input-border-radius; + margin-bottom: .3rem; } From d45932038fc20f0f032874e9c6a0c3b2c22b55ad Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Sun, 4 Jul 2021 20:43:51 +0100 Subject: [PATCH 15/23] Use absolute path on UpdateManager::extractFile method --- app/system/classes/UpdateManager.php | 7 +++---- app/system/console/commands/ExtensionInstall.php | 2 +- app/system/console/commands/IgniterUpdate.php | 3 ++- app/system/console/commands/ThemeInstall.php | 2 +- app/system/controllers/Updates.php | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/system/classes/UpdateManager.php b/app/system/classes/UpdateManager.php index 435bb4dd74..9a102f2aef 100644 --- a/app/system/classes/UpdateManager.php +++ b/app/system/classes/UpdateManager.php @@ -507,12 +507,11 @@ public function extractCore($fileCode) return $result; } - public function extractFile($fileCode, $directory = null) + public function extractFile($fileCode, $extractTo = null) { $filePath = $this->getFilePath($fileCode); - $extractTo = base_path(); - if ($directory) - $extractTo .= '/'.$directory.str_replace('.', '/', $fileCode); + if ($extractTo) + $extractTo .= '/'.str_replace('.', '/', $fileCode); if (!file_exists($extractTo)) mkdir($extractTo, 0777, TRUE); diff --git a/app/system/console/commands/ExtensionInstall.php b/app/system/console/commands/ExtensionInstall.php index da65d3df13..410ff4f6ad 100644 --- a/app/system/console/commands/ExtensionInstall.php +++ b/app/system/console/commands/ExtensionInstall.php @@ -49,7 +49,7 @@ public function handle() ]); $this->output->writeln(sprintf('Extracting extension %s files', $code)); - $manager->extractFile($code, 'extensions/'); + $manager->extractFile($code, extension_path('/')); $this->output->writeln(sprintf('Installing %s extension', $code)); ExtensionManager::instance()->loadExtensions(); diff --git a/app/system/console/commands/IgniterUpdate.php b/app/system/console/commands/IgniterUpdate.php index a34453a665..bc324ff3d0 100644 --- a/app/system/console/commands/IgniterUpdate.php +++ b/app/system/console/commands/IgniterUpdate.php @@ -91,7 +91,8 @@ public function handle() $this->output->writeln(sprintf('Extracting %s files', $addonName)); - $updateManager->extractFile($addonCode, $addonType.'s/'); + $extractTo = $addonType === 'theme' ? theme_path('/') : extension_path('/'); + $updateManager->extractFile($addonCode, $extractTo); }); // Run migrations diff --git a/app/system/console/commands/ThemeInstall.php b/app/system/console/commands/ThemeInstall.php index a6e89bc359..65aad65d7a 100644 --- a/app/system/console/commands/ThemeInstall.php +++ b/app/system/console/commands/ThemeInstall.php @@ -48,7 +48,7 @@ public function handle() ]); $this->output->writeln(sprintf('Extracting theme %s files', $code)); - $manager->extractFile($code, 'themes/'); + $manager->extractFile($code, theme_path('/')); $this->output->writeln(sprintf('Installing %s theme', $code)); ThemeManager::instance()->loadThemes(); diff --git a/app/system/controllers/Updates.php b/app/system/controllers/Updates.php index 11304c9137..b78c4c8b7d 100644 --- a/app/system/controllers/Updates.php +++ b/app/system/controllers/Updates.php @@ -325,11 +325,11 @@ protected function processInstallOrUpdate() break; case 'extractExtension': - $response = $updateManager->extractFile($meta['code'], 'extensions/'); + $response = $updateManager->extractFile($meta['code'], extension_path('/')); if ($response) $json['result'] = 'success'; break; case 'extractTheme': - $response = $updateManager->extractFile($meta['code'], 'themes/'); + $response = $updateManager->extractFile($meta['code'], theme_path('/')); if ($response) $json['result'] = 'success'; break; From 75ce2608e790fd4f47eb06fcaf664fb5461d1930 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Sun, 4 Jul 2021 20:44:39 +0100 Subject: [PATCH 16/23] Make locationable methods public --- app/admin/traits/Locationable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/admin/traits/Locationable.php b/app/admin/traits/Locationable.php index 3ca2687335..ca9634c3c0 100644 --- a/app/admin/traits/Locationable.php +++ b/app/admin/traits/Locationable.php @@ -117,19 +117,19 @@ protected function getLocationableRelationObject() return $this->{$relationName}(); } - protected function locationableIsSingleRelationType() + public function locationableIsSingleRelationType() { $relationType = $this->getRelationType($this->locationableRelationName()); return in_array($relationType, ['hasOne', 'belongsTo']); } - protected function locationableRelationName() + public function locationableRelationName() { return defined('static::LOCATIONABLE_RELATION') ? static::LOCATIONABLE_RELATION : 'location'; } - protected function locationableRelationExists() + public function locationableRelationExists() { $relationName = $this->locationableRelationName(); From ba31bfd8f3a3456133adc403a17a152c9667ea89 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 5 Jul 2021 10:50:59 +0100 Subject: [PATCH 17/23] Start weekdays on monday --- app/admin/models/Working_hours_model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/models/Working_hours_model.php b/app/admin/models/Working_hours_model.php index 526b93804e..a5ddd2d839 100644 --- a/app/admin/models/Working_hours_model.php +++ b/app/admin/models/Working_hours_model.php @@ -50,7 +50,7 @@ public function parseRecord($row) public function getWeekDaysOptions() { return collect(self::$weekDays)->map(function ($day, $index) { - return now()->startOfWeek()->setDay($index)->isoFormat(lang('system::lang.moment.weekday_format')); + return now()->startOfWeek()->addDays($index)->isoFormat(lang('system::lang.moment.weekday_format')); })->all(); } From af08f08ae5f118b28842d779ebfdfd75e2d4b1ff Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:49:06 +0100 Subject: [PATCH 18/23] Read extension manifest from composer.json --- app/system/classes/BaseExtension.php | 27 +++++++++++++++++++++--- app/system/classes/ExtensionManager.php | 28 ++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/app/system/classes/BaseExtension.php b/app/system/classes/BaseExtension.php index 881b68a7bb..28a8d65061 100644 --- a/app/system/classes/BaseExtension.php +++ b/app/system/classes/BaseExtension.php @@ -175,13 +175,18 @@ protected function getConfigFromFile() $className = get_class($this); $configPath = realpath(dirname(File::fromClass($className))); - $configFile = $configPath.'/extension.json'; - if (!File::exists($configFile)) + if (File::exists($configFile = $configPath.'/extension.json')) { + $config = json_decode(File::get($configFile), TRUE) ?? []; + } + elseif (File::exists($configFile = $configPath.'/composer.json')) { + $config = $this->getConfigFromComposerJson($configFile); + } + else { throw new SystemException("The configuration file for extension {$className} does not exist. ". 'Create the file or override extensionMeta() method in the extension class.'); + } - $config = json_decode(File::get($configFile), TRUE) ?? []; foreach (['code', 'name', 'description', 'author', 'icon'] as $item) { if (!array_key_exists($item, $config)) { throw new SystemException(sprintf( @@ -193,4 +198,20 @@ protected function getConfigFromFile() return $this->config = $config; } + + protected function getConfigFromComposerJson($configFile) + { + $composer = json_decode(File::get($configFile), TRUE) ?? []; + + if (!$config = array_get($composer, 'extra.tastyigniter-extension', [])) + return $config; + + if ($description = array_get($composer, 'description')) + $config['description'] = $description; + + if ($author = array_get($composer, 'author')) + $config['author'] = $author; + + return $config; + } } diff --git a/app/system/classes/ExtensionManager.php b/app/system/classes/ExtensionManager.php index f22c4752e9..e12de8dd08 100644 --- a/app/system/classes/ExtensionManager.php +++ b/app/system/classes/ExtensionManager.php @@ -758,7 +758,7 @@ public function installExtension($code, $version = null) // set extension migration to the latest version UpdateManager::instance()->migrateExtension($model->name); - $model->version = $version ?? $model->version; + $model->version = $version ?? $this->getComposerInstalledVersion($extension) ?? $model->version; $model->save(); $this->updateInstalledExtensions($model->name); @@ -822,4 +822,30 @@ protected function mergeConfigFrom(string $namespace, string $path) )); } } + + protected function getComposerInstalledVersion($extension) + { + if (!$extensionCode = array_get($extension->extensionMeta(), 'code')) + return null; + + if (!File::exists(sprintf('%s/composer.json', $this->path($extensionCode)))) + return null; + + if (!File::exists($path = base_path('/vendor/composer/installed.json'))) + return null; + + $installed = json_decode(File::get($path), TRUE); + + // Structure of the installed.json manifest in different in Composer 2.0 + $installed = $installed['packages'] ?? $installed; + + $package = collect($installed)->first(function ($package) use ($extensionCode) { + if (array_get($package, 'type') !== 'tastyigniter-extension') + return FALSE; + + return array_get($package, 'extra.tastyigniter-extension.code') === $extensionCode; + }); + + return array_get($package ?? [], 'version'); + } } From 2cf844eea46ed26a1483cda640d0111fa636241f Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 5 Jul 2021 11:57:14 +0100 Subject: [PATCH 19/23] Minor fix --- app/admin/models/Menus_model.php | 4 ++-- app/admin/models/Orders_model.php | 16 +++++++++++++++- app/system/language/en/lang.php | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/admin/models/Menus_model.php b/app/admin/models/Menus_model.php index 4520b470ce..337f21d345 100644 --- a/app/admin/models/Menus_model.php +++ b/app/admin/models/Menus_model.php @@ -349,8 +349,8 @@ public function isAvailable($datetime = null) } } - if (!is_null($eventResults = $this->fireSystemEvent('admin.menu.isAvailable', [$datetime, $isAvailable], TRUE))) - $isAvailable = (bool)$eventResults; + if (is_bool($eventResults = $this->fireSystemEvent('admin.menu.isAvailable', [$datetime, $isAvailable], TRUE))) + $isAvailable = $eventResults; return $isAvailable; } diff --git a/app/admin/models/Orders_model.php b/app/admin/models/Orders_model.php index 41c1f5d563..a09165b058 100644 --- a/app/admin/models/Orders_model.php +++ b/app/admin/models/Orders_model.php @@ -56,7 +56,7 @@ class Orders_model extends Model */ public $timestamps = TRUE; - public $appends = ['customer_name', 'order_type_name', 'formatted_address']; + public $appends = ['customer_name', 'order_type_name', 'order_date_time', 'formatted_address']; protected $casts = [ 'customer_id' => 'integer', @@ -188,11 +188,25 @@ public function getCustomerNameAttribute($value) public function getOrderTypeNameAttribute() { + if (!$this->location) + return $this->order_type; + return optional( $this->location->availableOrderTypes()->get($this->order_type) )->getLabel(); } + public function getOrderDatetimeAttribute($value) + { + if (!isset($this->attributes['order_date']) + AND !isset($this->attributes['order_time']) + ) return null; + + return Carbon::createFromTimeString( + "{$this->attributes['order_date']} {$this->attributes['order_time']}" + ); + } + public function getFormattedAddressAttribute($value) { return $this->address ? $this->address->formatted_address : null; diff --git a/app/system/language/en/lang.php b/app/system/language/en/lang.php index fb5a5d3a49..a703622bed 100644 --- a/app/system/language/en/lang.php +++ b/app/system/language/en/lang.php @@ -349,7 +349,7 @@ 'text_tab_mail' => 'Mail', 'text_tab_server' => 'Advanced', - 'text_tab_desc_general' => 'Change your restaurant name, email and url, default language, currency and date time formats, ...', + 'text_tab_desc_general' => 'Change your restaurant name, email, default language, currency...', 'text_tab_desc_mail' => 'Settings for sending out emails', 'text_tab_desc_server' => 'Manage advanced system settings such as enabling/disabling maintenance.', From 83d12aaac7de95af6ed4d7a98afa378112623333 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 5 Jul 2021 18:16:18 +0100 Subject: [PATCH 20/23] Minor UI adjustments --- app/admin/assets/css/admin.css | 3 - .../assets/scss/utilities/_utilities.scss | 6 +- .../formwidgets/maparea/assets/js/maparea.js | 3 +- .../repeater/assets/js/repeater.js | 3 +- app/system/views/settings/index.blade.php | 65 ++++++++++--------- 5 files changed, 38 insertions(+), 42 deletions(-) diff --git a/app/admin/assets/css/admin.css b/app/admin/assets/css/admin.css index ae0e8ccb90..94daa39d12 100755 --- a/app/admin/assets/css/admin.css +++ b/app/admin/assets/css/admin.css @@ -18910,9 +18910,6 @@ html { min-height: 100%; height: 100%; } -body { - margin-bottom: 50px; -} body.page { height: 100%; overflow: hidden; diff --git a/app/admin/assets/scss/utilities/_utilities.scss b/app/admin/assets/scss/utilities/_utilities.scss index 47c62495b0..edb6d0ce5f 100644 --- a/app/admin/assets/scss/utilities/_utilities.scss +++ b/app/admin/assets/scss/utilities/_utilities.scss @@ -7,10 +7,6 @@ html { height: 100%; } -body { - margin-bottom: 50px; -} - body.page { height: 100%; overflow: hidden; @@ -22,4 +18,4 @@ body.page { .page-y-spacer { padding-top: $page-padding-y; padding-bottom: $page-padding-y; -} \ No newline at end of file +} diff --git a/app/admin/formwidgets/maparea/assets/js/maparea.js b/app/admin/formwidgets/maparea/assets/js/maparea.js index 1831c919f3..ad809d0c94 100644 --- a/app/admin/formwidgets/maparea/assets/js/maparea.js +++ b/app/admin/formwidgets/maparea/assets/js/maparea.js @@ -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) { diff --git a/app/admin/formwidgets/repeater/assets/js/repeater.js b/app/admin/formwidgets/repeater/assets/js/repeater.js index 75744bd8f6..0233ad4857 100644 --- a/app/admin/formwidgets/repeater/assets/js/repeater.js +++ b/app/admin/formwidgets/repeater/assets/js/repeater.js @@ -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 () { diff --git a/app/system/views/settings/index.blade.php b/app/system/views/settings/index.blade.php index 3163e5888d..d93ccaac9e 100644 --- a/app/system/views/settings/index.blade.php +++ b/app/system/views/settings/index.blade.php @@ -1,41 +1,42 @@ -
-
- @foreach ($settings as $item => $categories) - @continue(!count($categories)) -
-
{{ ucwords($item) }}
-
-
- @foreach ($categories as $key => $category) + From e3c0328f723055741d04ef9aa659cbaeb05b64c0 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Mon, 5 Jul 2021 18:19:37 +0100 Subject: [PATCH 21/23] Use correct datepicker locales path tastyigniter/ti-ext-reservation#18 --- app/admin/formwidgets/DatePicker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/admin/formwidgets/DatePicker.php b/app/admin/formwidgets/DatePicker.php index 926ff8eb30..a74fded4a0 100644 --- a/app/admin/formwidgets/DatePicker.php +++ b/app/admin/formwidgets/DatePicker.php @@ -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'); } From 63f29762c1ed5dd554d7d6d7b2da8677071f2055 Mon Sep 17 00:00:00 2001 From: Sam Poyigi <6567634+sampoyigi@users.noreply.github.com> Date: Tue, 6 Jul 2021 00:24:21 +0100 Subject: [PATCH 22/23] Fix: add canEdit to connector modal (#812) --- app/admin/formwidgets/Connector.php | 15 ++++++++++----- .../formwidgets/connector/assets/js/connector.js | 3 ++- .../formwidgets/connector/connector.blade.php | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/admin/formwidgets/Connector.php b/app/admin/formwidgets/Connector.php index 01f77e99d1..857aaa07c2 100644 --- a/app/admin/formwidgets/Connector.php +++ b/app/admin/formwidgets/Connector.php @@ -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() @@ -68,12 +73,12 @@ public function initialize() 'formName', 'form', 'prompt', + 'editable', 'sortable', 'nameFrom', 'descriptionFrom', 'partial', 'popupSize', - 'canEdit', ]); $fieldName = $this->formField->getName(FALSE); @@ -113,12 +118,12 @@ 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; $this->vars['descriptionFrom'] = $this->descriptionFrom; $this->vars['sortableInputName'] = $this->sortableInputName; - $this->vars['canEdit'] = $this->canEdit ?? true; } public function onLoadRecord() @@ -213,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) diff --git a/app/admin/formwidgets/connector/assets/js/connector.js b/app/admin/formwidgets/connector/assets/js/connector.js index a4358ce5ce..70f78f776c 100644 --- a/app/admin/formwidgets/connector/assets/js/connector.js +++ b/app/admin/formwidgets/connector/assets/js/connector.js @@ -16,12 +16,13 @@ Connector.DEFAULTS = { alias: undefined, + editable: true, sortableHandle: '.connector-item-handle', sortableContainer: '.field-connector-items', } Connector.prototype.init = function () { - if (this.options.canEdit) + 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)) diff --git a/app/admin/formwidgets/connector/connector.blade.php b/app/admin/formwidgets/connector/connector.blade.php index 94404001d3..0a8faa2b2d 100644 --- a/app/admin/formwidgets/connector/connector.blade.php +++ b/app/admin/formwidgets/connector/connector.blade.php @@ -5,7 +5,7 @@ class="field-connector" data-alias="{{ $this->alias }}" data-sortable-container="#{{ $this->getId('items') }}" data-sortable-handle=".{{ $this->getId('items') }}-handle" - data-editable="{{ $canEdit }}" + data-editable="{{ $editable ? 'true' : 'false' }}" >
Date: Wed, 14 Jul 2021 08:18:32 +0100 Subject: [PATCH 23/23] Minor adjustments --- app/admin/language/en/lang.php | 2 +- app/system/language/en/lang.php | 1 + app/system/views/updates/search.blade.php | 31 +++++++++++++++-------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/admin/language/en/lang.php b/app/admin/language/en/lang.php index d566255f54..9678428935 100644 --- a/app/admin/language/en/lang.php +++ b/app/admin/language/en/lang.php @@ -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.', diff --git a/app/system/language/en/lang.php b/app/system/language/en/lang.php index a703622bed..4a3db96dfc 100644 --- a/app/system/language/en/lang.php +++ b/app/system/language/en/lang.php @@ -636,6 +636,7 @@ 'button_check' => '  Check Again', 'button_updates' => '  Updates', 'button_update' => '  Update', + 'button_marketplace' => 'Open TastyIgniter Marketplace  ', 'help_carte_key' => 'A Carte key is required to add/update item from the TastyIgniter Marketplace. Get one by creating a site from your TastyIgniter Account, if you haven\'t already.', ], diff --git a/app/system/views/updates/search.blade.php b/app/system/views/updates/search.blade.php index 4d1f0d881c..38ed9b6496 100644 --- a/app/system/views/updates/search.blade.php +++ b/app/system/views/updates/search.blade.php @@ -1,16 +1,25 @@