danielo515 / obsidian-modal-form

Define forms for filling data that you will be able to open from anywhere you can run JS
https://danielorodriguez.com/obsidian-modal-form/
MIT License
175 stars 13 forks source link

[Feature request] quickadd use condition before renderin the strig #287

Open louwelyn-jeremy opened 2 weeks ago

louwelyn-jeremy commented 2 weeks ago

i want to use modal form to add task on a specific file for that i use:

in modal form

{ "title": "actions_tous", "name": "TODO_global", "fields": [ { "name": "todo_type", "label": "type d'action", "description": "", "isRequired": false, "input": { "type": "select", "source": "fixed", "options": [ { "value": "- [ ]", "label": "normal" } ] } }, { "name": "action", "label": "action", "description": "", "isRequired": false, "input": { "type": "text" } }, { "name": "choix_prio", "label": "priorisation", "description": "cocher pour ajouter une priorisation", "isRequired": false, "input": { "type": "toggle" } }, { "name": "prio", "label": "type de priorisation", "description": "", "isRequired": false, "input": { "type": "select", "source": "fixed", "options": [ { "value": "", "label": "normal" }, { "value": "🔺", "label": "très haute" } ] } }, { "name": "choix_echeance", "label": "ajouter une echéance ?", "description": "", "isRequired": false, "input": { "type": "toggle" } }, { "name": "type_echeance", "label": "type d'échéance", "description": "", "isRequired": false, "input": { "type": "select", "source": "fixed", "options": [ { "value": "📅", "label": "echéance" }, { "value": "⏳", "label": "planification" } ] } }, { "name": "date_echeance", "label": "date de l'échéance", "description": "", "isRequired": false, "input": { "type": "date" } } ], "version": "1" }

in quickadd

    const modalForm = app.plugins.plugins.modalforms.api;
    const date_creation= "➕ " + window.moment().format("YYYY-MM-DD")
    const txt_prio = ""
    const txt_echeance = ""
    const result = await modalForm.openForm('TODO_global');
    if (result.get("choix_prio") == "true") {
        txt_prio = result.get("prio");
        txt_prio = "faux au choix prio";
      }                           
    if (result.get("choix_echeance") == "true") {
        txt_echeance = result.get("type_echeance") + result.get("date_echeance");
        txt_echeance="faux au chois echéance";
      } 
    return result.asString('{{todo_type}} TODO {{action}}')+ "|" + txt_prio + "|" + date_creation + "|" + txt_echeance + "|"

my problem is on the if statement ... quicka dd don't see them ! foe eremple, this is the result:

i don't have the value if true or value if false ....