class SpaCyNLPPipelineModelList extends RessourceList { static autoInit() { for (let spaCyNLPPipelineModelListElement of document.querySelectorAll('.spacy-nlp-pipeline-model-list:not(.no-autoinit)')) { new SpaCyNLPPipelineModelList(spaCyNLPPipelineModelListElement); } } static options = { initialHtmlGenerator: (id) => { return `
search
Title and Description Publisher
`.trim(); }, item: `
()
delete send `.trim(), ressourceMapper: (spaCyNLPPipelineModel) => { return { 'id': spaCyNLPPipelineModel.id, 'creation-date': spaCyNLPPipelineModel.creation_date, 'description': spaCyNLPPipelineModel.description, 'publisher': spaCyNLPPipelineModel.publisher, 'publisher-url': spaCyNLPPipelineModel.publisher_url, 'publishing-url': spaCyNLPPipelineModel.publishing_url, 'publishing-url-2': spaCyNLPPipelineModel.publishing_url, 'publishing-year': spaCyNLPPipelineModel.publishing_year, 'title': spaCyNLPPipelineModel.title, 'title-2': spaCyNLPPipelineModel.title, 'version': spaCyNLPPipelineModel.version, 'shared': spaCyNLPPipelineModel.shared ? 'True' : 'False' }; }, sortArgs: ['creation-date', {order: 'desc'}], valueNames: [ {data: ['id']}, {data: ['creation-date']}, {name: 'publisher-url', attr: 'href'}, {name: 'publishing-url', attr: 'href'}, 'description', 'publisher', 'publishing-url-2', 'publishing-year', 'title', 'title-2', 'version', {name: 'shared', attr: 'data-checked'} ] }; constructor(listElement, options = {}) { super(listElement, {...SpaCyNLPPipelineModelList.options, ...options}); this.listjs.list.addEventListener('change', (event) => {this.onChange(event)}); } init (user) { this._init(user.spacy_nlp_pipeline_models); } _init(ressources) { super._init(ressources); for (let uncheckedCheckbox of this.listjs.list.querySelectorAll('input[data-checked="True"]')) { uncheckedCheckbox.setAttribute('checked', ''); } } onClick(event) { if (event.target.closest('.action-switch')) { return; } let actionButtonElement = event.target.closest('.action-button'); let action = actionButtonElement === null ? 'view' : actionButtonElement.dataset.action; let spaCyNLPPipelineModelElement = event.target.closest('tr'); let spaCyNLPPipelineModelId = spaCyNLPPipelineModelElement.dataset.id; switch (action) { case 'delete-request': { Utils.deleteSpaCyNLPPipelineModelRequest(this.userId, spaCyNLPPipelineModelId); break; } case 'view': { window.location.href = `/contributions/spacy-nlp-pipeline-models/${spaCyNLPPipelineModelId}`; break; } default: { break; } } } onChange(event) { let actionSwitchElement = event.target.closest('.action-switch'); let action = actionSwitchElement.dataset.action; let spaCyNLPPipelineModelElement = event.target.closest('tr'); let spaCyNLPPipelineModelId = spaCyNLPPipelineModelElement.dataset.id; switch (action) { case 'share-request': { let shared; if (actionSwitchElement.querySelector('input').checked) { shared = true; } else { shared = false; } Utils.shareSpaCyNLPPipelineModelRequest(this.userId, spaCyNLPPipelineModelId, shared); break; } default: { break; } } } }