Skip to content

Commit acb8f1d

Browse files
committed
Adding subject filter bar on notes list.
1 parent 18afe42 commit acb8f1d

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
"confidential": "confidential",
4949
"It is confidential": "It is confidential",
5050
"The note will not be displayed by default, you will have to ask to show it": "The note will not be displayed by default, you will have to ask to show it",
51-
"Subjects": "Subjects"
51+
"Subjects": "Subjects",
52+
"Filter": "Filter"
5253
}

src/locales/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@
4848
"confidential": "confidentiel",
4949
"It is confidential": "C'est confidentiel",
5050
"The note will not be displayed by default, you will have to ask to show it": "La note ne sera pas affichée par défaut, vous devrez demander à l'afficher",
51-
"Subjects": "Sujets"
51+
"Subjects": "Sujets",
52+
"Filter": "Filtrer"
5253
}

src/views/EditNote.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
v-combobox(
1616
chips,
1717
deletable-chips,
18+
small-chips,
1819
multiple,
1920
:label="$t('Subjects')",
2021
v-model="dbDoc.subjects",

src/views/Notes.vue

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@ div
88
span {{ $t('There is no notes') }}.
99
br
1010
router-link(style="color:white;", :to="{name: 'edit-note', params: {id: 1}}") {{ $t('Create a note') }}
11+
v-autocomplete(
12+
v-model="subjectsFilters",
13+
:items="Object.keys($store.state.subjects)",
14+
:label="$t('Filter')",
15+
class="mb-2 mx-1",
16+
prepend-inner-icon="filter_list",
17+
flat, multiple, dense, chips, deletable-chips, small-chips, clearable, solo, hide-no-data, hide-details)
1118
v-layout(wrap)
12-
v-flex(v-for="note in notes", :key="note._id", pa-1, d-flex)
19+
v-flex(v-for="note in filtered_notes", :key="note._id", pa-1, d-flex)
1320
note-display(:id="note._id", :title="note.title", :content="note.content", :confidential="note.confidential", :subjects="note.subjects")
1421
v-btn(large, icon, fixed, bottom, right, color="primary", :to="{name: 'edit-note', params: {id: 1}}")
1522
v-icon add
@@ -20,10 +27,31 @@ import NoteDisplay from '@/components/note-display.vue';
2027
2128
export default {
2229
name: 'notes',
30+
data() {
31+
return {
32+
subjectsFilters: [],
33+
};
34+
},
2335
components: {
2436
'note-display': NoteDisplay,
2537
},
2638
computed: {
39+
filtered_notes () {
40+
return this.notes.filter((note) => {
41+
let result = !(this.subjectsFilters.length > 0);
42+
43+
if(typeof(note.subjects) !== 'undefined') {
44+
for (let i = 0; i < note.subjects.length; i++) {
45+
if(this.subjectsFilters.includes(note.subjects[i])) {
46+
result = true;
47+
break;
48+
}
49+
}
50+
}
51+
52+
return result;
53+
});
54+
},
2755
notes () {
2856
return Object.keys(this.$store.state.notes).map((key) => {
2957
return this.$store.state.notes[key];

0 commit comments

Comments
 (0)