zotero / scaffold

Zotero translator creation IDE
http://www.zotero.org/support/dev/scaffold
38 stars 9 forks source link

List fields also for all other item types #68

Closed zuphilip closed 6 years ago

dstillman commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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

dstillman commented 6 years ago

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

zuphilip commented 6 years ago

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

zuphilip commented 6 years ago

@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. :hourglass_flowing_sand: