Skip to content

Commit 81d8495

Browse files
committed
Reverse sort order, disable (instead of hiding) inactive Pager buttons
1 parent 6e0046d commit 81d8495

File tree

2 files changed

+45
-49
lines changed

2 files changed

+45
-49
lines changed

app/controllers/Files.scala

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -220,31 +220,28 @@ class Files @Inject() (
220220
}
221221
}
222222

223-
224-
225-
//val fileList = files.
226-
val pager: Option[models.Pager] = dataset match {
227-
case None => None
223+
val pager: models.Pager = dataset match {
224+
case None => Pager(None, None)
228225
case Some(dsId) => {
229226
datasets.get(new UUID(dsId)) match {
230-
case None => None
227+
case None => Pager(None, None)
231228
case Some(ds) => {
232229
val lastIndex = ds.files.length - 1
233230
val index = ds.files.indexOf(id)
234231

235232
// Set prevFile / nextFile, if applicable
236233
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))))
234+
// Yields UUID of prevFile and nextFile respectively
235+
Pager(Some(ds.files(index + 1)), Some(ds.files(index - 1)))
239236
}else if (index == 0 && index < lastIndex) {
240237
// This is the first file in the list, but not the last
241-
Some(Pager(None, Some(ds.files(index + 1))))
238+
Pager(Some(ds.files(index + 1)), None)
242239
} else if (index > 0 && index == lastIndex) {
243240
// This is the last file in the list, but not the first
244-
Some(Pager(Some(ds.files(index - 1)), None))
241+
Pager(None, Some(ds.files(index - 1)))
245242
} else {
246243
// There is one item on the list, disable paging
247-
None
244+
Pager(None, None)
248245
}
249246
}
250247
}

app/views/file.scala.html

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
rdfExported: Boolean,
77
extractionsStatus: Map[String, ExtractionGroup], outputFormats: Option[List[String]], spaceId: Option[String], access:String,
88
folderHierarchy: List[Folder], spaces:List[ProjectSpace], allDatasets: List[Dataset],
9-
view_count: Int, view_date: java.util.Date, pager: Option[models.Pager])(implicit user: Option[models.User], request: RequestHeader)
9+
view_count: Int, view_date: java.util.Date, pager: models.Pager)(implicit user: Option[models.User], request: RequestHeader)
1010

1111
@import helper._
1212
@import play.api.Play.current
@@ -198,44 +198,43 @@
198198
@** Only enable paging when viewing from a dataset? *@
199199
@if(allDatasets.length == 1) {
200200
@allDatasets.map { ds =>
201-
@pager match {
202-
case None => {}
203-
case Some(pg) => {
204-
<div class="row bottom-padding">
205-
<div class="col-sm-12 col-md-12 col-lg-12">
206-
@pg.prev match {
207-
case None => {}
208-
case Some(prev) => {
209-
<a class="btn btn-sm btn-link" style="border-radius:15px;border-color:lightgray;" href="@routes.Files.file(prev, if(datasets.length > 0) {
210-
Some(datasets.head.id.stringify)
211-
} else {
212-
None
213-
}, spaceId, if(folders.length > 0) {
214-
Some(folders.head.id.stringify)
215-
} else {
216-
None
217-
})"><i class="glyphicon glyphicon-chevron-left"></i> Prev</a>
218-
}
219-
}
220-
@pg.next match {
221-
case None => {}
222-
case Some(next) => {
223-
<a class="btn btn-sm btn-link" style="border-radius:15px;border-color:lightgray;" href="@routes.Files.file(next, if(datasets.length > 0) {
224-
Some(datasets.head.id.stringify)
225-
} else {
226-
None
227-
}, spaceId, if(folders.length > 0) {
228-
Some(folders.head.id.stringify)
229-
} else {
230-
None
231-
})">Next <i class="glyphicon glyphicon-chevron-right"></i></a>
232-
}
233-
}
201+
<div class="row bottom-padding">
202+
<div class="col-sm-12 col-md-12 col-lg-12">
203+
@pager.prev match {
204+
case None => {
205+
<button class="btn btn-sm btn-link disabled" disabled="true" style="cursor:not-allowed;border-radius:15px;border-color:lightgray;"><i class="glyphicon glyphicon-chevron-left"></i> Prev</button>
206+
}
207+
case Some(prev) => {
208+
<a class="btn btn-sm btn-link" style="border-radius:15px;border-color:lightgray;" href="@routes.Files.file(prev, if(datasets.length > 0) {
209+
Some(datasets.head.id.stringify)
210+
} else {
211+
None
212+
}, spaceId, if(folders.length > 0) {
213+
Some(folders.head.id.stringify)
214+
} else {
215+
None
216+
})"><i class="glyphicon glyphicon-chevron-left"></i> Prev</a>
217+
}
218+
}
219+
@pager.next match {
220+
case None => {
221+
<button class="btn btn-sm btn-link disabled" disabled="true" style="cursor:not-allowed;border-radius:15px;border-color:lightgray;">Next <i class="glyphicon glyphicon-chevron-right"></i></button>
222+
}
223+
case Some(next) => {
224+
<a class="btn btn-sm btn-link" style="border-radius:15px;border-color:lightgray;" href="@routes.Files.file(next, if(datasets.length > 0) {
225+
Some(datasets.head.id.stringify)
226+
} else {
227+
None
228+
}, spaceId, if(folders.length > 0) {
229+
Some(folders.head.id.stringify)
230+
} else {
231+
None
232+
})">Next <i class="glyphicon glyphicon-chevron-right"></i></a>
233+
}
234+
}
234235

235-
</div>
236-
</div>
237-
}
238-
}
236+
</div>
237+
</div>
239238
}
240239
}
241240
</div>

0 commit comments

Comments
 (0)