diff --git a/app/Http/Controllers/ActieController.php b/app/Http/Controllers/ActieController.php index 3858549a..f0db068b 100755 --- a/app/Http/Controllers/ActieController.php +++ b/app/Http/Controllers/ActieController.php @@ -14,7 +14,7 @@ class ActieController extends VoyagerBaseController { - public function agenda() + public function agenda(Request $request) { // Definieer de routes waarmee de component evenementen kan ophalen $routes = collect(Route::getRoutes()->getRoutesByName())->filter(function ($route) { @@ -29,10 +29,13 @@ public function agenda() $themes = Theme::orderBy('name', 'ASC')->get(); $categories = Category::orderBy('name', 'ASC')->get(); + $themes_selected_ids = $request->themes ? array_map('intval', $request->themes) : []; + $categories_selected_ids = $request->categories ? array_map('intval', $request->categories) : []; + // SEO SEOTools::setTitle('Acties'); - return view('acties.agenda', compact('routes', 'themes', 'categories')); + return view('acties.agenda', compact('routes', 'themes', 'categories', 'themes_selected_ids', 'categories_selected_ids')); } public function actie($slug) @@ -123,7 +126,7 @@ public function search(Request $request) if ($request->limit) { $acties = $query->limit($request->limit)->get(); } else { - $acties = $query->paginate(12); + $acties = $query->paginate(24); } return response()->json(['acties' => $acties]); diff --git a/app/Http/Controllers/ActieWijzerController.php b/app/Http/Controllers/ActieWijzerController.php index ce4270f9..5b785fb6 100644 --- a/app/Http/Controllers/ActieWijzerController.php +++ b/app/Http/Controllers/ActieWijzerController.php @@ -25,7 +25,7 @@ public function landing() { $questions = Question::active()->get()->toArray(); $dimensions = Dimension::all()->toArray(); - $themes = Theme::all()->toArray(); + $themes = Theme::orderBy('name', 'ASC')->all()->toArray(); $result_route = route('actiewijzer.result'); // SEO @@ -126,22 +126,32 @@ public function result(Request $request) { }); // Get referentie_types and calculate the similarity with the score_vector - $referentie_types = ReferentieType::published()->with(['referenties' => function (Builder $query) { + $referentie_types = ReferentieType::published()->with(['referenties' => function (Builder $query) use ($themes) { + $query->whereHas('themes', function (Builder $query) use ($themes) { + $query->whereIn('theme_id', $themes->pluck('id')->toArray()); + })->with('referentie_types'); $query->inRandomOrder()->limit(3); }])->get(); + foreach ($referentie_types as $rt) { + // calculate percentage match $dims_filtered = array_filter($dimensions->toArray(), function($d) use ($rt) { return in_array($d['id'], array_keys($rt->score_vector)); }); $dim_scores = array_combine(array_column($dims_filtered, 'id'), array_column($dims_filtered, 'score')); $rt->match_perc = round(percentageMatch($dim_scores, $rt->score_vector)); + + // if we get 0 referenties, get 3 referenties without filtering by theme + if ($rt->referenties->count() == 0) { + $rt->referenties = ReferentieType::find($rt->id)->referenties()->with('referentie_types')->inRandomOrder()->limit(3)->get(); + } } $referentie_types = $referentie_types->sortByDesc('match_perc'); return view('actiewijzer.result', compact('themes', 'dimensions', 'referentie_types', 'routes')); } - public function referentie_type($referentie_type) + public function referentie_type($referentie_type, Request $request) { $referentie_type = ReferentieType::where('title', $referentie_type)->firstOrFail(); @@ -156,20 +166,21 @@ public function referentie_type($referentie_type) }); $themes = Theme::orderBy('name', 'ASC')->get(); + $themes_selected_ids = $request->themes ? array_map('intval', $request->themes) : []; // SEO SEOTools::setTitle($referentie_type->title); SEOTools::setDescription($referentie_type->description); SEOMeta::setKeywords($referentie_type->title); - return view('actiewijzer.referentie_type', compact('referentie_type', 'themes', 'routes')); + return view('actiewijzer.referentie_type', compact('referentie_type', 'themes', 'routes', 'themes_selected_ids')); } public function search(Request $request) { $referentie_type = ReferentieType::find($request->referentieTypeId); - $query = Referentie::query()->whereHas('referentie_types', function($q) use ($referentie_type) { + $query = Referentie::query()->with('referentie_types')->whereHas('referentie_types', function($q) use ($referentie_type) { $q->where('referentie_type_id', $referentie_type->id); }); if ($request->q) { @@ -187,7 +198,7 @@ public function search(Request $request) if ($request->limit) { $referenties = $query->orderBy('title', 'ASC')->published()->limit($request->limit)->get(); } else { - $referenties = $query->orderBy('title', 'ASC')->published()->paginate(12); + $referenties = $query->orderBy('title', 'ASC')->published()->paginate(24); } return response()->json(['referenties' => $referenties]); diff --git a/app/Http/Controllers/OrganizerController.php b/app/Http/Controllers/OrganizerController.php index 8a8adcf6..0862ee74 100755 --- a/app/Http/Controllers/OrganizerController.php +++ b/app/Http/Controllers/OrganizerController.php @@ -58,7 +58,7 @@ public function search(Request $request) if ($request->limit) { $organizers = $query->orderBy('name', 'ASC')->published()->limit($request->limit)->get(); } else { - $organizers = $query->orderBy('name', 'ASC')->published()->paginate(12); + $organizers = $query->orderBy('name', 'ASC')->published()->paginate(24); } return response()->json(['organizers' => $organizers]); diff --git a/app/Models/ReferentieType.php b/app/Models/ReferentieType.php index e17c320d..9560055b 100644 --- a/app/Models/ReferentieType.php +++ b/app/Models/ReferentieType.php @@ -12,6 +12,10 @@ class ReferentieType extends Model protected $table = 'referentie_types'; + protected $appends = [ + 'link' + ]; + protected $fillable = [ 'title', 'description', @@ -24,7 +28,6 @@ class ReferentieType extends Model * @var array */ protected $with = [ - 'referenties', 'dimensions' ]; @@ -50,6 +53,12 @@ public function getScoreVectorAttribute() return $score_vec; } + public function getLinkAttribute() + { + return url('/type/' . strtolower($this->title)); + + } + public function scopePublished($query) { return $query->where('status', 'PUBLISHED'); diff --git a/resources/lang/nl/actiewijzer.php b/resources/lang/nl/actiewijzer.php index bb4e9b0d..1a01f45e 100644 --- a/resources/lang/nl/actiewijzer.php +++ b/resources/lang/nl/actiewijzer.php @@ -22,4 +22,5 @@ 'results_summary_body' => 'Dit zijn de voorkeuren die je hebt aangegeven. Op basis van deze scores stellen we jouw persoonlijke suggesties voor actie samen.', 'back_to_actiewijzer' => 'Terug naar ActieWijzer', 'back_to_actiewijzer_result' => 'Terug naar Resultaat ActieWijzer', + 'no_results_suggestion_retry_or_later' => 'Vul de ActieWijzer in met meer thema\'s of probeer het later opnieuw.', ]; diff --git a/resources/lang/nl/general.php b/resources/lang/nl/general.php index 49a3ae6d..faabaee1 100644 --- a/resources/lang/nl/general.php +++ b/resources/lang/nl/general.php @@ -13,6 +13,7 @@ 'written_on' => 'Geschreven op ', 'read_more' => 'Meer lezen...', 'more_info' => 'Meer info', + 'load_more' => 'Meer laden', 'about' => 'Over', 'about_us' => 'Over ons', 'mark_as_read' => 'Markeer als gelezen', @@ -35,6 +36,8 @@ 'position_and_resize_photo' => 'Pas de grootte en positie van je foto aan', 'send_form' => 'Verzenden', 'no_results' => 'Geen resultaten', + 'no_results_suggestion_too_many_filters' => 'Heb je misschien te veel filters ingesteld?', + 'clear_filters' => 'Filter(s) wissen', '404_header' => 'Oeps! Pagina niet gevonden...', '500_header' => 'Oeps! Er is iets misgegaan...', 'approve' => 'Goedkeuren', diff --git a/resources/svg/antdesign-link-o.svg b/resources/svg/antdesign-link-o.svg new file mode 100644 index 00000000..b9493a18 --- /dev/null +++ b/resources/svg/antdesign-link-o.svg @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/resources/views/VueTailwindSettings.js b/resources/views/VueTailwindSettings.js index 1ba3178f..e417145f 100644 --- a/resources/views/VueTailwindSettings.js +++ b/resources/views/VueTailwindSettings.js @@ -107,7 +107,7 @@ const VueTailwindSettings = { fixedClasses: { overlay: "z-[1001] overflow-auto scrolling-touch left-0 top-0 bottom-0 right-0 w-full h-full fixed bg-black/50", wrapper: "relative mx-auto mt-20 max-w-lg px-3 py-12", - modal: "overflow-visible relative rounded-lg overflow-hidden", + modal: "relative rounded-lg overflow-hidden", body: "p-3", header: "border-b rounded-t", footer: " p-3 rounded-b", @@ -143,6 +143,14 @@ const VueTailwindSettings = { close: "bg-red-50 text-red-700 hover:bg-red-200 border-red-100 border", modal: "bg-white shadow-lg", footer: "bg-red-50" + }, + card: { + overlay: "", + header: "p-0", + body: "", + close: "m-3", + modal: "bg-white shadow", + footer: "bg-gray-100" } } } diff --git a/resources/views/acties/agenda.blade.php b/resources/views/acties/agenda.blade.php index 30b7d0b0..6a5ef0f6 100644 --- a/resources/views/acties/agenda.blade.php +++ b/resources/views/acties/agenda.blade.php @@ -21,6 +21,8 @@ :routes="{{ $routes }}" :themes="{{ $themes }}" :categories="{{ $categories }}" + :themes-selected-ids="{{ json_encode($themes_selected_ids) }}" + :categories-selected-ids="{{ json_encode($categories_selected_ids) }}" > diff --git a/resources/views/actiewijzer/referentie_type.blade.php b/resources/views/actiewijzer/referentie_type.blade.php index 1b44121f..362d1d0a 100755 --- a/resources/views/actiewijzer/referentie_type.blade.php +++ b/resources/views/actiewijzer/referentie_type.blade.php @@ -22,6 +22,7 @@ :routes="{{ $routes }}" :themes="{{ $themes }}" :referentie-type-id="{{ $referentie_type->id }}" + :themes-selected-ids="{{ json_encode($themes_selected_ids) }}" /> diff --git a/resources/views/actiewijzer/result.blade.php b/resources/views/actiewijzer/result.blade.php index d96e1521..ed9cfdef 100755 --- a/resources/views/actiewijzer/result.blade.php +++ b/resources/views/actiewijzer/result.blade.php @@ -103,25 +103,42 @@ class="relative self-start inline-block px-2 py-1 mr-1 mb-1 text-xs font-medium :limit="4" > - @else -
- @foreach ($rt->referenties->toArray() as $ref) - - @endforeach +
+ + +
+ @else + @if($rt->referenties->count() > 0) + + + @else +
+

{{__('general.no_results')}}

+
+

{{ __('actiewijzer.no_results_suggestion_retry_or_later') }}

+
+
+ @endif @endif -
@endforeach diff --git a/resources/views/assets/js/components/apps/ActieAgenda.vue b/resources/views/assets/js/components/apps/ActieAgenda.vue index 38314449..c8063805 100644 --- a/resources/views/assets/js/components/apps/ActieAgenda.vue +++ b/resources/views/assets/js/components/apps/ActieAgenda.vue @@ -82,7 +82,7 @@
-
-
-

{{__('general.no_results')}}

+
+

{{__('general.no_results')}}

+
+

{{ __('general.no_results_suggestion_too_many_filters') }}

+
- - + +
+ +
+
+
+
@@ -147,10 +150,18 @@ export default { type: Array, default: () => [], }, + themesSelectedIds: { + type: Array, + default: () => [], + }, categories: { type: Array, default: () => [], }, + categoriesSelectedIds: { + type: Array, + default: () => [], + }, filterable: { type: Boolean, default: true, @@ -171,6 +182,10 @@ export default { type: Array, default: () => [], }, + enableShowMore: { + type: Boolean, + default: true, + }, skeletons: { type: Number, default: 10, @@ -192,11 +207,12 @@ export default { geoSuggestions: [], showPast: false, isGeladen: false, + appending: false, heeftFout: false, currentPage: null, + lastPage: null, perPage: null, total: null, - base_link: null, } }, computed: { @@ -253,33 +269,40 @@ export default { } }, mounted() { + this.themesSelected = this.themes.filter(t => this.themesSelectedIds.includes(t.id)).map(t => t.id); + this.categoriesSelected = this.categories.filter(c => this.categoriesSelectedIds.includes(c.id)).map(c => c.id); this.getActies() }, methods: { - getActies: _.debounce(async function getActies(page = 1) { + getActies: _.debounce(async function getActies() { this.isGeladen = false this.heeftFout = false axios.get(this.routes["acties.search"].uri, { params: { q: this.query, - themes: this.themesSelected ?? this.themeIds, + themes: this.themesSelected.length > 0 ? this.themesSelected : this.themeIds, categories: this.categoriesSelected, coordinates: this.coordinates, distance: this.distance, show_past: this.showPast, - page: page, + page: this.currentPage, organizer: this.organizerId, } }).then((response) => { - this.acties = this.processActiesArray(response.data.acties.data) + if (this.appending) { + this.acties = this.acties.concat(this.processActiesArray(response.data.acties.data)) + } else { + this.acties = this.processActiesArray(response.data.acties.data) + } this.currentPage = response.data.acties.current_page + this.lastPage = response.data.acties.last_page this.perPage = response.data.acties.per_page this.total = response.data.acties.total - this.base_link = response.data.acties.first_page_url }).catch((error) => { this.heeftFout = true }).finally(() => { this.isGeladen = true + this.appending = false }) }, 500), processActiesArray: function(acties) { diff --git a/resources/views/assets/js/components/apps/Notifications.vue b/resources/views/assets/js/components/apps/Notifications.vue index 9b51cd33..20d150bb 100644 --- a/resources/views/assets/js/components/apps/Notifications.vue +++ b/resources/views/assets/js/components/apps/Notifications.vue @@ -104,13 +104,13 @@ export default { \ No newline at end of file diff --git a/resources/views/assets/js/components/apps/Organizers.vue b/resources/views/assets/js/components/apps/Organizers.vue index f42aa055..a473eb21 100644 --- a/resources/views/assets/js/components/apps/Organizers.vue +++ b/resources/views/assets/js/components/apps/Organizers.vue @@ -35,7 +35,7 @@
-
+
{{organizer.selected}}
-
-
-

{{__('general.no_results')}}

+
+

{{__('general.no_results')}}

+
+

{{ __('general.no_results_suggestion_too_many_filters') }}

+
- - + +
+ +
+
+
+
@@ -97,7 +99,7 @@ export default { type: Boolean, default: true, }, - showPagination: { + enableShowMore: { type: Boolean, default: true }, @@ -121,11 +123,12 @@ export default { organizersSel: this.organizersSelected, query: "", isGeladen: false, + appending: false, heeftFout: false, currentPage: null, + lastPage: null, perPage: null, total: null, - base_link: null, } }, computed: { @@ -146,6 +149,10 @@ export default { organizerBaseRoute() { return this.routes["organizers.organizer"].uri.split("{")[0] }, + filterCount() { + var filters = [this.query, this.themesSelected] + return filters.filter(f => (!!f && !(f.length === 0))).length + }, }, watch: { query: function() { @@ -162,24 +169,28 @@ export default { this.getOrganizers() }, methods: { - getOrganizers: _.debounce(async function getOrganizers(page = 1) { + getOrganizers: _.debounce(async function getOrganizers() { this.isGeladen = false this.heeftFout = false axios.get(this.routes["organizers.search"].uri, { params: { q: this.query, themes: this.themesSelected, - page: page, + page: this.currentPage, organizer: this.organizerId, limit: this.max ?? null } }).then((response) => { if ('per_page' in response.data.organizers) { - this.organizers = response.data.organizers.data + if (this.appending) { + this.organizers = this.organizers.concat(response.data.organizers.data) + } else { + this.organizers = response.data.organizers.data + } this.currentPage = response.data.organizers.current_page + this.lastPage = response.data.organizers.last_page this.perPage = response.data.organizers.per_page this.total = response.data.organizers.total - this.base_link = response.data.organizers.first_page_url } else { this.organizers = response.data.organizers } @@ -187,6 +198,7 @@ export default { this.heeftFout = true }).finally(() => { this.isGeladen = true + this.appending = false }) }, 500), processQuery: _.debounce(function(input) { @@ -213,6 +225,10 @@ export default { return v.id === organizer.id }) }, + resetFilters() { + this.themesSelected = [] + this.query = "" + } } } diff --git a/resources/views/assets/js/components/apps/Referenties.vue b/resources/views/assets/js/components/apps/Referenties.vue index 1adf1e5b..cb1273a2 100644 --- a/resources/views/assets/js/components/apps/Referenties.vue +++ b/resources/views/assets/js/components/apps/Referenties.vue @@ -1,6 +1,6 @@ + diff --git a/resources/views/assets/js/components/forms/OrganizerForm.vue b/resources/views/assets/js/components/forms/OrganizerForm.vue index 242d7bbf..8b688bf3 100644 --- a/resources/views/assets/js/components/forms/OrganizerForm.vue +++ b/resources/views/assets/js/components/forms/OrganizerForm.vue @@ -22,7 +22,7 @@ :organizers-selected="organizersSelected" :routes="routes" :show-themes="false" - :show-pagination="false" + :enable-show-more="false" :max="5" mode="select" /> diff --git a/resources/views/assets/js/components/partials/Referentie.vue b/resources/views/assets/js/components/partials/Referentie.vue index 1b72beb2..78953404 100644 --- a/resources/views/assets/js/components/partials/Referentie.vue +++ b/resources/views/assets/js/components/partials/Referentie.vue @@ -1,60 +1,58 @@ diff --git a/resources/views/assets/sass/app.scss b/resources/views/assets/sass/app.scss index 53ab5ebb..42fccc6d 100755 --- a/resources/views/assets/sass/app.scss +++ b/resources/views/assets/sass/app.scss @@ -109,6 +109,9 @@ &.gray { @apply flex justify-center px-4 py-2 text-sm font-medium cursor-pointer text-gray-600 transition duration-150 ease-in-out border border-transparent rounded-md bg-gray-200 hover:bg-gray-300; } + &.pink { + @apply flex justify-center px-4 py-2 text-sm font-medium cursor-pointer text-white transition duration-150 ease-in-out border border-transparent rounded-md bg-[color:var(--wkid-pink)] hover:bg-[color:var(--wkid-pink-dark)] disabled:bg-gray-400 disabled:cursor-not-allowed; + } } } @@ -258,4 +261,14 @@ div.custom-loader { width: 20px; height: 20px; animation: spin 1s linear infinite; + + &.dark { + border: 4px solid #333; + border-top: 4px solid transparent; + } + + &.large { + width: 40px; + height: 40px; + } } \ No newline at end of file diff --git a/resources/views/tailwind.config.js b/resources/views/tailwind.config.js index d47a411d..c1746ad0 100755 --- a/resources/views/tailwind.config.js +++ b/resources/views/tailwind.config.js @@ -12,7 +12,6 @@ module.exports = { plugins: [ require("@tailwindcss/forms"), require("@tailwindcss/typography"), - require("@tailwindcss/line-clamp"), ], safelist: [ "-mx-2", @@ -21,6 +20,7 @@ module.exports = { "-mt-1", "mt-20", "my-2", + "m-3", "animate-pulse", "animate-spin", "bg-[color:var(--wkid-blue)]",