|
@ -22,6 +22,9 @@ import scalafx.scene.control.ListCell |
|
|
import scalafx.scene.control.SelectionMode |
|
|
import scalafx.scene.control.SelectionMode |
|
|
import scalafx.scene.layout.HBox |
|
|
import scalafx.scene.layout.HBox |
|
|
import scalafx.scene.text.Text |
|
|
import scalafx.scene.text.Text |
|
|
|
|
|
import scalafx.geometry.Pos |
|
|
|
|
|
import scalafx.scene.layout.BorderPane |
|
|
|
|
|
import scalafx.scene.layout.Priority |
|
|
|
|
|
|
|
|
object TodoListView { |
|
|
object TodoListView { |
|
|
def apply( |
|
|
def apply( |
|
@ -33,58 +36,18 @@ object TodoListView { |
|
|
val todos = store.map { case (_, state) => state.todos } |
|
|
val todos = store.map { case (_, state) => state.todos } |
|
|
val _selectedItems = ObjectProperty(Seq.empty[Todo]) |
|
|
val _selectedItems = ObjectProperty(Seq.empty[Todo]) |
|
|
|
|
|
|
|
|
new HBox { |
|
|
|
|
|
|
|
|
new BorderPane { |
|
|
padding = Insets(5) |
|
|
padding = Insets(5) |
|
|
val _content = StringProperty("") |
|
|
val _content = StringProperty("") |
|
|
children = Seq( |
|
|
|
|
|
new JFXTextField { |
|
|
|
|
|
text ==> _content |
|
|
|
|
|
}, |
|
|
|
|
|
new JFXListView[Todo] { |
|
|
|
|
|
|
|
|
center = new HBox { |
|
|
|
|
|
padding = Insets(5) |
|
|
|
|
|
children ++= Seq(new JFXListView[Todo] { |
|
|
|
|
|
hgrow = Priority.Always |
|
|
def selectedItems = selectionModel().selectedItems.view |
|
|
def selectedItems = selectionModel().selectedItems.view |
|
|
|
|
|
|
|
|
|
|
|
styleClass ++= Seq("text-white") |
|
|
selectionModel().selectionMode = SelectionMode.Multiple |
|
|
selectionModel().selectionMode = SelectionMode.Multiple |
|
|
selectionModel().selectedItems.observableSeqValue ==> _selectedItems |
|
|
selectionModel().selectedItems.observableSeqValue ==> _selectedItems |
|
|
|
|
|
|
|
|
stylesheets ++= Seq( |
|
|
|
|
|
(os.rel / "static" / "css" / "main.css").toString |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
style = """| |
|
|
|
|
|
| .scroll-bar:horizontal .track, |
|
|
|
|
|
| .scroll-bar:vertical .track{ |
|
|
|
|
|
| -fx-background-color:transparent; |
|
|
|
|
|
| -fx-border-color:transparent; |
|
|
|
|
|
| -fx-background-radius: 0em; |
|
|
|
|
|
| -fx-border-radius:2em; |
|
|
|
|
|
| } |
|
|
|
|
|
| |
|
|
|
|
|
| .scroll-bar:horizontal .increment-button , |
|
|
|
|
|
| .scroll-bar:horizontal .decrement-button { |
|
|
|
|
|
| -fx-background-color:transparent; |
|
|
|
|
|
| -fx-background-radius: 0em; |
|
|
|
|
|
| -fx-padding:0 0 10 0; |
|
|
|
|
|
| } |
|
|
|
|
|
| |
|
|
|
|
|
| .scroll-bar:vertical .increment-button , |
|
|
|
|
|
| .scroll-bar:vertical .decrement-button { |
|
|
|
|
|
| -fx-background-color:transparent; |
|
|
|
|
|
| -fx-background-radius: 0em; |
|
|
|
|
|
| -fx-padding:0 10 0 0; |
|
|
|
|
|
| } |
|
|
|
|
|
| .scroll-bar .increment-arrow, |
|
|
|
|
|
| .scroll-bar .decrement-arrow{ |
|
|
|
|
|
| -fx-shape:" "; |
|
|
|
|
|
| -fx-padding:0; |
|
|
|
|
|
| } |
|
|
|
|
|
| |
|
|
|
|
|
| .scroll-bar:horizontal .thumb, |
|
|
|
|
|
| .scroll-bar:vertical .thumb { |
|
|
|
|
|
| -fx-background-color:derive(black,90%); |
|
|
|
|
|
| -fx-background-insets: 2, 0, 0; |
|
|
|
|
|
| -fx-background-radius: 2em; |
|
|
|
|
|
}""".stripMargin |
|
|
|
|
|
|
|
|
|
|
|
cc += items <-- todos |
|
|
cc += items <-- todos |
|
|
|
|
|
|
|
|
val emptyCell = ObjectProperty(new HBox) |
|
|
val emptyCell = ObjectProperty(new HBox) |
|
@ -136,28 +99,43 @@ object TodoListView { |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
new JFXButton { |
|
|
|
|
|
text = "Add" |
|
|
|
|
|
// disable <== _selectedItems.map(_.length > 0) |
|
|
|
|
|
obsAction |
|
|
|
|
|
.useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store |
|
|
|
|
|
}, |
|
|
|
|
|
new JFXButton { |
|
|
|
|
|
text = "Edit" |
|
|
|
|
|
disable <== _selectedItems.map(_.length > 1) |
|
|
|
|
|
obsAction.useLazyEval( |
|
|
|
|
|
me.Task( |
|
|
|
|
|
TodoListStore.Edit( |
|
|
|
|
|
_selectedItems |
|
|
|
|
|
.map(_.headOption.map(_.id).getOrElse(-1)) |
|
|
|
|
|
.value, |
|
|
|
|
|
_content() |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bottom = new HBox { |
|
|
|
|
|
spacing = 5 |
|
|
|
|
|
padding = Insets(5) |
|
|
|
|
|
children = Seq( |
|
|
|
|
|
new JFXTextField { |
|
|
|
|
|
text ==> _content |
|
|
|
|
|
}, |
|
|
|
|
|
new JFXButton { |
|
|
|
|
|
text = "Add" |
|
|
|
|
|
alignment = Pos.Center |
|
|
|
|
|
// disable <== _selectedItems.map(_.length > 0) |
|
|
|
|
|
styleClass = Seq("btn", "btn-primary") |
|
|
|
|
|
obsAction |
|
|
|
|
|
.useLazyEval(me.Task(TodoListStore.Add(_content()))) --> store |
|
|
|
|
|
}, |
|
|
|
|
|
new JFXButton { |
|
|
|
|
|
text = "Edit" |
|
|
|
|
|
alignment = Pos.Center |
|
|
|
|
|
disable <== _selectedItems.map(_.length > 1) |
|
|
|
|
|
styleClass = Seq("btn", "btn-info") |
|
|
|
|
|
style = "" |
|
|
|
|
|
obsAction.useLazyEval( |
|
|
|
|
|
me.Task( |
|
|
|
|
|
TodoListStore.Edit( |
|
|
|
|
|
_selectedItems |
|
|
|
|
|
.map(_.headOption.map(_.id).getOrElse(-1)) |
|
|
|
|
|
.value, |
|
|
|
|
|
_content() |
|
|
|
|
|
) |
|
|
) |
|
|
) |
|
|
) |
|
|
|
|
|
) --> store |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
) --> store |
|
|
|
|
|
} |
|
|
|
|
|
) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
) |
|
|
) |
|
|