gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchk40-lists9af8e780|||PR Use keyed list mutations for live ticket updatesmrek40-lists/components/inbox.hl

3.4 KB

  1. // components/inbox.hl — `/inbox` (ticket #20): the tickets ASSIGNED TO YOU, in two lists: pending and
  2. // review, across all projects. Personal: needs a login. Live: a ticket assigned to you, or moving into
  3. // or out of those states, appears / disappears without a reload.
  4. parent './main.hl'
  5. import { inboxRows } from '../lib/tickets.hl'
  6. import { siteName } from '../project.hl'
  7. import { userOfSession } from '../lib/users.hl'
  8. import { hintLook, subjectLook, ticketsLook } from '../lib/looks.hl'
  9. session = null
  10. myId = userOfSession(session) != null ? userOfSession(session).id : ''
  11. loggedIn = myId != ''
  12. loggedOut = myId == ''
  13. box = inboxRows(userOfSession(session))
  14. pending = box.pending
  15. review = box.review
  16. noPending = pending.length == 0
  17. noReview = review.length == 0
  18. __title = siteName + ' | inbox'
  19. Style {
  20. '#loginhint' = hintLook + { }
  21. olTickets = ticketsLook + {
  22. @media {
  23. minWidth = '60rem'
  24. li {
  25. gridTemplateColumns = '8.5rem minmax(0, 1fr) auto'
  26. alignItems = 'center'
  27. gap = '1rem'
  28. }
  29. }
  30. }
  31. aSubject = subjectLook + { }
  32. '#reviewbox' {
  33. display = 'grid'
  34. gap = '.5rem'
  35. h2 {
  36. margin = '0'
  37. fontSize = '1.1rem'
  38. }
  39. }
  40. '#pendingbox' {
  41. display = 'grid'
  42. gap = '.5rem'
  43. h2 {
  44. margin = '0'
  45. fontSize = '1.1rem'
  46. }
  47. }
  48. }
  49. View {
  50. ticketBoard {
  51. h1 { id = "heading" "Inbox" }
  52. if (loggedOut) { p { id = "loginhint" "Log in with ident (top right) to see the tickets assigned to you." } }
  53. if (loggedIn) {
  54. section { id = "reviewbox"
  55. h2 { "Review" }
  56. if (noReview) { p { id = "reviewempty" class = "empty" "Nothing is waiting for your review." } }
  57. ol { id = "review" Style.olTickets
  58. for (row of review) {
  59. li {
  60. ticketState { class = row.stateSlug row.state }
  61. a { Style.aSubject href = row.href ticketRef { row.ref } row.subject }
  62. ticketMeta {
  63. a { href = row.projectHref row.projectTitle }
  64. time { row.updated }
  65. }
  66. }
  67. }
  68. }
  69. }
  70. section { id = "pendingbox"
  71. h2 { "Pending" }
  72. if (noPending) { p { id = "pendingempty" class = "empty" "Nothing is pending for you." } }
  73. ol { id = "pending" Style.olTickets
  74. for (row of pending) {
  75. li {
  76. ticketState { class = row.stateSlug row.state }
  77. a { Style.aSubject href = row.href ticketRef { row.ref } row.subject }
  78. ticketMeta {
  79. a { href = row.projectHref row.projectTitle }
  80. time { row.updated }
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. }
  88. }
  89. // a row goes to the top of its list if it is assigned to me and in that state, and out of both otherwise
  90. place = (Hybrid row) => {
  91. p = pending
  92. r = review
  93. p.remove(id = row.id)
  94. r.remove(id = row.id)
  95. pending = row.assigneeId == myId && row.state == 'pending' ? [row].concat(p) : p
  96. review = row.assigneeId == myId && row.state == 'review' ? [row].concat(r) : r
  97. noPending = pending.length == 0
  98. noReview = review.length == 0
  99. }
  100. on client ticketCreated(row) { place(row) }
  101. on client ticketEvent(ticketId, ev, row) { place(row) }
  102. on client signedIn(tag, info) {
  103. b = emit server myInbox()
  104. if (b != null && b.pending != null) {
  105. pending = b.pending
  106. review = b.review
  107. noPending = b.pending.length == 0
  108. noReview = b.review.length == 0
  109. myId = b.me
  110. loggedIn = true
  111. loggedOut = false
  112. }
  113. }
  114. on client signedOut(tag) {
  115. myId = ''
  116. loggedIn = false
  117. loggedOut = true
  118. }
  119. on server myInbox(session) {
  120. u = userOfSession(session)
  121. if (u == null) { return { error = 'log in first' } }
  122. b = inboxRows(u)
  123. return { pending = b.pending review = b.review me = u.id }
  124. }

Branches

Latest commits

  • 9af8e780|||PR Use keyed list mutations for live ticket updatesmre
  • 610d8e8aMerge branch 'records-t39' into mainTickets
  • 32bcdf24|||PR records: GO P39 K40mre
  • 4123c6d1Merge branch 'records-t38' into mainTickets
  • cd3641a1|||PR records: day72 deploy live, tickets closedmre
  • 7d44d852Merge branch 'records-t37' into mainTickets
  • 926f7061|||PR records: merges, D36 deploymre
  • bf58534eMerge branch 'l33-final' into mainTickets
  • 759a9ac3|||PR thin login (tickets#46, #45): merge main, route entry cleanupmre
  • 239436d8Merge remote-tracking branch 'origin/main' into l33-finalmre
  • 5822cb3aMerge branch 'o34-clean' into mainTickets
  • 0870653c|||PR offline note from __hlOnline, no polling (tickets#41)mre
  • 14cf96b4Merge branch 'records-t36' into mainTickets
  • 07749fa1|||PR records: day72 + #40 mergedmre
  • ecd7e226|||PR Consolidate login and move handler logic into topic libraries (partial)mre
  • 6dea1c60Merge branch 'r35-day72' into mainTickets
  • 7bcfdc22|||PR drop worker edits to conductor recordsmre
  • 2617b6ee|||PR dialogs: host flag cleared on close, dialog gate (tickets#40)mre
  • 6e701371|||PR record partial day72 dialog validationmre
  • b9fb9a91|||PR bind ticket dialog visibility to member flagsmre