Skip to content
Draft
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
name: analyse

on: ['push', 'pull_request']
on: ["push", "pull_request"]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.3]
laravel: [11.*]
stability: [prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4]
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Analyse
run: composer analyse
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction

- name: Execute phpstan
run: composer analyse
55 changes: 30 additions & 25 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
name: style

on:
push:
branches:
- master
jobs:
style:
name: Style
runs-on: ubuntu-latest
on: ["push", "pull_request"]

steps:
- name: Checkout code
uses: actions/checkout@v4
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.4]
laravel: [12.*]
stability: [prefer-stable]
include:
- laravel: 12.*
testbench: 10.*

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

- name: Install dependencies
run: composer install
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Style
run: composer fix-style
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Fix styling changes
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: Execute tests
run: composer style
2 changes: 1 addition & 1 deletion .github/workflows/translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
php-version: '8.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick
coverage: none
- name: Install dependencies
Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
"name": "Kevin Meijer",
"email": "kevin@justbetter.nl",
"role": "Developer"
},
{
"name": "Bob Wezelman",
"email": "bob@justbetter.nl",
"role": "Developer"
}
],
"autoload": {
Expand All @@ -25,16 +30,14 @@
}
},
"require": {
"elasticsearch/elasticsearch": "^8.19",
"rapidez/core": "^4.0",
"rapidez/laravel-scout-elasticsearch": "^1.0",
"rapidez/statamic": "^5.0|^6.0",
"statamic/cms": "^5.0"
"rapidez/core": "^5.0",
"rapidez/statamic": "dev-feature/statamic-6",
"statamic/cms": "^6.0"
},
"require-dev": {
"larastan/larastan": "^3.7",
"laravel/pint": "^1.22",
"orchestra/testbench": "^9.0",
"orchestra/testbench": "^10.0",
"pestphp/pest": "^4.1",
"phpstan/phpstan-mockery": "^2.0",
"phpunit/phpunit": "^12.3"
Expand Down
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"@statamic/cms": "file:./vendor/statamic/cms/resources/dist-package",
"axios": "^1.13.3"
},
"devDependencies": {
"@vitejs/plugin-vue2": "^2.2.0",
"laravel-vite-plugin": "^0.7.2",
"laravel-vite-plugin": "^1.2.0",
"postcss": "^8.4.41",
"tailwindcss": "^3.4.10",
"vite": "^4.0.0",
"vue": "^2.6.11"
"vite": "^6.3.4",
"vue": "^3.4.27"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

This file was deleted.

15 changes: 6 additions & 9 deletions resources/dist/build/manifest.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
{
"resources/js/statamic-query-builder.css": {
"file": "assets/statamic-query-builder-d534377b.css",
"src": "resources/js/statamic-query-builder.css"
},
"resources/js/statamic-query-builder.js": {
"css": [
"assets/statamic-query-builder-d534377b.css"
],
"file": "assets/statamic-query-builder-be794af5.js",
"file": "assets/statamic-query-builder-KTCjuzYx.js",
"name": "statamic-query-builder",
"src": "resources/js/statamic-query-builder.js",
"isEntry": true,
"src": "resources/js/statamic-query-builder.js"
"css": [
"assets/statamic-query-builder-D9z_9asP.css"
]
}
}
126 changes: 126 additions & 0 deletions resources/js/Pages/DefaultPreset.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<template>
<div>
<Head :title="__('Rapidez - Default Query')" />
<div class="max-w-4xl mx-auto py-6">
<div class="mb-6 flex items-center justify-between">
<h1 class="text-2xl font-bold">{{ __('Default Query Settings') }}</h1>
<div class="flex items-center gap-4">
<Field>
<Checkbox
id="enabled"
:label="__('Enable default query')"
v-model="enabled"
/>
</Field>
<Button
class="btn-primary"
:disabled="saving"
@click="save"
>
{{ saving ? __('Saving...') : __('Save') }}
</Button>
</div>
</div>

<div v-if="!attributesLoaded" class="py-8 text-center text-gray-500">
{{ __('Loading attributes...') }}
</div>

<div v-else class="space-y-6">
<QueryBuilder
v-if="groupedFields.length > 0"
:fields="groupedFields"
:sort-fields="sortingOptions"
:default-sort-field="sortingOptions[0]?.value"
:default-limit="100"
:show-limit="false"
:builder-templates="[]"
:show-use-default-query-toggle="false"
:value="queryValue"
@update:model-value="handleQueryUpdate"
/>
<div v-else class="py-8 text-center text-gray-500">
{{ __('No attributes available. Configure product attributes first.') }}
</div>
</div>
</div>
</div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { Head, router } from '@statamic/cms/inertia';
import { Field, Checkbox, Button } from '@statamic/cms/ui';
import QueryBuilder from '../components/fieldtypes/QueryBuilder.vue';
import {
FIELD_GROUPS,
buildGroupedFields,
fetchProductAttributes,
fetchSortingOptions,
normalizeQuery
} from '../helpers/productQueryBuilder';

const { enabled: initialEnabled, query: initialQuery, saveUrl } = defineProps({
enabled: {
type: Boolean,
default: true
},
query: {
type: Object,
default: () => ({ groups: [], globalConjunction: 'AND' })
},
saveUrl: {
type: String,
required: true
}
});

const enabled = ref(initialEnabled);
const queryValue = ref(normalizeQuery(initialQuery));
const groupedFields = ref([]);
const sortingOptions = ref([{ label: 'Created', value: 'created_at' }]);
const saving = ref(false);
const attributesLoaded = ref(false);

const loadAttributesAndSorting = async () => {
try {
const [attributes, options] = await Promise.all([
fetchProductAttributes(),
fetchSortingOptions()
]);
groupedFields.value = buildGroupedFields(attributes, FIELD_GROUPS);
sortingOptions.value = options.length > 0 ? options : [{ label: 'Created', value: 'created_at' }];
} catch (error) {
console.error('Error fetching attributes:', error);
} finally {
attributesLoaded.value = true;
}
};

const handleQueryUpdate = (payload) => {
queryValue.value = {
groups: payload.groups || [],
globalConjunction: payload.globalConjunction || 'AND'
};
};

const save = () => {
saving.value = true;
router.post(saveUrl, {
enabled: enabled.value,
query: {
groups: queryValue.value.groups,
globalConjunction: queryValue.value.globalConjunction
}
}, {
preserveScroll: true,
onFinish: () => {
saving.value = false;
}
});
};

onMounted(() => {
loadAttributesAndSorting();
});
</script>
Loading
Loading