Skip to content

Commit

Permalink
Merge branch 'master' of github.com:rapidez/core into feature/filters
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyHoenderdaal committed Sep 6, 2024
2 parents e998c9e + 80906f9 commit bdf614b
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 62 deletions.
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
# Changelog

[Unreleased changes](https://github.com/rapidez/core/compare/2.8.0...2.8.0)
[Unreleased changes](https://github.com/rapidez/core/compare/2.9.2...2.9.2)
## [2.9.2](https://github.com/rapidez/core/releases/tag/2.9.2) - 2024-09-03

### Fixed

- Sliderover header button fix (#554)
- Checkout progressbar steps correct fallback (#555)

## [2.9.1](https://github.com/rapidez/core/releases/tag/2.9.1) - 2024-08-27

### Fixed

- Allow UUID's in Elasticsearch (#545)
- Don't always assume api calls return json (#544)
- Correct slideover class merging (#548)
- Correct ReCaptcha header in the GraphQL mutation component (#549)
- Correct data for the order id for the checkout-payment-saved event (#550)
- Correctly use parseInt (#551)

## [2.9.0](https://github.com/rapidez/core/releases/tag/2.9.0) - 2024-08-16

### Added

- Health check for super attributes (#535)
- Category index scopes Eventy filter (#537)

### Changed

- Removed the NoAttributesToSelectSpecifiedException (#543)

### Fixed

- Prevent price addition errors in sliders (#536)
- Always attempt to decode attribute values (#520)

## [2.8.0](https://github.com/rapidez/core/releases/tag/2.8.0) - 2024-07-24

### Added
Expand Down
1 change: 1 addition & 0 deletions resources/css/app.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import 'components/vue-slider';
@import 'components/price-slider';
@import './theme-variables.css';
@import './components/pagination.css';

@tailwind base;
@tailwind components;
Expand Down
37 changes: 37 additions & 0 deletions resources/css/components/pagination.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.pagination .pagination-button:first-child:nth-last-child(3),
.pagination .pagination-button:first-child:nth-last-child(3) ~ .pagination-button {
@apply hidden;
}

.pagination {
@apply flex flex-wrap justify-center gap-x-2 !m-0 !my-6 max-md:gap-y-4;
}

.pagination-button {
@apply !font-semibold !font-sans !border !border-border !rounded !bg-white !text-neutral !shadow;
}

.pagination-button.active {
@apply !border !border-none !bg-primary !text-white !shadow-none;
}

.pagination-button:first-child {
@apply !mr-auto max-md:w-full max-md:order-last;
}

.pagination-button:last-child {
@apply !ml-auto max-md:w-full max-md:-order-1;
}

.pagination-button:not(:first-child):not(:last-child) {
@apply !m-0 !size-14 max-md:flex-1 max-md:w-auto;
}

.pagination-button:first-child,
.pagination-button:last-child {
@apply h-14 px-6 max-md:!m-0;
}

.pagination-button[disabled] {
@apply opacity-60;
}
4 changes: 2 additions & 2 deletions resources/js/components/Checkout/Checkout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,11 @@ export default {
},
})
}
// response.data = orderId
// response = orderId
this.$root.$emit('checkout-payment-saved', {
order: {
id: response?.data,
id: response,
payment_method_code: this.checkout.payment_method,
},
})
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/GraphqlMutation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
let options = { headers: {} }
if (this.recaptcha) {
options['headers']['Authorization'] = await this.getReCaptchaToken()
options['headers']['X-ReCaptcha'] = await this.getReCaptchaToken()
}
if (this.store) {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/Listing/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export default {
function_score: {
script_score: {
script: {
source: Integer.parseInt(
source: parseInt(
doc['positions.' + window.config.category.entity_id].empty
? '0'
: doc['positions.' + window.config.category.entity_id + ''].value,
Expand Down
8 changes: 7 additions & 1 deletion resources/js/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,13 @@ export const rapidezAPI = (window.rapidezAPI = async (method, endpoint, data = {
throw new FetchError(window.config.translations.errors.wrong, response)
}

return await response.json()
let responseData = await response.text()

try {
return JSON.parse(responseData)
} catch (e) {
return responseData
}
})

export const magentoGraphQL = (window.magentoGraphQL = async (
Expand Down
2 changes: 1 addition & 1 deletion resources/views/checkout/partials/progressbar.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<nav class="grid grid-cols-12 my-5">
@foreach (array_slice((config('rapidez.frontend.checkout_steps.'.config('rapidez.store_code')) ?? config('rapidez.checkout_steps.default')), 0, -1) as $stepTitle)
@foreach (array_slice((config('rapidez.frontend.checkout_steps.'.config('rapidez.store_code')) ?: config('rapidez.frontend.checkout_steps.default')), 0, -1) as $stepTitle)
<button class="col-span-3 relative focus:outline-none" :disabled="checkout.step < {{ $loop->index }}" :class="checkout.step < {{ $loop->index }} ? 'cursor-default' : ''" v-on:click="if (checkout.step >= {{ $loop->index }}) goToStep({{ $loop->index }})">
@if (!$loop->last)
<div :class="checkout.step > {{ $loop->index }} ? 'bg-neutral' : 'bg-inactive'" class="absolute flex w-full h-0.5 top-5 left-1/2"></div>
Expand Down
10 changes: 6 additions & 4 deletions resources/views/checkout/steps/credentials.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
</div>
</div>

<div v-for="(method, index in checkout.shipping_methods" class="flex flex-col gap-4">
<div class="flex flex-col gap-4">
<p class="text-2xl font-bold">
@lang('Shipping method')
</p>
<x-rapidez::radio v-model="checkout.shipping_method" v-bind:value="method.carrier_code+'_'+method.method_code" v-bind:dusk="'method-'+index">
@{{ method.method_title }}
</x-rapidez::radio>
<template v-for="(method, index) in checkout.shipping_methods">
<x-rapidez::radio v-model="checkout.shipping_method" v-bind:value="method.carrier_code+'_'+method.method_code" v-bind:dusk="'method-'+index">
@{{ method.method_title }}
</x-rapidez::radio>
</template>
</div>
<div class="flex flex-col gap-4">
<p class="text-2xl font-bold">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/slideover/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@
<x-tag v-on:reset="toggleScroll(false)" :is="$tag">
<input id="{{ 'close-' . $id }}" class="hidden" type="reset">
@if (!$hasParent)
<input @checked($open) {{ $attributes->only(['id'])->merge(['id' => $id]) }} v-on:change="toggleScroll($event.target.checked)" class="peer hidden" type="checkbox">
<input @checked($open) {{ $attributes->only(['id'])->merge(['id' => $id, 'class' => 'peer hidden']) }} v-on:change="toggleScroll($event.target.checked)" type="checkbox">
<label
v-bind:for="{{ $attributes->get('v-bind:id') ?? '\'' . $closeId . '\'' }}"
class="pointer-events-none fixed inset-0 z-40 cursor-pointer bg-neutral/50 opacity-0 transition peer-checked:pointer-events-auto peer-checked:opacity-100"
></label>
@else
<input @checked($open) {{ $attributes->only(['id'])->merge(['id' => $id]) }} class="peer hidden" type="checkbox">
<input @checked($open) {{ $attributes->only(['id'])->merge(['id' => $id, 'class' => 'peer hidden']) }} type="checkbox">
@endif
<div {{ $attributes->class([
'fixed inset-y-0 transition-all bg-white z-40 flex flex-col max-w-md w-full',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/slideover/mobile.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{--
This component adds some styling on the slideover to hide the slideover on desktop and placing the content on the page itself.
By using this, you have the ability to have something that becomes a slider on mobile.
By using this, you have the ability to have something that becomes a slideover on mobile.
--}}
@include('rapidez::components.slideover.index', ['attributes' => $attributes->class('lg:contents [&>.slideover-wrapper]:lg:contents [&>.slideover-header]:lg:hidden')])
10 changes: 2 additions & 8 deletions resources/views/components/slideover/partials/header.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
<div class="px-5">
<div class="relative flex items-center justify-center">
@if ($hasParent)
<label
{{ $attributes->merge(['id' => $id]) }}
class="absolute left-0 top-1/2 -translate-y-1/2 cursor-pointer text-white"
>
<label for="{{ $id }}" class="absolute left-0 top-1/2 -translate-y-1/2 cursor-pointer text-white">
<x-heroicon-o-arrow-left class="size-6" />
</label>
@elseif ($headerbutton->isNotEmpty())
Expand All @@ -16,10 +13,7 @@ class="absolute left-0 top-1/2 -translate-y-1/2 cursor-pointer text-white"
{{ $title }}
</span>
@endif
<label
v-bind:for="{{ $attributes->get('v-bind:id') ?? '\'' . $closeId . '\'' }}"
class="absolute right-0 top-1/2 -translate-y-1/2 cursor-pointer text-white"
>
<label v-bind:for="{{ $attributes->get('v-bind:id') ?? '\'' . $closeId . '\'' }}" class="absolute right-0 top-1/2 -translate-y-1/2 cursor-pointer text-white">
<x-heroicon-o-x-mark class="size-6" />
</label>
</div>
Expand Down
6 changes: 4 additions & 2 deletions resources/views/listing/products.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
:react="{and: reactiveFilters}"
:sort-options="sortOptions"
:inner-class="{
button: '!bg-inactive disabled:!bg-opacity-60 !text-white [&.active]:!bg-neutral',
sortOptions: '{{ $dropdownClasses }}'
button: 'pagination-button',
current: 'current-button',
sortOptions: '{{ $dropdownClasses }}',
pagination: 'pagination'
}"
prev-label="@lang('Prev')"
next-label="@lang('Next')"
Expand Down
13 changes: 0 additions & 13 deletions src/Exceptions/NoAttributesToSelectSpecifiedException.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Jobs/IndexJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class IndexJob
use Dispatchable;

protected string $index;
protected int $id;
protected int|string $id;
protected array $values;

public function __construct(string $index, int $id, $values)
public function __construct(string $index, int|string $id, $values)
{
$this->index = $index;
$this->id = $id;
Expand Down
36 changes: 15 additions & 21 deletions src/Models/QuoteItemOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Rapidez\Core\Models;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Support\Facades\DB;
use TorMorten\Eventy\Facades\Eventy;

class QuoteItemOption extends Model
{
Expand All @@ -23,26 +23,20 @@ public function quote_item()
protected function value(): Attribute
{
return Attribute::make(
get: fn (string $value) => match ($this->code) {
'info_buyRequest' => json_decode($value),
'attributes' => json_decode($value),
'option_ids' => explode(',', $value),
default => (function () use ($value) {
if (! $this->option) {
return;
}

if (in_array($this->option->type, ['drop_down', 'radio'])) {
return config('rapidez.models.product_option_type_value')::find($value)->title;
}

if ($this->option->type == 'file') {
return json_decode($value);
}

return $value;
})()
})->shouldCache();
get: function (string $value) {
$value = Eventy::filter('quote_item_option.value', $value, $this);

if (isset($this->option) && in_array($this->option->type, ['drop_down', 'radio'])) {
$value = config('rapidez.models.product_option_type_value')::find($value)->title;
}

if ($this->code === 'option_ids') {
$value = explode(',', $value);
}

return is_string($value) ? (json_decode($value) ?? $value) : $value;
}
)->shouldCache();
}

protected function label(): Attribute
Expand Down
3 changes: 1 addition & 2 deletions src/Models/Scopes/Product/WithProductAttributesScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;
use Rapidez\Core\Exceptions\NoAttributesToSelectSpecifiedException;

class WithProductAttributesScope implements Scope
{
public function apply(Builder $builder, Model $model)
{
if (empty($model->attributesToSelect)) {
throw NoAttributesToSelectSpecifiedException::create();
return;
}

$attributeModel = config('rapidez.models.attribute');
Expand Down

0 comments on commit bdf614b

Please sign in to comment.