Skip to content

Commit c0b7d46

Browse files
committed
Adding *no subject* filter + fixing issue on changed data after edit note.
1 parent ebbd385 commit c0b7d46

7 files changed

Lines changed: 678 additions & 881 deletions

File tree

src/locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"Include confidential notes": "Include confidential notes",
5656
"In order to save your data, just copy and paste the following data in an text editor (like notepad), and then save it as *.json file.": "In order to save your data, just copy and paste the following data in an text editor (like notepad), and then save it as *.json file.",
5757
"Please paste your data in the following field and click on the button in the the bottom of the page, in order to load them in this app.": "Please paste your data in the following field and click on the button in the the bottom of the page, in order to load them in this app.",
58-
"The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit.": "The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit."
58+
"The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit.": "The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit.",
59+
"no subject": "no subject"
5960
}

src/locales/fr-FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
"Include confidential notes": "Intégrer les notes confidentielles",
5656
"In order to save your data, just copy and paste the following data in an text editor (like notepad), and then save it as *.json file.": "Pour sauvegarder vos données, copiez et collez simplement les données dans un éditeur de texte (comme le bloc-notes) et enregistrez le ensuite comme un fichier *.json.",
5757
"Please paste your data in the following field and click on the button in the the bottom of the page, in order to load them in this app.": "Veuillez coller vos données dans le champ suivant et clicker sur le bouton en bas de la page pour les importer dans cette application.",
58-
"The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit.": "La note n'est pas enregistrée, vous allez perdre les changements si vous quittez la page. Veuillez confirmer que vous souhaitez partir maintenant."
58+
"The note is not saved, you will lost the changes if your are leaving the page. Please confirm the exit.": "La note n'est pas enregistrée, vous allez perdre les changements si vous quittez la page. Veuillez confirmer que vous souhaitez partir maintenant.",
59+
"no subject": "pas de sujet"
5960
}

src/views/EditNote.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,12 @@ export default {
5656
},
5757
watch: {
5858
dbDoc: {
59-
handler: function() {
60-
this.changed = true;
59+
handler: function(value, oldValue) {
60+
if(oldValue._id === value._id && oldValue._rev === value._rev) {
61+
this.changed = true;
62+
} else {
63+
this.changed = false;
64+
}
6165
},
6266
deep: true,
6367
},

src/views/ExportData.vue

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ div
88
v-toolbar(color="primary")
99
v-toolbar-side-icon
1010
v-icon archive
11-
v-toolbar-title {{ $t('Export your data') }}
11+
v-toolbar-title {{ $t('Export your data manually') }}
1212
v-card-text
1313
v-autocomplete(
1414
v-model="subjectsFilters",
15-
:items="Object.keys($store.state.subjects)",
15+
:items="filters",
1616
:label="$t('Filter')",
1717
class="mb-2 mx-1",
1818
prepend-inner-icon="filter_list",
@@ -51,17 +51,23 @@ export default {
5151
}
5252
5353
const subjectFilter = function() {
54-
let result = false;
54+
let result = !(that.subjectsFilters.length > 0);
5555
56-
if(that.subjectsFilters.length > 0 && typeof(note.subjects) !== 'undefined') {
57-
for (let i = 0; i < note.subjects.length; i++) {
58-
if(that.subjectsFilters.includes(note.subjects[i])) {
59-
result = true;
60-
break;
56+
if(typeof(note.subjects) !== 'undefined') {
57+
if(that.subjectsFilters.includes('*' + that.$t('no subject') + '*') && note.subjects.length === 0) {
58+
result = true;
59+
} else {
60+
for (let i = 0; i < note.subjects.length; i++) {
61+
if(that.subjectsFilters.includes(note.subjects[i])) {
62+
result = true;
63+
break;
64+
}
6165
}
6266
}
6367
} else {
64-
result = true;
68+
if(that.subjectsFilters.includes('*' + that.$t('no subject') + '*')) {
69+
result = true;
70+
}
6571
}
6672
6773
return result;
@@ -74,14 +80,21 @@ export default {
7480
return JSON.stringify(
7581
{
7682
notes: {
77-
filters: this.subjectsFilters,
83+
filters: this.subjectsFilters.map((filter) => { return (filter === '*' + this.$t('no subject') + '*') ? '*no subject*' : filter; }),
7884
add_confidential: this.confidentials,
7985
items: this.filtered_notes,
8086
},
8187
app_version: require('../../package.json').version,
8288
date: new Date(),
8389
}, null, (this.readable) ? '\t': '');
8490
},
91+
filters() {
92+
let result = ['*' + this.$t('no subject') + '*'];
93+
94+
result = result.concat(Object.keys(this.$store.state.subjects));
95+
96+
return result;
97+
}
8598
},
8699
};
87100
</script>

src/views/ImportData.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ div
88
v-toolbar(color="primary")
99
v-toolbar-side-icon
1010
v-icon unarchive
11-
v-toolbar-title {{ $t('Import your data') }}
11+
v-toolbar-title {{ $t('Import your data manually') }}
1212
v-card-text
1313
v-alert(type="info", :value="true") {{ $t('Please paste your data in the following field and click on the button in the the bottom of the page, in order to load them in this app.') }}
1414
v-divider(class="my-3")

src/views/Notes.vue

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@ div
55
v-icon event_note
66
v-toolbar-title {{ $t('Notes') }}
77
v-spacer
8-
v-toolbar-actions
9-
v-tooltip(bottom)
10-
v-btn(icon, :to="{name:'export-data'}", slot="activator")
11-
v-icon archive
12-
span {{ $t('Import your data manually') }}
13-
v-tooltip(bottom)
14-
v-btn(icon, :to="{name:'import-data'}", slot="activator")
15-
v-icon unarchive
16-
span {{ $t('Export your data manually') }}
8+
v-tooltip(bottom)
9+
v-btn(icon, :to="{name:'export-data'}", slot="activator")
10+
v-icon archive
11+
span {{ $t('Import your data manually') }}
12+
v-tooltip(bottom)
13+
v-btn(icon, :to="{name:'import-data'}", slot="activator")
14+
v-icon unarchive
15+
span {{ $t('Export your data manually') }}
1716
v-alert(type="info", :value="notes.length <= 0")
1817
span {{ $t('There is no notes') }}.
1918
br
2019
router-link(style="color:white;", :to="{name: 'edit-note', params: {id: 1}}") {{ $t('Create a note') }}
2120
v-autocomplete(
2221
v-model="subjectsFilters",
23-
:items="Object.keys($store.state.subjects)",
22+
:items="availableSubjects",
2423
:label="$t('Filter')",
2524
class="mb-2 mx-1",
2625
prepend-inner-icon="filter_list",
@@ -53,27 +52,42 @@ export default {
5352
},
5453
},
5554
computed: {
56-
filtered_notes () {
55+
filtered_notes() {
5756
return this.notes.filter((note) => {
5857
let result = !(this.subjectsFilters.length > 0);
5958
6059
if(typeof(note.subjects) !== 'undefined') {
61-
for (let i = 0; i < note.subjects.length; i++) {
62-
if(this.subjectsFilters.includes(note.subjects[i])) {
63-
result = true;
64-
break;
60+
if(this.subjectsFilters.includes('*' + this.$t('no subject') + '*') && note.subjects.length === 0) {
61+
result = true;
62+
} else {
63+
for (let i = 0; i < note.subjects.length; i++) {
64+
if(this.subjectsFilters.includes(note.subjects[i])) {
65+
result = true;
66+
break;
67+
}
6568
}
6669
}
70+
} else {
71+
if(this.subjectsFilters.includes('*' + this.$t('no subject') + '*')) {
72+
result = true;
73+
}
6774
}
6875
6976
return result;
7077
});
7178
},
72-
notes () {
79+
notes() {
7380
return Object.keys(this.$store.state.notes).map((key) => {
7481
return this.$store.state.notes[key];
7582
});
7683
},
84+
availableSubjects() {
85+
let result = ['*' + this.$t('no subject') + '*'];
86+
87+
result = result.concat(Object.keys(this.$store.state.subjects));
88+
89+
return result;
90+
}
7791
},
7892
methods: {
7993
saveFilter() {

0 commit comments

Comments
 (0)