Vue.component("action-list", {
template: '<template>     <div>         <vv-notice ref=\'notice\'></vv-notice>         <q-list dense>             <q-item v-for="item in list_ui" clickable v-ripple @click="list_on_click(item)">                 <q-item-section>{{item.rid}}</q-item-section>                 <q-item-section side>                     <div>                         <q-btn style="padding: 0px 5px 0px 5px;" flat dense icon="icon-fa-ellipsis-vert" color="grey-5" size=\'xs\' @click.stop.prevent>                             <q-menu>                                 <q-list>                                     <q-item clickable v-close-popup @click="list_on_delete(item)">                                         <q-item-section>                                             <q-item-label>delete</q-item-label>                                         </q-item-section>                                     </q-item>                                 </q-list>                             </q-menu>                         </q-btn>                     </div>                 </q-item-section>             </q-item>         </q-list>     </div> </template>',
props :{
    list: { type: Array },
    tags: { type: Array },
    list_filter: { type: Object }
},
data :function () {
    return { show_additional: false };
},
computed :{
    list_filtered() {
        if (vvs.isEmptyString(this.list_filter.text) && this.list_filter.filter_tags.length <= 0)
            return this.list;
        let texts = [];
        if (!vvs.isEmptyString(this.list_filter.text)) {
            texts = this.list_filter.filter_data_whole === true ? [this.list_filter.text] : this.list_filter.text.split(' ').filter(ff => !vvs.isEmptyString(ff));
        }
        return this.list.filter(f => (texts.length <= 0 || texts.every(e => new RegExp(e, 'i').test(f.rid) || this.list_filter.filter_data_script === true && new RegExp(e, 'i').test(f.data))) && (this.list_filter.filter_tags.length <= 0 || this.list_filter.filter_tags.every(e => f.tags.some(s => new RegExp(e, 'i').test(s)))));
    },
    list_ui() {
        let filtered = this.list_filtered;
        return filtered.sort((a, b) => {
            let aa = vvs.toString(a.rid, '').toLowerCase();
            let bb = vvs.toString(b.rid, '').toLowerCase();
            if (aa > bb)
                return 1;
            if (aa < bb)
                return -1;
            return 0;
        });
    }
},
methods :{
    list_on_delete(item) {
        if (!item || !item.rid)
            return;
        this.$refs.notice.question('Are you sure you want to delete action "'.concat(item.rid, '"?'), 'Delete action', result => {
            if (result === true) {
                this.emit('delete', item);
            }
        });
    },
    list_on_click(item) {
        this.emit('select', item);
    },
    emit(command, item) {
        this.$emit('event', {
            command: command,
            item: item
        });
    }
}
})