Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Template New Note Buttons, allow manual naming of the new note in a pop-up window, which will allow Templater tp.file.title functions to run. #69

Open
DryIce1 opened this issue Aug 25, 2021 · 3 comments

Comments

@DryIce1
Copy link

@DryIce1 DryIce1 commented Aug 25, 2021

Problem

  • pre-defining a note name is problematic in some cases. most times when clicking a New Note Button, you would want to be able to type an original note name.
  • Specifically in some of my templates, I want Templater to use the tp.file.title function each time I make a new note. However, if the note name is predefined, this is not possible.

Expected solution

  • When creating a new template button, instead of selecting Note Name (What should the new note be named?), there should be a checkbox to select for something like "Name new note in pop-up window".
  • After clicking the button, a pop-up window to name the new note is presented. such as:
    image
  • Naming the note would then allow Templater to run and completes the tp.file.title field.

for example, my current use case, where I would want to manually rename New Note:

  • my current button
name New Task
type note(New Note) template
action New Task
templater true
color blue

image

  • my template
# <% tp.file.title %>
---
#tasks #inbox
Completed:: 
Project:: [[<%tp.file.cursor(1)%>]]
Status:: #active
Priority:: 
Date Created:: <% tp.date.now("YYYY-MM-DD") %>
Due Date::
Defer Date::
Recur Length::

image


I hope this makes sense and is useful for others.

@DryIce1
Copy link
Author

@DryIce1 DryIce1 commented Aug 25, 2021

Perhaps I explained this problem more simply over here

@MartynKeigher
Copy link

@MartynKeigher MartynKeigher commented Oct 8, 2021

You can do that already @DryIce1. Create a template based on the following code block and then tie the inserting of the template to a button! :)

<%*
const prompt = await tp.system.prompt("Title:")
const title = await prompt
await tp.file.rename(title)
tR += "# " + title
%>

---
#tasks #inbox
Completed:: 
Project:: [[<%tp.file.cursor(1)%>]]
Status:: #active
Priority:: 
Date Created:: <% tp.file.creation_date("dddd,  MMMM D, YYYY @ HH:MM") %>
Due Date::
Defer Date::
Recur Length::

@DryIce1
Copy link
Author

@DryIce1 DryIce1 commented Oct 28, 2021

Hi @MartynKeigher, thanks for the snippet - it does what it is supposed to do perfectly! And I have added the tp.file.include function so that my Action Items Template can remain unaltered.

For any non-tech people who want to do something similar, here is my current set up.

  • Button creates new file from Rename File Title Template, which has two functions
    1. prompt user to rename the file
    2. Include the Action Items template

Button

button
name New Action Item
type note(Title, split) template
action Templater - rename file title and include Action Item Template
templater true
color blue

Template 1 - rename file title and include Action Item Template

<%*const prompt = await tp.system.prompt("Title:")
const title = await prompt
await tp.file.rename(title)%>
<%-tp.file.include("[[Action Items Template]]")%>

Template 2 - tp.file.include - Action Items Template

#inbox

---
- *Back Matter*
	- **Date Added**:: 2021-10-28 15:20
	- **Do Date**:: 
	- **Due Date**:: 
	- **Done**:: 
	- **Recur Length**:: 
	- **Priority**:: #✅/P
	- **Status**:: #✅/S/1_Active
	- **Date Added**:: <%-tp.file.include("[[Timestamp]]")%>
	- **Person**:: 
	- **URL**:: 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants