All files / app/assets/javascripts/notes discussion_filters.js

100% Statements 12/12
66.67% Branches 4/6
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35        21x   21x 1x 1x 3x       1x   1x 1x     1x               1x         20x    
import Vue from 'vue';
import DiscussionFilter from './components/discussion_filter.vue';
 
export default (store) => {
  const discussionFilterEl = document.getElementById('js-vue-discussion-filter');
 
  if (discussionFilterEl) {
    const { defaultFilter, notesFilters } = discussionFilterEl.dataset;
    const filterValues = notesFilters ? JSON.parse(notesFilters) : {};
    const filters = Object.keys(filterValues).map((entry) => ({
      title: entry,
      value: filterValues[entry],
    }));
    const props = { filters };
 
    Eif (defaultFilter) {
      props.selectedValue = parseInt(defaultFilter, 10);
    }
 
    return new Vue({
      el: discussionFilterEl,
      name: 'DiscussionFilter',
      components: {
        DiscussionFilter,
      },
      store,
      render(createElement) {
        return createElement('discussion-filter', { props });
      },
    });
  }
 
  return null;
};