Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: search jobs modal showing 'no jobs found' without searching any job (#85zrmar8z) #364

Merged
merged 7 commits into from
Feb 8, 2023
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
"Schedule product sync": "Schedule product sync",
"Select run time": "Select run time",
"Search jobs": "Search jobs",
"Searched jobs will appear here": "Searched jobs will appear here",
"Select jobs": "Select jobs",
"select jobs": "select jobs",
"Services have been scheduled in bulk": "Services have been scheduled in bulk",
Expand Down
14 changes: 10 additions & 4 deletions src/views/SelectJobsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
</ion-toolbar>
</ion-header>
<ion-content>
<ion-searchbar v-model="queryString" :placeholder="$t('Search jobs')" @keyup.enter="search($event)" />
<ion-searchbar :placeholder="$t('Search jobs')" @keyup.enter="search($event)" />

<div v-if="jobs.length === 0" class="ion-text-center">
<div v-if="queryString.length === 0" class="ion-text-center">
<p>{{ $t("Searched jobs will appear here") }}</p>
</div>

<div v-else-if="jobs.length === 0 && queryString.length != 0" class="ion-text-center">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the condition queryString.length != 0" might not be needed, else-if will execute only when queryString.length === 0 fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improved.

<p>{{ $t("No jobs found") }}</p>
</div>

Expand Down Expand Up @@ -80,7 +84,7 @@ export default defineComponent({
queryString: '',
jobs: [] as any,
isScrollable: true,
jobFrequencyType: JSON.parse(process.env?.VUE_APP_JOB_FREQUENCY_TYPE as string) as any,
jobFrequencyType: JSON.parse(process.env?.VUE_APP_JOB_FREQUENCY_TYPE as string) as any
}
},
computed: {
Expand All @@ -92,7 +96,9 @@ export default defineComponent({
methods: {
async search(event: any) {
this.queryString = event.target.value.trim();
if(this.queryString.length > 0) this.getJobs();
if(this.queryString.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need the length check at all?

"That is, all values are truthy except false, 0, -0, 0n, "", null, undefined, and NaN."

https://developer.mozilla.org/en-US/docs/Glossary/Truthy

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sir. The empty queryString itself is a false value.

this.getJobs();
}
},
async getJobs(vSize?: any, vIndex?: any) {
const viewSize = vSize ? vSize : process.env.VUE_APP_VIEW_SIZE;
Expand Down