49 lines
1.4 KiB
R
49 lines
1.4 KiB
R
db_checklists_list <- function(db, scope = NULL) {
|
|
api_get(db, "/v1/checklists")
|
|
}
|
|
|
|
db_checklists_get <- function(db, id) {
|
|
api_get_one(db, paste0("/v1/checklists/", id))
|
|
}
|
|
|
|
db_checklists_insert <- function(db, name, scope = "colony") {
|
|
result <- api_post(db, "/v1/checklists", list(name = name, scope = scope))
|
|
result$id
|
|
}
|
|
|
|
db_checklists_delete <- function(db, id) {
|
|
api_delete(db, paste0("/v1/checklists/", id))
|
|
}
|
|
|
|
db_checklist_items_list <- function(db, checklist_id) {
|
|
api_get(db, paste0("/v1/checklists/", checklist_id, "/items"))
|
|
}
|
|
|
|
db_checklist_items_insert <- function(db, checklist_id, text, position = 0L) {
|
|
result <- api_post(db, paste0("/v1/checklists/", checklist_id, "/items"), list(
|
|
text = text,
|
|
position = as.integer(position)
|
|
))
|
|
result$id
|
|
}
|
|
|
|
db_checklist_items_delete <- function(db, id) {
|
|
api_delete(db, paste0("/v1/checklists/items/", id))
|
|
}
|
|
|
|
db_checklist_completions_list <- function(db, checklist_id, scope_id, date = NULL) {
|
|
api_get(db, paste0("/v1/checklists/", checklist_id, "/completions"),
|
|
list(scope_id = scope_id))
|
|
}
|
|
|
|
db_checklist_completions_toggle <- function(db, checklist_id, item_id,
|
|
scope_id, date, completed_by = NA) {
|
|
result <- api_post(db, paste0("/v1/checklists/", checklist_id, "/completions/toggle"), list(
|
|
item_id = item_id,
|
|
scope_id = scope_id,
|
|
date = as.character(date),
|
|
completed_by = completed_by
|
|
))
|
|
isTRUE(result$toggled)
|
|
}
|