Skip to content

Commit 1724d29

Browse files
Andrew Reitanoc-w
authored andcommitted
Enable sorting of documents in frontend
1 parent e39b3a1 commit 1724d29

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
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
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
@@ -52,6 +52,7 @@ export default {
5252
url: '',
5353
offset: getOffsetFromUrl(window.location.href),
5454
picked: 'all',
55+
ordering: '',
5556
count: 0,
5657
isSuperuser: false,
5758
isMetadataActive: false,
@@ -109,7 +110,7 @@ export default {
109110

110111
async submit() {
111112
const state = this.getState();
112-
this.url = `docs?q=${this.searchQuery}&is_checked=${state}&offset=${this.offset}`;
113+
this.url = `docs?q=${this.searchQuery}&is_checked=${state}&offset=${this.offset}&ordering=${this.ordering}`;
113114
await this.search();
114115
this.pageNumber = 0;
115116
},
@@ -155,6 +156,11 @@ export default {
155156
this.submit();
156157
},
157158

159+
ordering() {
160+
this.offset = 0;
161+
this.submit();
162+
},
163+
158164
annotations() {
159165
// fetch progress info.
160166
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)