readd renderif feature from commit d6bdad27b2 to searchbar

This commit is contained in:
Harald Bamberger
2025-10-01 14:26:58 +02:00
parent 57345940ef
commit ecbb6744a7
3 changed files with 29 additions and 5 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ const app = Vue.createApp({
defaultaction: {
type: "link",
renderif: function(data) {
if(data.content_id === "N/A"){
if(data.content_id === null){
return false;
}
return true;
@@ -79,7 +79,7 @@ const app = Vue.createApp({
icon: "fas fa-info-circle",
type: "link",
renderif: function(data) {
if(data.content_id === "N/A"){
if(data.content_id === null){
return false;
}
return true;
@@ -19,10 +19,24 @@ export default {
if (this.action.type === 'function')
this.action.action(this.res);
this.$emit('actionexecuted');
},
renderif: function() {
if(this.action?.renderif === undefined) {
return true;
}
return this.action.renderif(this.res);
}
},
template: `
<template v-if="this.renderif()">
<a class="searchbar-result-template-action" :href="actionHref" @click="actionFunc">
<slot>{{ $p.t('search/action_default_label') }}</slot>
</a>`
</a>
</template>
<template v-else>
<div class="searchbar-result-template-action">
<slot>{{ $p.t('search/action_default_label') }}</slot>
</div>
</template>`
};
@@ -10,11 +10,20 @@ export default {
res: Object,
actions: Array
},
methods: {
renderif: function(action) {
if(action?.renderif === undefined) {
return true;
}
return action.renderif(this.res);
}
},
template: `
<div v-if="actions.length" class="searchbar-result-template-actions">
<template v-for="(action, index) in actions" :key="action.label">
<result-action
v-for="(action, index) in actions"
:key="action.label"
v-if="this.renderif(action)"
:res="res"
:action="action"
class="btn btn-primary btn-sm"
@@ -23,5 +32,6 @@ export default {
<i v-if="action.icon" :class="action.icon"></i>
<span class="p-2">{{ action.label }}</span>
</result-action>
</template>
</div>`
};