-
-
Save kellnerd/62a651295367645fa68955c57a6459eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function addVocalAttribute(id, creditedAs) { | |
MB.relationshipEditor.relationshipDialogDispatch({ | |
type: 'update-attribute', | |
action: { | |
type: 'update-multiselect-attribute', | |
// rootKey, | |
action: { | |
type: 'update-value-autocomplete', | |
// valueKey, | |
action: { | |
type: 'select-item', | |
item: { | |
id, | |
// ... | |
}, | |
}, | |
}, | |
}, | |
}); | |
if (creditedAs) { | |
MB.relationshipEditor.relationshipDialogDispatch({ | |
type: 'update-attribute', | |
action: { | |
type: 'update-multiselect-attribute', | |
// rootKey, | |
action: { | |
type: 'set-value-credit', | |
// valueKey, | |
creditedAs, | |
}, | |
}, | |
}); | |
} | |
} | |
/******************************************************************************************************************** | |
* Equivalent code to add the rel without opening a dialog. Currently causes a sentry error... * | |
* Based on https://github.com/kellnerd/musicbrainz-scripts/blob/beta/src/relationship-editor/createRelationship.js * | |
********************************************************************************************************************/ | |
/** | |
* @param {Object} [options] | |
* @param {ArtistT} options.artist The performing artist. | |
* @param {string} [options.roleName] Credited name of the voice actor's role (optional). | |
* @param {string} [options.artistCredit] Credited name of the performing artist (optional). | |
*/ | |
function createVoiceActorRelationship({ artist, roleName, artistCredit }) { | |
createRelationship({ | |
target: artist, | |
linkTypeID: 60, // performance -> performer -> vocals | |
entity0_credit: artistCredit, | |
attributes: [{ | |
type: { gid: 'd3a36e62-a7c4-4eb9-839f-adfebe87ac12' }, | |
typeID: 561, | |
typeName: 'spoken vocals', | |
credited_as: roleName, | |
}], | |
}); | |
} |
I have created a separate gist with a complete code sample for the second issue:
https://gist.github.com/kellnerd/dc39236e58d5fb39b41a53a883eacb09
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setting attributes in a relationship dialog will be simplified by metabrainz/musicbrainz-server#2733.
Now I only have to figure out why
createVoiceActorRelationship
does not work as expected....