Closed louwelyn-jeremy closed 2 weeks ago
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?
no problem
{
"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": []
}
}
const modalForm = app.plugins.plugins.modalforms.api;
const result = await modalForm.openForm('LOG');
return result.asString('{{type}} {{log}} [[{{lien}}]]');
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)
{ "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": [] } }
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]]
That is is correct code. When I get back to home later I will provide you a simpler version if you like it
El vie, 28 jun 2024, 13:26, louwelyn-jeremy @.***> escribió:
I found something from #269 https://github.com/danielo515/obsidian-modal-form/issues/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]]
— Reply to this email directly, view it on GitHub https://github.com/danielo515/obsidian-modal-form/issues/286#issuecomment-2196682034, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARKJWP2KRRHBIKFT6OBR43ZJVB5HAVCNFSM6AAAAABJ3VEAOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJWGY4DEMBTGQ . You are receiving this because you were assigned.Message ID: @.***>
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?
You can close the issue, thank you. Sorry, I'm a newbie in javascript
No worries, we've all been there
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 ?