.extra_properties.assignee-id => .assigned_to
This commit is contained in:
parent
f096fcec4f
commit
d4d21dd3fa
@ -6,6 +6,9 @@ Modal = require './modal.ls'
|
||||
|
||||
{field, input, textarea, label, control, select} = require './bulma.ls'
|
||||
|
||||
# FIXME: This be a copy-pasta. Somebody gotta touch this spaghetti.
|
||||
const PERMISSION_LEVELS = ["admin", "edit", "read"]
|
||||
|
||||
colors = [
|
||||
"white"
|
||||
"black"
|
||||
@ -40,10 +43,11 @@ color-to-form-selection = (self, color, current-color) ->
|
||||
selected: current-color && current-color == color
|
||||
} [ color ]
|
||||
|
||||
user-form-selection = (self, user) ->
|
||||
user-form-selection = (self, uid, is-selected) ->
|
||||
h \option {
|
||||
value: user.uid
|
||||
} [ user.login ]
|
||||
selected: is-selected
|
||||
value: uid.to-string!
|
||||
} [ uid.to-string! ]
|
||||
|
||||
TaskCreationModal = (project, todod-ws, task, users) ->
|
||||
task ||= {}
|
||||
@ -52,12 +56,10 @@ TaskCreationModal = (project, todod-ws, task, users) ->
|
||||
self = {
|
||||
title: task.title || ""
|
||||
description: task.description || ""
|
||||
assigned_to: task.assigned_to
|
||||
extra_properties:
|
||||
column: ""
|
||||
background-color: ""
|
||||
assignee-id: task.assignee-id || void
|
||||
tmp:
|
||||
users: users || []
|
||||
}
|
||||
|
||||
# copy extra properties
|
||||
@ -126,11 +128,22 @@ TaskCreationModal = (project, todod-ws, task, users) ->
|
||||
} [
|
||||
select \.is-fullwidth {
|
||||
onchange: (e) ->
|
||||
self.extra_properties.assignee-id := e.target.value
|
||||
if uid = parse-int e.target.value
|
||||
self.assigned_to := uid
|
||||
else
|
||||
self.assigned_to := void
|
||||
} [
|
||||
user-form-selection self, { login: "Choose a user", uid: "-" }
|
||||
for user-id, user of self.tmp.users
|
||||
user-form-selection self, user
|
||||
h \option {
|
||||
default: true
|
||||
value: ""
|
||||
} [ "(unassigned)" ]
|
||||
|
||||
for permission in PERMISSION_LEVELS
|
||||
[
|
||||
for uid in project.permissions[permission]
|
||||
user-form-selection self, uid,
|
||||
(self.assigned_to == uid)
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
|
@ -6,16 +6,12 @@ TaskRemovalModal = require './task-removal-modal.ls'
|
||||
|
||||
{icon} = require "./font-awesome.ls"
|
||||
|
||||
display-login = (task, users) ->
|
||||
if task.extra_properties && task.extra_properties.assignee-id && users && users[task.extra_properties.assignee-id] && users[task.extra_properties.assignee-id].login
|
||||
h \p [ '@' + users[task.extra_properties.assignee-id].login ]
|
||||
else
|
||||
h \p [ '-' ]
|
||||
|
||||
|
||||
Task = (self, project, todod-ws) ->
|
||||
modal = void
|
||||
|
||||
self.render-login = (uid) ->
|
||||
h \p [ '@' + uid.to-string! ]
|
||||
|
||||
self.render = (args) ->
|
||||
args or= {}
|
||||
|
||||
@ -47,7 +43,8 @@ Task = (self, project, todod-ws) ->
|
||||
# FIXME: assignee card image
|
||||
]
|
||||
h \div.media-content [
|
||||
display-login self, project.users
|
||||
if uid = self.assigned_to
|
||||
self.render-login uid
|
||||
]
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user