@@ -220,6 +220,37 @@ class Files @Inject() (
220220 }
221221 }
222222
223+
224+
225+ // val fileList = files.
226+ val pager : Option [models.Pager ] = dataset match {
227+ case None => None
228+ case Some (dsId) => {
229+ datasets.get(new UUID (dsId)) match {
230+ case None => None
231+ case Some (ds) => {
232+ val lastIndex = ds.files.length - 1
233+ val index = ds.files.indexOf(id)
234+
235+ // Set prevFile / nextFile, if applicable
236+ if (index > 0 && index < lastIndex) {
237+ // Yields UUID of prevFile and nextFile
238+ Some (Pager (Some (ds.files(index - 1 )), Some (ds.files(index + 1 ))))
239+ }else if (index == 0 && index < lastIndex) {
240+ // This is the first file in the list, but not the last
241+ Some (Pager (None , Some (ds.files(index + 1 ))))
242+ } else if (index > 0 && index == lastIndex) {
243+ // This is the last file in the list, but not the first
244+ Some (Pager (Some (ds.files(index - 1 )), None ))
245+ } else {
246+ // There is one item on the list, disable paging
247+ None
248+ }
249+ }
250+ }
251+ }
252+ }
253+
223254 // call Polyglot to get all possible output formats for this file's content type
224255 current.plugin[PolyglotPlugin ] match {
225256 case Some (plugin) => {
@@ -238,7 +269,7 @@ class Files @Inject() (
238269 plugin.getOutputFormats(contentTypeEnding).map(outputFormats =>
239270 Ok (views.html.file(file, id.stringify, commentsByFile, previewsWithPreviewer, sectionsWithPreviews,
240271 extractorsActive, decodedDatasetsContaining.toList, foldersContainingFile,
241- mds, isRDFExportEnabled, extractionGroups, outputFormats, space, access, folderHierarchy.reverse.toList, decodedSpacesContaining.toList, allDecodedDatasets.toList, view_count, view_date)))
272+ mds, isRDFExportEnabled, extractionGroups, outputFormats, space, access, folderHierarchy.reverse.toList, decodedSpacesContaining.toList, allDecodedDatasets.toList, view_count, view_date, pager )))
242273 }
243274 case None =>
244275 Logger .debug(" Polyglot plugin not found" )
@@ -249,7 +280,7 @@ class Files @Inject() (
249280 // passing None as the last parameter (list of output formats)
250281 Future (Ok (views.html.file(file, id.stringify, commentsByFile, previewsWithPreviewer, sectionsWithPreviews,
251282 extractorsActive, decodedDatasetsContaining.toList, foldersContainingFile,
252- mds, isRDFExportEnabled, extractionGroups, None , space, access, folderHierarchy.reverse.toList, decodedSpacesContaining.toList, allDecodedDatasets.toList, view_count, view_date)))
283+ mds, isRDFExportEnabled, extractionGroups, None , space, access, folderHierarchy.reverse.toList, decodedSpacesContaining.toList, allDecodedDatasets.toList, view_count, view_date, pager )))
253284 }
254285 }
255286
0 commit comments