2023-08-06 11:51:24 (UTC-03:00)
Marcel Rodrigues <marcelgmr@gmail.com>
implement ticket shifting
diff --git a/skopos.lua b/skopos.lua index e51e8f7..e3ecbd5 100644 --- a/skopos.lua +++ b/skopos.lua @@ -273,6 +273,24 @@ function App:routes() self:log(LOG_INFO, "user "..user.nick.." edited ticket "..name.."#"..code) return "/p/"..name.."/t/"..code, 303 end}, + {"POST", "/p/([-_%w]+)/t/(%d+)/shift/(%d+)", + function (req, name, code, state_id) + local user = self:get_user(req) + if user == nil then return "/login", 303 end + local proj = self.model:get_user_project(user.id, name) + if proj == nil then return "not found", 404 end + local tick = self.model:get_ticket(proj.id, code) + if tick == nil then return "not found", 404 end + self.model:shift_ticket(user.id, tick, state_id) + self:log(LOG_INFO, "user "..user.nick.." shifted ticket "..name.."#"..code) + local path + if req.query.from == "proj" then + path = "/p/"..name + else + path = "/" + end + return path, 303 + end}, {"POST", "/p/([-_%w]+)/t/(%d+)/del", function (req, name, code) local user = self:get_user(req) diff --git a/view/board.html b/view/board.html index 259d572..25cd1aa 100644 --- a/view/board.html +++ b/view/board.html @@ -13,10 +13,12 @@ <div class="centered menu"> % if $proj == nil then % set proj_name = "global" + % set from = "home" <a href="/p">projects</a> <a href="/i">invites</a> % else % set proj_name = $proj.name + % set from = "proj" <a href="/p/{{$proj.name}}/t/new">new ticket</a> % end </div> @@ -41,16 +43,21 @@ ({{$card.priority}}) </div> <div class="buttons"> + % set shift_path = "/p/"..$card.proj_name.."/t/"..$card.code.."/shift/" % set left_disabled = "" % if $state_id == 1 then % set left_disabled = " disabled" % end - <button{{$left_disabled}}>←</button> + <form action="{{$shift_path}}{{$state_id-1}}?from={{$from}}" method="post"> + <button type="submit"{{$left_disabled}}>←</button> + </form> % set right_disabled = "" % if $state_id == #$states then % set right_disabled = " disabled" % end - <button{{$right_disabled}}>→</button> + <form action="{{$shift_path}}{{$state_id+1}}?from={{$from}}" method="post"> + <button type="submit"{{$right_disabled}}>→</button> + </form> </div> </div> % end