From 0edde9191f5116edaf04507d571d561c1169dec2 Mon Sep 17 00:00:00 2001 From: Sami Walbury Date: Wed, 31 May 2023 17:08:50 +0100 Subject: [PATCH] Allow for template string {{prompt}} in the entry name --- README.md | 6 ++++++ plugin/main.js | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/README.md b/README.md index e288d81..201e8ad 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,12 @@ Just search for the Action "Toggl" within the Stream Deck app and install it. Th Just press any Toggl Button to start tracking time. The button should indicate tracking by turning red and showing the current tracking time (if no *Title* is set). The status of the button is defined by workspace, project and entry name. If you setup two identical buttons (even on different Stream Deck profiles), both button indicate the same. If you start or stop your timer using the Toggl app (web, desktop, mobile) Toggl for Stream Deck will follow by changing the status. +## Variable Entry Names + +You can have dynamic bits of yoru Entry Name by using the template `{{prompt}}` (no spaces). + +A prompt will appear to ask what it should be replaced with. Due to a limitation of the Stream Deck, the prompt may appear behind other apps. + ## 📞 Help Feel free to ask your questions on [my Discord Server](https://discord.gg/YWy3UAy). Please use GitHub Issues for reporting bugs and requesting new features. diff --git a/plugin/main.js b/plugin/main.js index 69a0133..84e09a1 100755 --- a/plugin/main.js +++ b/plugin/main.js @@ -140,6 +140,10 @@ async function toggle(context, settings) { // Toggl API Helpers function startEntry(apiToken = isRequired(), activity = 'Time Entry created by Toggl for Stream Deck', workspaceId = 0, projectId = 0, billableToggle = false) { + if (activity.includes('{{prompt}}')) { + let promptVal = prompt('What entry name would you like?'); + activity = activity.replace('{{prompt}}', promptVal); + } return fetch( `${togglBaseUrl}/time_entries/start`, { method: 'POST',