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

[Feature request] add current date or time in result #286

Closed
louwelyn-jeremy opened this issue Jun 25, 2024 · 7 comments
Closed

[Feature request] add current date or time in result #286

louwelyn-jeremy opened this issue Jun 25, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@louwelyn-jeremy
Copy link

thank you for your work!
i have an issue with this plugin for make log to my journal.
i use Quick addand i can add log like this one:
log:: ☑📡 my text [[link to project]]
but i want to add the current time ... how can i do that ?

@louwelyn-jeremy louwelyn-jeremy added the enhancement New feature or request label Jun 25, 2024
@danielo515
Copy link
Owner

this is (if I understand it correctly) the same as #269, but a bit more specific to date.
May you share the template you are using?

@louwelyn-jeremy
Copy link
Author

louwelyn-jeremy commented Jun 27, 2024

no problem

from modal forms

{
  "title": "ajouter un log journalier",
  "name": "LOG",
  "fields": [
    {
      "name": "type",
      "label": "type de log",
      "description": "Séléctionner le type de log",
      "isRequired": true,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "log:: ☑💼",
            "label": "Projet"
          },
          {
            "value": "log:: ☑📡",
            "label": "Perimetre"
          }
        ]
      }
    },
    {
      "name": "log",
      "label": "info",
      "description": "indiquer ici l'information à noter",
      "isRequired": true,
      "input": {
        "type": "text"
      }
    },
    {
      "name": "lien",
      "label": "en rapport avec",
      "description": "choisir le projet, le périmètre",
      "isRequired": false,
      "input": {
        "type": "dataview",
        "query": "dv.pages('\"KMS_jeremy/GTD/GTD-Dom. resp\" or \"KMS_jeremy/GTD/GTD-objectifs\"or \"KMS_jeremy/GTD/GTD-projets\"').file.name"
      }
    }
  ],
  "version": "1",
  "template": {
    "createCommand": true,
    "parsedTemplate": []
  }
}

from quick add

	const modalForm = app.plugins.plugins.modalforms.api;
	const result = await modalForm.openForm('LOG');
	return result.asString('{{type}} {{log}} [[{{lien}}]]');

@louwelyn-jeremy
Copy link
Author

I found something from #269 and the quick add documentation:
in can use a function in quick add to find the actual hour with window.moment().format("HH:mm");
this my code now (i make some change)

from modal form

{
"title": "ajouter un log journalier",
"name": "LOG",
"fields": [
{
"name": "type",
"label": "type de log",
"description": "Séléctionner le type de log",
"isRequired": true,
"input": {
"type": "select",
"source": "fixed",
"options": [
{
"value": "log:: ☑💼",
"label": "Projet"
},
{
"value": "log:: ☑📡",
"label": "Perimetre"
}
]
}
},
{
"name": "log",
"label": "info",
"description": "indiquer ici l'information à noter",
"isRequired": true,
"input": {
"type": "text"
}
},
{
"name": "lien",
"label": "en rapport avec",
"description": "choisir le projet, le périmètre",
"isRequired": false,
"input": {
"type": "dataview",
"query": "dv.pages('"KMS_jeremy/GTD/GTD-Dom. resp" or "KMS_jeremy/GTD/GTD-objectifs"or "KMS_jeremy/GTD/GTD-projets"').file.link"
}
}
],
"version": "1",
"template": {
"createCommand": true,
"parsedTemplate": []
}
}

from quickadd

	const modalForm = app.plugins.plugins.modalforms.api;
	const result = await modalForm.openForm('LOG');
	const temps = window.moment().format("HH:mm");
	return result.asString('{{type}} ||')+ temps + result.asString('|| {{log}} {{lien}} \n');

the result:

log:: ☑📡 ||09:04|| my text [[path/to/my note.md|my note]]

@danielo515
Copy link
Owner

danielo515 commented Jun 28, 2024 via email

@danielo515
Copy link
Owner

So, you can write that code like this, using a single javascript template string

	const modalForm = app.plugins.plugins.modalforms.api;
	const result = await modalForm.openForm('LOG');
	const temps = window.moment().format("HH:mm");
	return result.asString(`{{type}} || ${temps} || {{log}} {{lien}} \n`);

I feel really tempted to document this under advanced usecases.
If you are happy with the outcome, can we close the issue?

@louwelyn-jeremy
Copy link
Author

You can close the issue, thank you.
Sorry, I'm a newbie in javascript

@danielo515
Copy link
Owner

No worries, we've all been there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants