import VueSelect from 'vue-select'; export const IssueLabel = { template: ` {{ name }} `, data() { return { labels: window.labels } }, props: { name: { type: String, required: true } }, computed: { /** * Get the name of the class to apply to the label based on the group to * which it belongs. Falls back to miscellaneous if the label does not * belong to a group or a class cannot be identified. * * @returns {string} the name of the class to apply to the label */ className() { return window.categories[this.name] || 'miscellaneous' } } } export const IssueCard = { template: `

{{ issue.title }}

{{ issue.repo }}#{{ issue.number }}   opened on {{ dateCreated }}.

`, components: { IssueLabel }, props: { issue: { type: Object, required: true }, }, computed: { dateCreated() { const dateCreated = new Date(this.issue.createdAt*1000) return dateCreated.toLocaleDateString() } } } export const App = { el: '#vue-app', template: `

No results.

`, components: { VueSelect, IssueCard }, data() { return { options: { skills: window.skills, experiences: [ {name: 'Yes, it is', code: 'beginner'}, {name: 'No, it isn\'t', code: 'experienced'} ] }, filters: { skills: [], experience: 'experienced' }, issues: [] } }, computed: { /** * Get a filtered list of issues matching the chosen skill labels. * * @returns {array} the array of filtered issues */ filteredIssues() { return window.issues.filter(issue => { // Check experience match if (this.filters.experience === 'beginner' && !issue.labels.includes('good first issue')) { return false } // Check skill set match const joinedLabels = issue.labels.join(',') if (this.filters.skills.length && !this.filters.skills.some(skill => joinedLabels.includes(skill))) { return false } return true }).sort((a, b) => b.createdAt - a.createdAt) } } }