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
199 stars 17 forks source link

[FEATUREREQUEST] format notes as links #177

Open the1gofer opened 8 months ago

the1gofer commented 8 months ago

I'm not sure if this is the intended behavior or not, but it seems like a bug.

To Reproduce

{
  "title": "New Call",
  "name": "call",
  "customClassname": "call",
  "fields": [
    {
      "name": "case link",
      "label": "Case",
      "description": "",
      "isRequired": false,
      "input": {
        "type": "note",
        "folder": "TCPA/Cases"
      }
    },
    {
      "name": "date",
      "label": "Date",
      "description": "",
      "isRequired": false,
      "input": {
        "type": "date"
      }
    },
    {
      "name": "time",
      "label": "Time",
      "description": "",
      "isRequired": false,
      "input": {
        "type": "time"
      }
    },
    {
      "name": "direction",
      "label": "Direction",
      "description": "",
      "isRequired": false,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "Inbound",
            "label": "Inbound"
          },
          {
            "value": "Outbound",
            "label": "Outbound"
          }
        ]
      }
    },
    {
      "name": "line called",
      "label": "Line Called",
      "description": "",
      "isRequired": true,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "(602)295-1875",
            "label": "Main"
          },
          {
            "value": "(602)295-7930",
            "label": "Backup"
          },
          {
            "value": "(602)903-4748",
            "label": "Main GV"
          },
          {
            "value": "(480)788-8125",
            "label": "Backup GV"
          }
        ]
      }
    },
    {
      "name": "caller ID",
      "label": "Caller ID",
      "description": "Caller ID",
      "isRequired": true,
      "input": {
        "type": "tel"
      }
    },
    {
      "name": "ATDS",
      "label": "ATDS",
      "description": "",
      "isRequired": true,
      "input": {
        "type": "toggle"
      }
    },
    {
      "name": "pre-recorded",
      "label": "Pre-Recorded",
      "description": "",
      "isRequired": true,
      "input": {
        "type": "toggle"
      }
    },
    {
      "name": "campaign",
      "label": "Campaign",
      "description": "",
      "isRequired": true,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "Tax Settlement",
            "label": "Tax Settlement"
          },
          {
            "value": "Life Insurance",
            "label": "Life Insurance"
          },
          {
            "value": "Medicare",
            "label": "Medicare"
          },
          {
            "value": "Health Insurnace",
            "label": "Health Insurance"
          },
          {
            "value": "Solar",
            "label": "Solar"
          },
          {
            "value": "Legal-Auto",
            "label": "Legal-Auto"
          },
          {
            "value": "Legal-Camp Legune",
            "label": "Legal-Camp Legune"
          },
          {
            "value": "Legal-Roundup",
            "label": "Legal-Roundup"
          },
          {
            "value": "Vacation",
            "label": "Vacation"
          },
          {
            "value": "Other",
            "label": "Other"
          }
        ]
      }
    },
    {
      "name": "recorded on",
      "label": "Recording Location",
      "description": " ",
      "isRequired": true,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "Recorder",
            "label": "Recorder"
          },
          {
            "value": "Rev",
            "label": "Rev"
          },
          {
            "value": "Not Recorded",
            "label": "Not Recorded"
          },
          {
            "value": "Cube",
            "label": "Cube"
          }
        ]
      }
    },
    {
      "name": "dnc request",
      "label": "DNC Request",
      "description": "",
      "isRequired": false,
      "input": {
        "type": "select",
        "source": "fixed",
        "options": [
          {
            "value": "False",
            "label": "False"
          },
          {
            "value": "True",
            "label": "True"
          }
        ]
      }
    }
  ],
  "version": "1",
  "template": {
    "createCommand": true,
    "parsedTemplate": [
      {
        "_tag": "text",
        "value": "---\ncall-date: "
      },
      {
        "_tag": "variable",
        "value": "date"
      },
      {
        "_tag": "text",
        "value": "\ncall-time: "
      },
      {
        "_tag": "variable",
        "value": "time"
      },
      {
        "_tag": "text",
        "value": "\ncall-type: "
      },
      {
        "_tag": "variable",
        "value": "type"
      },
      {
        "_tag": "text",
        "value": "\ncall-direction: "
      },
      {
        "_tag": "variable",
        "value": "direction"
      },
      {
        "_tag": "text",
        "value": "\ncalled: "
      },
      {
        "_tag": "variable",
        "value": "called"
      },
      {
        "_tag": "text",
        "value": "\ncallerID: "
      },
      {
        "_tag": "variable",
        "value": "callerID"
      },
      {
        "_tag": "text",
        "value": "\nATDS: "
      },
      {
        "_tag": "variable",
        "value": "ATDS"
      },
      {
        "_tag": "text",
        "value": "\npre-recorded: "
      },
      {
        "_tag": "variable",
        "value": "prerecorded"
      },
      {
        "_tag": "text",
        "value": "\ncampaign: "
      },
      {
        "_tag": "variable",
        "value": "campaign"
      },
      {
        "_tag": "text",
        "value": "\nrecorded-on: "
      },
      {
        "_tag": "variable",
        "value": "recordingLoc"
      },
      {
        "_tag": "text",
        "value": "\nrecording file: \n---\n# Notes"
      }
    ]
  }
}

let frontmatter = result.asFrontmatterString('call'); and result.get('case-link', (p) => p) yields amongst other things:
case link: "Test Call"

I'm assuming it's becuase I am using a drop down, and it's not getting saved as a link, but I'm not sure.

danielo515 commented 8 months ago

If I understand correctly,because the input is of type note you expect the rendered output to be a link? Or you refer to something else. If that is the case, it is the expected behavior. Not saying it's the best, but I decided to not take too many decisions for the user, and I leave the conversion to the one using the values

the1gofer commented 8 months ago

Oh maybe that’s it I associated note with a link to the note.

Jason Crews

On Thu, Dec 28, 2023 at 1:32 PM Daniel Rodríguez Rivero < @.***> wrote:

If I understand correctly,because the input is of type note you expect the rendered output to be a link? Or you refer to something else. If that is the case, it is the expected behavior. Not saying it's the best, but I decided to not take too many decisions for the user, and I leave the conversion to the one using the values

— Reply to this email directly, view it on GitHub https://github.com/danielo515/obsidian-modal-form/issues/177#issuecomment-1871472377, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQKUNGDMVXOQZ7EQ7I6ZMLYLXJOFAVCNFSM6AAAAABBFARIAOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZRGQ3TEMZXG4 . You are receiving this because you authored the thread.Message ID: @.***>

the1gofer commented 8 months ago

Ok,

Maybe I'm odd, but if you you use multi select, and select a note, I would expect it to be a link to that page. I'm not sure how usefull just the name is, but maybe it's just me.

Jason Crews

On Thu, Dec 28, 2023 at 1:41 PM Jason Crews @.***> wrote:

Oh maybe that’s it I associated note with a link to the note.

Jason Crews

On Thu, Dec 28, 2023 at 1:32 PM Daniel Rodríguez Rivero < @.***> wrote:

If I understand correctly,because the input is of type note you expect the rendered output to be a link? Or you refer to something else. If that is the case, it is the expected behavior. Not saying it's the best, but I decided to not take too many decisions for the user, and I leave the conversion to the one using the values

— Reply to this email directly, view it on GitHub https://bitli.pro/22Qwm_07b90ad0, or unsubscribe https://bitli.pro/22Qwn_5a12806a. You are receiving this because you authored the thread.Message ID: @.***>

danielo515 commented 8 months ago

I am open to make easy to format values as links, but making it the default will be a breaking change, and from my perspective less flexible. With just the note name, you can do whatever you like. For example I use them as contacts in several fields where a link doesn't make sense

rchaklashiya commented 7 months ago

I also would find it useful to have the link format--honestly for my own usecase this is the only scenario where it is useful. Perhaps this could be done as a separate type? (i.e. instead of "note" it could be "link"?) Separately I tried to implement links using the dataview module of the modal forms plugin but nothing showed up in the eventual form as options even if they did in the preview, which I find strange. So currently I am unable to get links via the plugin, which is impeding my ability to implement it.

danielo515 commented 7 months ago

Properly rendering as links is a bit more tricky that it could initially look. First, we need the original file we want to link to, that is not a problem, I can either keep the file reference or get it when rendering as link. However, it is also needed the current note link, and that is something that my plugin doesn't know, it needs to be provided from templater template, so the API will look something like this:

result.notesField.asLinks(tp.config.target_file).bullets

Will that work for you?

the1gofer commented 7 months ago

Thanks. I haven't had a chance to try it, but it looks promising. Jason Crews

On Fri, Jan 19, 2024 at 12:05 PM Daniel Rodríguez Rivero < @.***> wrote:

Properly rendering as links is a bit more tricky that it could initially look. First, we need the original file we want to link to, that is not a problem, I can either keep the file reference or get it when rendering as link. However, it is also needed the current note link, and that is something that my plugin doesn't know, it needs to be provided from templater template, so the API will look something like this:

result.notesField.asLinks(tp.config.target_file).bullets

Will that work for you?

— Reply to this email directly, view it on GitHub https://bitli.pro/23SKg_64259acc, or unsubscribe https://bitli.pro/23SKh_1db65aeb. You are receiving this because you authored the thread.Message ID: @.***>

danielo515 commented 7 months ago

Thanks. I haven't had a chance to try it, but it looks promising. Jason Crews

That was just a proposition to see if the API makes sense to you, it is not yet a real thing. Just wanted to clarify

the1gofer commented 7 months ago

yes, seems reasonable.

Jason Crews

On Tue, Jan 23, 2024 at 2:40 AM Daniel Rodríguez Rivero < @.***> wrote:

Thanks. I haven't had a chance to try it, but it looks promising. Jason Crews

That was just a proposition to see if the API makes sense to you, it is not yet a real thing. Just wanted to clarify

— Reply to this email directly, view it on GitHub https://bitli.pro/24qra_e3bcee6b, or unsubscribe https://bitli.pro/24qrb_d9eb7007. You are receiving this because you authored the thread.Message ID: @.***>

ekbl1 commented 6 months ago

This isn't the ideal solution, but it does format notes as links, once the modal form is closed and you're back in your Note:

Make a multiselect field, with the following dataview query to populate it:

dv.pagePaths('"yourDirectoryHere"').map(path=>"[["+ path + "|" + dv.page(path).file.name + "]]")