ExportXMLWordPrintable

      In my "seed Concert event from an existing recording" userscript I use the capability to prefill fields in an Event creation page by using an URL like

      https://mb.o/event/create?edit-event.name=...
      &rels.0.target=...
      &rels.0.type=...
      &rels.1.target=...
      &rels.1.type=...

      This was working earlier this year, and I just checked on tag v-2020-08-24 it works as expected.

      It doesn't work on recent versions of MBS with a "Uncaught TypeError: i.attributes is undefined" in the javascript console of my browser.

       

      This capability was broken in MBS commit 1adc89f5c37 as far as I can tell, when lodash.transform(myArray, myFct...) was changed to myArray.reduce(myFct...). lodash.transform() accepted an 'undefined' myArray input (considered as equal to an empty array) and of course myArray.reduce() does not, which explains the error coming from root/static/scripts/relationship-editor/common/viewModel.js line~350 where rel.attributes is undefined:

       

      diff --git a/root/static/scripts/relationship-editor/common/viewModel.js b/root/static/scripts/relationship-editor/common/viewModel.js
      index 9a1ad9bd71..9247362813 100644
      --- a/root/static/scripts/relationship-editor/common/viewModel.js
      +++ b/root/static/scripts/relationship-editor/common/viewModel.js

      @@ -346,7 +347,8 @@ function addRelationshipsFromQueryString(source) {
      {{ };}}

      {{ if (linkType) {}}
      - data.attributes = rel.attributes.reduce(function (accum, attr) {
      + data.attributes = (rel.attributes ?? []).reduce(function (accum, attr) {
      {{ var attrInfo = linkedEntities.link_attribute_type[attr.type];}}

      {{ if (attrInfo && linkType.attributes[attrInfo.id]) {}}

       
      With the patch above my userscript restart working. There's still another bug left (when I have relations to different entity types, the wrong relation names are displayed) I want to take a look at, but I think at least this fix should be applied

            Assignee:
            Nicolás Tamargo
            Reporter:
            loujin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package
                2021-01-11