124124 </div >
125125 </div >
126126 </div >
127- <div v-if =" data.showResultsList" v-for =" (doc, idx) of data.documents" :key =" doc._id + idx" style =" display :block ;border-bottom :gray 1px solid ;padding :1em ;cursor :pointer ;" @click =" loadItem({path: doc._id})" >
128- <div class =" text-base" >
129- {{ doc.fields.identifier[0] }}
130- </div >
131- <div class =" text-lg font-medium" >
132- {{ doc.fields.name[0] }}
133- </div >
134- <div v-if =" doc.highlight" v-for =" (text, idx) of doc.highlight.text" class =" text-sm font-medium" >
135- …<span v-html =" text" ></span >…
136- </div >
137- <div v-if =" doc.highlight" v-for =" (text, idx) of doc.highlight.phoneticText" class =" text-sm font-medium" >
138- …<span v-html =" text" ></span >…
127+ <div class =" flex flex-col" >
128+ <div v-if =" data.showResultsList" v-for =" (doc, idx) of data.documents" :key =" doc._id + idx" style =" display :block ;border-bottom :gray 1px solid ;padding :1em ;cursor :pointer ;" @click =" loadItem({path: doc._id})" >
129+ <div class =" text-base" >
130+ {{ doc.fields.identifier[0] }}
131+ </div >
132+ <div class =" text-lg font-medium" >
133+ {{ doc.fields.name[0] }}
134+ </div >
135+ <div v-if =" doc.highlight" v-for =" (text, idx) of doc.highlight.text" class =" text-sm font-medium" >
136+ …<span v-html =" text" ></span >…
137+ </div >
138+ <div v-if =" doc.highlight" v-for =" (text, idx) of doc.highlight.phoneticText" class =" text-sm font-medium" >
139+ …<span v-html =" text" ></span >…
140+ </div >
139141 </div >
140142 </div >
143+
141144 </div >
142145 </div >
143146</template >
@@ -213,9 +216,7 @@ async function search() {
213216 },
214217 });
215218 // Don't show the search results list until the user has explicitly searched for something
216- if (Object .keys ({... data .form }).length !== 0 ) {
217- data .showResultsList = true ;
218- }
219+ data .showResultsList = ! isFormEmpty (data .form );
219220 if (response .status === 200 ) {
220221 response = await response .json ();
221222 data .documents = response .hits ;
@@ -224,6 +225,14 @@ async function search() {
224225 }
225226}
226227
228+ function isFormEmpty (form ) {
229+ let nonEmptyFields = Object .entries (form).filter (([_k , v ]) => {
230+ return v !== " "
231+ })
232+
233+ return nonEmptyFields .length === 0 ;
234+ }
235+
227236async function lookup (query , cb ) {
228237 let response = await $http .get ({ route: " /repository/lookup/language" , params: { query } });
229238 if (response .status === 200 ) {
0 commit comments