code refactoring

This commit is contained in:
Burak Civan 2022-07-19 10:48:46 +03:00
parent 41a62341cb
commit 099dd2d753
3 changed files with 18 additions and 10 deletions

View File

@ -88,8 +88,11 @@ const app = new Vue({
addToCartLoading: false, addToCartLoading: false,
loadMoreLoading: false, loadMoreLoading: false,
live_search_modal: false, live_search: {
live_search_data: [], data: [],
modal: false,
not_found: false
},
route_url: url route_url: url
} }
}, },
@ -301,7 +304,7 @@ const app = new Vue({
let target = event.target; let target = event.target;
if (el !== target && target.contains(el)) { if (el !== target && target.contains(el)) {
this.live_search_modal = false; this.live_search.modal = false;
} }
}, },
@ -311,15 +314,17 @@ const app = new Vue({
if (target_length > 2) { if (target_length > 2) {
window.axios.get(url + '/apps/search?keyword=' + event.target.value) window.axios.get(url + '/apps/search?keyword=' + event.target.value)
.then(response => { .then(response => {
this.live_search_data = response.data.data.data; this.live_search.data = response.data.data.data;
this.live_search_modal = true; this.live_search.modal = true;
this.live_search.not_found = false;
}) })
.catch(error => { .catch(error => {
this.live_search_modal = false; this.live_search.not_found = true;
this.live_search.data = [];
console.log(error); console.log(error);
}) })
} else if (target_length == 0) { } else if (target_length == 0) {
this.live_search_modal = false; this.live_search.modal = false;
} }
} }
} }

View File

@ -50,6 +50,7 @@ return [
'hosted_on_akaunting' => 'Hosted on akaunting.com', 'hosted_on_akaunting' => 'Hosted on akaunting.com',
'only_works_cloud' => 'This app is available only on <strong>Cloud</strong>.', 'only_works_cloud' => 'This app is available only on <strong>Cloud</strong>.',
'only_premium_plan' => 'This app is available only on <strong>Premium Cloud</strong>.', 'only_premium_plan' => 'This app is available only on <strong>Premium Cloud</strong>.',
'not_found' => 'App not found',
'about' => 'About', 'about' => 'About',

View File

@ -77,9 +77,9 @@
/> />
</div> </div>
<div ref="liveSearchModal" v-if="live_search_modal" class="absolute w-full left-0 right-0 bg-white rounded-xl shadow-md p-4 top-20 z-10"> <div ref="liveSearchModal" v-if="live_search.modal" class="absolute w-full left-0 right-0 bg-white rounded-xl shadow-md p-4 top-20 z-10">
<ul class="grid sm:grid-cols-6 gap-8"> <ul class="grid sm:grid-cols-6 gap-8">
<li v-for="(item, index) in live_search_data.slice(0,8)" :key="index" class="sm:col-span-3 p-3 rounded-lg hover:bg-gray-100"> <li v-for="(item, index) in live_search.data.slice(0,8)" :key="index" class="sm:col-span-3 p-3 rounded-lg hover:bg-gray-100">
<a :href="route_url + '/apps/' + item.slug" class="flex items-center space-x-4"> <a :href="route_url + '/apps/' + item.slug" class="flex items-center space-x-4">
<img v-for="(file, indis) in item.files" <img v-for="(file, indis) in item.files"
:src="file.path_string" :src="file.path_string"
@ -92,9 +92,11 @@
</div> </div>
</a> </a>
</li> </li>
<li v-if="live_search.not_found">{{ trans('modules.not_found') }}</li>
</ul> </ul>
<div v-if="live_search_data.length > 4" class="flex item-center justify-center mt-5"> <div v-if="live_search.data.length > 8" class="flex item-center justify-center mt-5">
<x-button type="submit" kind="primary">{{ trans('modules.see_more') }}</x-button> <x-button type="submit" kind="primary">{{ trans('modules.see_more') }}</x-button>
</div> </div>
</div> </div>