Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq committed Aug 1, 2018
1 parent 56f3f8e commit 102b039
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,16 @@ class FolderFileList(filesRx: Rx[Set[File]], flat: Boolean)(implicit context: Ap
table.createTable(filesSeqRx)
}

lazy val previewsFileTable = PreviewsFileTable(filesSeqRx, selectedFile)

def renderTag(md: ModifierT*): TagT = {
val viewSelectButton = Button(ButtonStyle.info)(AppIcons.changeView, context.locale.changeView, onclick := Callback.onClick(_ changeListView()))
val uploadForm = UploadForm()(context, folderContext, fileController)
div(
div(ButtonGroup(ButtonGroupSize.extraSmall, uploadForm.renderButton(), viewSelectButton)),
Rx(div {
if (selectedView() == "previews") {
RichFileTable(filesSeqRx, selectedFile).renderTag(md:_*)
previewsFileTable.renderTag(md:_*)
} else {
fileTable.renderTag(md:_*)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import scalaTags.all._
import com.karasiq.shadowcloud.model.File
import com.karasiq.shadowcloud.webapp.context.{AppContext, FolderContext}

private[folder] object RichFileTable {
private[folder] object PreviewsFileTable {
def apply(files: Rx[Seq[File]], selectedFile: Var[Option[File]])
(implicit context: AppContext, fc: FolderContext): RichFileTable = {
new RichFileTable(files, selectedFile)
(implicit context: AppContext, fc: FolderContext): PreviewsFileTable = {
new PreviewsFileTable(files, selectedFile)
}
}

private[folder] class RichFileTable(files: Rx[Seq[File]], selectedFile: Var[Option[File]])
(implicit context: AppContext, fc: FolderContext) extends BootstrapHtmlComponent {
private[folder] class PreviewsFileTable(files: Rx[Seq[File]], selectedFile: Var[Option[File]])
(implicit context: AppContext, fc: FolderContext) extends BootstrapHtmlComponent {

private[this] lazy val sortedFiles = Rx {
val allFiles = files()
val filtered = {
val filterStr = filter()
if (filterStr.isEmpty) allFiles
else allFiles.filter(_.toString.toLowerCase.contains(filterStr.toLowerCase))
else allFiles.filter(_.path.name.toLowerCase.contains(filterStr.toLowerCase))
}
val sorted = sortTypes(sortType()) match {
case s if s == context.locale.name filtered.sortBy(_.path.name)
Expand All @@ -43,12 +43,12 @@ private[folder] class RichFileTable(files: Rx[Seq[File]], selectedFile: Var[Opti

lazy val pageSelector = PageSelector(pagesRx)

def renderTag(md: ModifierT*): TagT = {
val currentPageFiles = Rx {
val page = pageSelector.currentPage() min pagesRx()
sortedFiles().slice(rowsPerPage * (page - 1), rowsPerPage * (page - 1) + rowsPerPage)
}
lazy val currentPageFiles = Rx {
val page = pageSelector.currentPage() min pagesRx()
sortedFiles().slice(rowsPerPage * (page - 1), rowsPerPage * (page - 1) + rowsPerPage)
}

def renderTag(md: ModifierT*): TagT = {
val filterField = Form(FormInput.text("", filter.reactiveInput))

val sortLine = Rx {
Expand Down

0 comments on commit 102b039

Please sign in to comment.