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

Artciles with a related timeline can't be imported #27

Open
cswendrowski opened this issue Mar 14, 2021 · 0 comments
Open

Artciles with a related timeline can't be imported #27

cswendrowski opened this issue Mar 14, 2021 · 0 comments
Labels
bug Functionality which is not working as intended

Comments

@cswendrowski
Copy link

In GitLab by @adrien.schiehle on Mar 14, 2021, 11:50

Hi, I'm new here, so first :

Thank you for this integration module !

It will allow me to create my article in advance and share what I want directly inside fvtt.

When I tried it, some of my articles couldn't be imported. Here was the stack :

framework.js:71 Uncaught (in promise) TypeError: Cannot read property 'id' of undefined
    at framework.js:71
    at Array.map (<anonymous>)
    at _getArticleContent (framework.js:71)
    at importArticle (framework.js:12)
    at async WorldAnvilBrowser._onClickControlButton (journal.js:146)

If I understand correctly, timeline relations inside an article are not correctly interpreted. section.items is undefined.

  // Article relations
  if ( article.relations ) {
    for ( let [id, section] of Object.entries(article.relations) ) {
      const title = section.title || id.titleCase();
      const items = section.items instanceof Array ? section.items: [section.items];  // Items can be one or many
      const relations = items.map(i => `<span data-article-id="${i.id}" data-template="${i.type}">${i.title}</span>`);
      aside += `<dt>${title}:</dt><dd>${relations.join(", ")}</dd>`
    }
  }

Something like this could do the job. What do you think ?

      let items = section.items;
      if( ! items ) {
         items = []; // There can be no items in an article relation. (Ex: timeline)
      } else if (! items instanceof Array ) {
         items = [section.items];  // Items can be one or many
      } 
@aaclayton aaclayton added the bug Functionality which is not working as intended label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants