Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

add time_card undo to delete the last entry created by that person #5

Open
indirect opened this issue Jun 6, 2017 · 2 comments
Open

Comments

@indirect
Copy link
Member

indirect commented Jun 6, 2017

No description provided.

@Aliciawyse
Copy link

Hey @indirect, Are you saying that you want a method like

def undo_time_card
    # delete last entry
 end

in the Report class in app.rb? Or should there be another delete operation like the one created here https://github.com/rubytogether/time-card/pull/4/files?

@indirect
Copy link
Member Author

@Aliciawyse Another delete operation like that one. Maybe something like:

delete '/entries/last' do
  Entry.last.delete
end

After that gets added, I was hoping to add a command to the Slack bot, as well, over here: https://github.com/rubytogether/rubytogether-lita/blob/main/lib/lita/handlers/time_card.rb. Something like:

      route %r{^time_card undo},
        :undo_entry,
        command: true,
        help: { "time_card undo" => "Remove your last timecard entry." }

      def undo_entry(response)
        log.debug "[time_card] undo entry"
        r = authenticated_connection.delete("/entries/last")
        return if failed_request?(r, lita_response: response)
        response.reply("[time_card] last entry removed")
      end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants