+import gleam/dynamic
+import gleam/dynamic/decode
import gleam/int
import gleam/json
import gleam/list
field(fields, "assignees"),
model.task_subteams,
field(fields, "due_date"),
+ list.key_find(fields, "defcon")
+ |> result.unwrap("")
+ |> dynamic.string
+ |> decode.run(decode.int)
+ |> result.unwrap(0),
)
|> shared.new_task_json
#(
text_input("assignee", "Owner"),
text_input("assignees", "Assignees"),
text_input("due_date", "Due (MM/DD/YY)"),
+ text_input("defcon", "DEFCON"),
subteam_checkboxes(model.task_subteams),
html.textarea(
[
html.small([], [html.text("Subteams")]),
html.text(if_blank(join_subteams(task.subteams), "No subteam")),
]),
+ html.div([attribute.class("task-person")], [
+ html.small([], [html.text("DEFCON")]),
+ html.text(if_blank(int.to_string(task.defcon), "0")),
+ ]),
html.div([attribute.class("task-due")], [
html.small([], [html.text("Due")]),
html.text(case task.due_date {
arg_5: String,
arg_6: List(Subteam),
arg_7: String,
+ arg_8: Int,
) -> Result(pog.Returned(CreateTaskRow), pog.QueryError) {
let decoder = {
use id <- decode.field(0, decode.int)
assignee,
assignees,
subteams,
- due_date
+ due_date,
+ defcon
)
-values ($1, $2, $3, $4, $5, $6::subteam[], nullif($7, '')::date)
+values ($1, $2, $3, $4, $5, $6::subteam[], nullif($7, '')::date, $8)
returning id
"
|> pog.query
|> pog.parameter(pog.text(arg_5))
|> pog.parameter(pog.array(fn(value) { subteam_encoder(value) }, arg_6))
|> pog.parameter(pog.text(arg_7))
+ |> pog.parameter(pog.int(arg_8))
|> pog.returning(decoder)
|> pog.execute(db)
}
status: String,
assignee: String,
assignees: String,
+ defcon: Int,
subteams: String,
due_date: String,
)
use status <- decode.field(4, decode.string)
use assignee <- decode.field(5, decode.string)
use assignees <- decode.field(6, decode.string)
- use subteams <- decode.field(7, decode.string)
- use due_date <- decode.field(8, decode.string)
+ use defcon <- decode.field(7, decode.int)
+ use subteams <- decode.field(8, decode.string)
+ use due_date <- decode.field(9, decode.string)
decode.success(ListTasksRow(
id:,
project_id:,
status:,
assignee:,
assignees:,
+ defcon:,
subteams:,
due_date:,
))
status,
assignee,
assignees,
+ defcon,
coalesce(array_to_string(subteams, ','), '') as subteams,
coalesce(due_date::text, '') as due_date
from task
function bool2(input) {
return identity2(input);
}
+function int3(input) {
+ return identity2(input);
+}
function object2(entries) {
return object(entries);
}
}
}
class Task extends CustomType {
- constructor(id, project_id, title2, description, status, assignee, assignees, subteams, due_date) {
+ constructor(id, project_id, title2, description, status, assignee, assignees, subteams, due_date, defcon) {
super();
this.id = id;
this.project_id = project_id;
this.assignees = assignees;
this.subteams = subteams;
this.due_date = due_date;
+ this.defcon = defcon;
}
}
class Dashboard extends CustomType {
}
}
class NewTask extends CustomType {
- constructor(title2, description, assignee, assignees, subteams, due_date) {
+ constructor(title2, description, assignee, assignees, subteams, due_date, defcon) {
super();
this.title = title2;
this.description = description;
this.assignees = assignees;
this.subteams = subteams;
this.due_date = due_date;
+ this.defcon = defcon;
}
}
class StatusChange extends CustomType {
return field("assignees", string3, (assignees) => {
return field("subteams", list2(string3), (subteams) => {
return field("due_date", string3, (due_date) => {
- return success(new Task(id, project_id, title2, description, status, assignee, assignees, subteams, due_date));
+ return field("defcon", int2, (defcon) => {
+ return success(new Task(id, project_id, title2, description, status, assignee, assignees, subteams, due_date, defcon));
+ });
});
});
});
["assignee", string4(value3.assignee)],
["assignees", string4(value3.assignees)],
["subteams", array2(value3.subteams, string4)],
- ["due_date", string4(value3.due_date)]
+ ["due_date", string4(value3.due_date)],
+ ["defcon", int3(value3.defcon)]
]));
}
function status_change_json(value3) {
return none2();
}
}
-function join_subteams(subteams) {
- return join(subteams, ", ");
-}
function if_blank(value3, fallback) {
let $ = value3 === "";
if ($) {
return value3;
}
}
+function join_subteams(subteams) {
+ return join(subteams, ", ");
+}
function task_view(task) {
return div(toList([class$("task")]), toList([
div(toList([class$("task-header")]), toList([
small(List$Empty$const, toList([text3("Subteams")])),
text3(if_blank(join_subteams(task.subteams), "No subteam"))
])),
+ div(toList([class$("task-person")]), toList([
+ small(List$Empty$const, toList([text3("DEFCON")])),
+ text3(if_blank(to_string(task.defcon), "0"))
+ ])),
div(toList([class$("task-due")]), toList([
small(List$Empty$const, toList([text3("Due")])),
text3((() => {
text_input("assignee", "Owner"),
text_input("assignees", "Assignees"),
text_input("due_date", "Due (MM/DD/YY)"),
+ text_input("defcon", "DEFCON"),
subteam_checkboxes(model.task_subteams),
textarea(toList([
class$("task-description-input"),
let tasks = map2(project.tasks, (task) => {
let $1 = task.id === task_id;
if ($1) {
- return new Task(task.id, task.project_id, task.title, task.description, status, task.assignee, task.assignees, task.subteams, task.due_date);
+ return new Task(task.id, task.project_id, task.title, task.description, status, task.assignee, task.assignees, task.subteams, task.due_date, task.defcon);
} else {
return task;
}
let project_id = message2[0];
let fields = message2[1];
let _block;
- let _pipe = new NewTask(field2(fields, "title"), field2(fields, "description"), field2(fields, "assignee"), field2(fields, "assignees"), model.task_subteams, field2(fields, "due_date"));
+ let _pipe = new NewTask(field2(fields, "title"), field2(fields, "description"), field2(fields, "assignee"), field2(fields, "assignees"), model.task_subteams, field2(fields, "due_date"), (() => {
+ let _pipe2 = key_find(fields, "defcon");
+ let _pipe$1 = unwrap2(_pipe2, "");
+ let _pipe$2 = identity(_pipe$1);
+ let _pipe$3 = run(_pipe$2, int2);
+ return unwrap2(_pipe$3, 0);
+ })());
_block = new_task_json(_pipe);
let body2 = _block;
return [
let app = application(init, update2, view);
let $ = start4(app, "#app", Option$None$const);
if (!($ instanceof Ok)) {
- throw makeError("let_assert", FILEPATH, "client", 20, "main", "Pattern match failed, no pattern matched the value.", { value: $, start: 459, end: 509, pattern_start: 470, pattern_end: 475 });
+ throw makeError("let_assert", FILEPATH, "client", 22, "main", "Pattern match failed, no pattern matched the value.", { value: $, start: 508, end: 558, pattern_start: 519, pattern_end: 524 });
}
return;
}
assignees: String,
subteams: List(String),
due_date: String,
+ defcon: Int,
)
}
assignees: String,
subteams: List(String),
due_date: String,
+ defcon: Int,
)
}
use assignees <- decode.field("assignees", decode.string)
use subteams <- decode.field("subteams", decode.list(decode.string))
use due_date <- decode.field("due_date", decode.string)
- decode.success(Task(id:, project_id:, title:, description:, status:, assignee:, assignees:, subteams:, due_date:))
+ use defcon <- decode.field("defcon", decode.int)
+ decode.success(Task(
+ id:,
+ project_id:,
+ title:,
+ description:,
+ status:,
+ assignee:,
+ assignees:,
+ subteams:,
+ due_date:,
+ defcon:,
+ ))
}
pub fn credentials_decoder() -> decode.Decoder(Credentials) {
use assignees <- decode.field("assignees", decode.string)
use subteams <- decode.field("subteams", decode.list(decode.string))
use due_date <- decode.field("due_date", decode.string)
- decode.success(NewTask(title:, description:, assignee:, assignees:, subteams:, due_date:))
+ use defcon <- decode.field("defcon", decode.int)
+ decode.success(NewTask(
+ title:,
+ description:,
+ assignee:,
+ assignees:,
+ subteams:,
+ due_date:,
+ defcon:,
+ ))
}
pub fn status_change_decoder() -> decode.Decoder(StatusChange) {
#("assignees", json.string(value.assignees)),
#("subteams", json.array(value.subteams, json.string)),
#("due_date", json.string(value.due_date)),
+ #("defcon", json.int(value.defcon)),
])
}
#("assignees", json.string(value.assignees)),
#("subteams", json.array(value.subteams, json.string)),
#("due_date", json.string(value.due_date)),
+ #("defcon", json.int(value.defcon)),
])
}