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

List fields also for all other item types #68

Merged
merged 3 commits into from
Feb 26, 2018

Conversation

zuphilip
Copy link
Collaborator

@zuphilip zuphilip commented Feb 2, 2018

No description provided.

@dstillman
Copy link
Member

This should really be generated programatically in the window init function. Something like this (not checked for correctness):

var types = Zotero.ItemTypes.getAll();
var morePopup = document.getElementById('mb-help-fields-more-popup');
var primaryTypes = ['book', ];
for (let type of types) {
    if (!primaryTypes.includes(type)) continue;
    var menuitem = document.createElement('menuitem');
    menuitem.label = field.name; // or setAttribute if this doesn't work
    menuitem.oncommand = (elem) => { Scaffold.addTemplate('templateNewItem', elem.getAttribute('label')) };
    morePopup.appendChild(menuitem);
}

@zuphilip
Copy link
Collaborator Author

zuphilip commented Feb 3, 2018

I totally agree. With the code snippet you provided, I was able to implement this. Thank you! Please have a look at the new version.

@zuphilip
Copy link
Collaborator Author

zuphilip commented Feb 8, 2018

@dstillman Any more comments? This would be ready to merge from my side.

@dstillman
Copy link
Member

Did menuitem.oncommand = (elem) => { Scaffold.addTemplate('templateNewItem', elem.getAttribute('label')) }; not work? Better to avoid building up code with strings if possible.

@zuphilip
Copy link
Collaborator Author

That didn't work. But I changed now to addEventListener instead of the string concatenation. Please have a look at the new version.

@zuphilip
Copy link
Collaborator Author

@dstillman Can we merge this now? I would like to create afterwards a new release (with the help of #72), which I would like to use during a workshop about coding Zotero Translators in March. ⏳

@dstillman dstillman merged commit a46e0d7 into zotero:master Feb 26, 2018
@zuphilip zuphilip deleted the all-itemtypes branch February 26, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants