Skip to content

Commit 22e74cf

Browse files
authored
Merge pull request doccano#319 from CatalystCode/enhancement/document-sort-order
Enable sorting of documents in frontend
2 parents ff892d4 + 65f8079 commit 22e74cf

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

app/server/static/components/annotation.pug

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ div.columns(v-cloak="")
5555
div.main.pt0.pb0.pr20.pl20
5656
span About {{ count }} results (page {{ paginationPage }} of {{ paginationPages }})
5757

58+
div.main.pt0.pb0.pr20.pl20
59+
div.select
60+
select(v-model="ordering")
61+
option(value="", disabled, selected) Sort by
62+
option(value="created_at") Created : Ascending
63+
option(value="-created_at") Created : Descending
64+
option(value="updated_at") Updated : Ascending
65+
option(value="-updated_at") Updated : Descending
66+
5867
div.main.sidebar-scrollable
5968
a.item(
6069
v-for="(doc, index) in docs"

app/server/static/components/annotationMixin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export default {
8787
url: '',
8888
offset: getOffsetFromUrl(window.location.href),
8989
picked: 'all',
90+
ordering: '',
9091
count: 0,
9192
prevLimit: 0,
9293
paginationPages: 0,
@@ -188,7 +189,7 @@ export default {
188189

189190
async submit() {
190191
const state = this.getState();
191-
this.url = `docs?q=${this.searchQuery}&is_checked=${state}&offset=${this.offset}`;
192+
this.url = `docs?q=${this.searchQuery}&is_checked=${state}&offset=${this.offset}&ordering=${this.ordering}`;
192193
await this.search();
193194
this.pageNumber = 0;
194195
},
@@ -234,6 +235,11 @@ export default {
234235
this.submit();
235236
},
236237

238+
ordering() {
239+
this.offset = 0;
240+
this.submit();
241+
},
242+
237243
annotations() {
238244
// fetch progress info.
239245
HTTP.get('statistics').then((response) => {

app/server/static/components/document_classification.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default {
6464
6565
async submit() {
6666
const state = this.getState();
67-
this.url = `docs?q=${this.searchQuery}&doc_annotations__isnull=${state}&offset=${this.offset}`;
67+
this.url = `docs?q=${this.searchQuery}&doc_annotations__isnull=${state}&offset=${this.offset}&ordering=${this.ordering}`;
6868
await this.search();
6969
this.pageNumber = 0;
7070
},

app/server/static/components/seq2seq.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export default {
105105
106106
async submit() {
107107
const state = this.getState();
108-
this.url = `docs?q=${this.searchQuery}&seq2seq_annotations__isnull=${state}&offset=${this.offset}`;
108+
this.url = `docs?q=${this.searchQuery}&seq2seq_annotations__isnull=${state}&offset=${this.offset}&ordering=${this.ordering}`;
109109
await this.search();
110110
this.pageNumber = 0;
111111
},

app/server/static/components/sequence_labeling.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default {
6666
6767
async submit() {
6868
const state = this.getState();
69-
this.url = `docs?q=${this.searchQuery}&seq_annotations__isnull=${state}&offset=${this.offset}`;
69+
this.url = `docs?q=${this.searchQuery}&seq_annotations__isnull=${state}&offset=${this.offset}&ordering=${this.ordering}`;
7070
await this.search();
7171
this.pageNumber = 0;
7272
},

0 commit comments

Comments
 (0)