Task cards now have a color.

This commit is contained in:
Luka Vandervelden 2019-07-08 06:31:13 +02:00
parent bb8fb3ec1f
commit 84ca28f322
5 changed files with 45 additions and 3 deletions

View File

@ -49,7 +49,7 @@ Task = (self, project) ->
is-selected = model.selected == self.id is-selected = model.selected == self.id
h \div.card { h (\div.card.is- + (self.color || "dark")), {
key: self.id key: self.id
classes: { classes: {
"is-selected": is-selected "is-selected": is-selected
@ -175,6 +175,31 @@ Task = (self, project) ->
} [ "Assign" ] } [ "Assign" ]
] ]
if is-selected
h \div.card-footer {key: "color"} [
if model.editing == self.id + ".color"
h \div.card-footer-item {
key: "color.clicked"
} [
h \input.input {
onchange: (e) ->
model.editing := undefined
socket.send JSON.stringify {
type: "edit-task"
project: project.id
task: self.id
color: e.target.value
}
}
]
else
h \div.card-footer-item {
key: "assign"
onclick: ->
model.editing := self.id + ".color"
} [ "Change Color" ]
]
if is-selected if is-selected
h \div.card-footer {key: "move"} [ h \div.card-footer {key: "move"} [
h \div.card-footer-item { h \div.card-footer-item {

View File

@ -25,3 +25,10 @@
.project .project
margin-top: 12px margin-top: 12px
@each $name, $pair in $colors
$color: nth($pair, 1)
$color-invert: nth($pair, 2)
.card.is-#{$name}
background-color: darken($color, 30)

View File

@ -184,6 +184,10 @@ ws "/socket" do |socket|
task.description = description task.description = description
end end
if color = request.color
task.color = color
end
# FIXME: Check its a valid UID. # FIXME: Check its a valid UID.
if assigned_to = request.assigned_to if assigned_to = request.assigned_to
# FIXME: Probably not the best way to handle this corner-case. # FIXME: Probably not the best way to handle this corner-case.

View File

@ -57,7 +57,8 @@ class Requests::EditTask
column: String?, column: String?,
title: String?, title: String?,
description: String?, description: String?,
assigned_to: Int32? assigned_to: Int32?,
color: String?
}) })
end end

View File

@ -7,11 +7,16 @@ class Task
title: String, title: String,
description: String, description: String,
column: String, column: String,
assigned_to: Int32? assigned_to: Int32?,
color: {
type: String,
default: "dark"
}
}) })
def initialize(@title, @author, @description, @column) def initialize(@title, @author, @description, @column)
@id = UUID.random.to_s @id = UUID.random.to_s
@color = "dark"
end end
end end