code refactoring
This commit is contained in:
parent
41a62341cb
commit
099dd2d753
19
resources/assets/js/views/modules/apps.js
vendored
19
resources/assets/js/views/modules/apps.js
vendored
@ -88,8 +88,11 @@ const app = new Vue({
|
||||
|
||||
addToCartLoading: false,
|
||||
loadMoreLoading: false,
|
||||
live_search_modal: false,
|
||||
live_search_data: [],
|
||||
live_search: {
|
||||
data: [],
|
||||
modal: false,
|
||||
not_found: false
|
||||
},
|
||||
route_url: url
|
||||
}
|
||||
},
|
||||
@ -301,7 +304,7 @@ const app = new Vue({
|
||||
let target = event.target;
|
||||
|
||||
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) {
|
||||
window.axios.get(url + '/apps/search?keyword=' + event.target.value)
|
||||
.then(response => {
|
||||
this.live_search_data = response.data.data.data;
|
||||
this.live_search_modal = true;
|
||||
this.live_search.data = response.data.data.data;
|
||||
this.live_search.modal = true;
|
||||
this.live_search.not_found = false;
|
||||
})
|
||||
.catch(error => {
|
||||
this.live_search_modal = false;
|
||||
this.live_search.not_found = true;
|
||||
this.live_search.data = [];
|
||||
console.log(error);
|
||||
})
|
||||
} else if (target_length == 0) {
|
||||
this.live_search_modal = false;
|
||||
this.live_search.modal = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ return [
|
||||
'hosted_on_akaunting' => 'Hosted on akaunting.com',
|
||||
'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>.',
|
||||
'not_found' => 'App not found',
|
||||
|
||||
'about' => 'About',
|
||||
|
||||
|
@ -77,9 +77,9 @@
|
||||
/>
|
||||
</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">
|
||||
<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">
|
||||
<img v-for="(file, indis) in item.files"
|
||||
:src="file.path_string"
|
||||
@ -92,9 +92,11 @@
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li v-if="live_search.not_found">{{ trans('modules.not_found') }}</li>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user