-
Notifications
You must be signed in to change notification settings - Fork 16
/
publisher.update_requests.edge.js
160 lines (142 loc) · 6.44 KB
/
publisher.update_requests.edge.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
$.extend(true, doaj, {
publisherUpdatesSearch : {
activeEdges : {},
publisherStatusMap: function(value) {
if (doaj.valueMaps.applicationStatus.hasOwnProperty(value)) {
return doaj.valueMaps.applicationStatus[value];
}
return value;
},
editUpdateRequest : function (resultobj) {
if (resultobj.admin && resultobj.admin.application_status) {
var result = {label : "", link : ""};
var status = resultobj.admin.application_status;
result.link = doaj.publisherUpdatesSearchConfig.journalReadOnlyUrl + resultobj['id'];
result.label = '<span data-feather="eye" aria-hidden="true"></span><span>View</span>';
if (status === "update_request" || status === "revisions_required") {
result.link = doaj.publisherUpdatesSearchConfig.journalUpdateUrl + resultobj.admin.current_journal;
result.label = '<span data-feather="edit-3" aria-hidden="true"></span><span>Edit</span>';
}
return result;
}
return false;
},
init : function(params) {
if (!params) {
params = {};
}
var current_domain = document.location.host;
var current_scheme = window.location.protocol;
var selector = params.selector || "#publisher_update_requests";
var search_url = current_scheme + "//" + current_domain + doaj.publisherUpdatesSearchConfig.searchPath;
var countFormat = edges.numFormat({
thousandsSeparator: ","
});
var components = [
doaj.components.searchingNotification(),
// facets
edges.newORTermSelector({
id: "application_status",
category: "facet",
field: "admin.application_status.exact",
display: "Application Status",
size: 99,
valueFunction: doaj.publisherUpdatesSearch.publisherStatusMap,
syncCounts: false,
lifecycle: "update",
renderer : doaj.renderers.newORTermSelectorRenderer({
showCount: true,
hideEmpty: true,
open: true,
togglable: false
})
}),
edges.newFullSearchController({
id: "sort_by",
category: "controller",
sortOptions : [
{'display':'Added to DOAJ (newest first)','field':'created_date', "dir" : "desc"},
{'display':'Added to DOAJ (oldest first)','field':'created_date', "dir" : "asc"},
{'display':'Last updated (most recent first)','field':'last_manual_update', "dir" : "desc"},
{'display':'Last updated (less recent first)','field':'last_manual_update', "dir" : "asc"},
{'display':'Title (A-Z)','field':'index.unpunctitle.exact', "dir" : "asc"},
{'display':'Title (Z-A)','field':'index.unpunctitle.exact', "dir" : "desc"},
{'display':'Relevance','field':'_score'}
],
renderer: doaj.renderers.newSortRenderer({
prefix: "Sort by",
dirSwitcher: false
})
}),
edges.newPager({
id: "rpp",
category: "pager",
renderer : doaj.renderers.newPageSizeRenderer({
sizeOptions: [50, 100, 200],
sizeLabel: "Results per page"
})
}),
// the pager, with the explicitly set page size options (see the openingQuery for the initial size)
edges.newPager({
id: "top-pager",
category: "top-pager",
renderer : doaj.renderers.newPagerRenderer({
numberFormat: countFormat
})
}),
edges.newPager({
id: "bottom-pager",
category: "bottom-pager",
renderer : doaj.renderers.newPagerRenderer({
numberFormat: countFormat
})
}),
// results display
edges.newResultsDisplay({
id: "results",
category: "results",
renderer : doaj.renderers.newPublisherUpdateRequestRenderer({
actions: [
doaj.publisherUpdatesSearch.editUpdateRequest
]
})
}),
// selected filters display, with all the fields given their display names
edges.newSelectedFilters({
id: "selected-filters",
category: "selected-filters",
fieldDisplays: {
'admin.application_status.exact': 'Application Status'
},
renderer : doaj.renderers.newSelectedFiltersRenderer()
})
];
var e = edges.newEdge({
selector: selector,
template: doaj.templates.newPublicSearch({
titleBar: false,
title: "Update requests"
}),
search_url: search_url,
manageUrl: true,
openingQuery: es.newQuery({
sort: [{"field" : "last_manual_update", "order" : "desc"}],
size: 50
}),
components: components,
callbacks : {
"edges:query-fail" : function() {
alert("There was an unexpected error. Please reload the page and try again. If the issue persists please contact us.");
},
"edges:post-init" : function() {
feather.replace();
}
}
});
doaj.publisherUpdatesSearch.activeEdges[selector] = e;
}
}
});
jQuery(document).ready(function($) {
doaj.publisherUpdatesSearch.init();
});