mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
100 lines
3.6 KiB
JavaScript
100 lines
3.6 KiB
JavaScript
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 `
|
|
<div class="input-field">
|
|
<i class="material-icons prefix">search</i>
|
|
<input id="${id}-search" class="search" type="search"></input>
|
|
<label for="${id}-search">Search SpaCy NLP Pipeline Model</label>
|
|
</div>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th>Description</th>
|
|
<th>Biblio</th>
|
|
<th></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="list"></tbody>
|
|
</table>
|
|
<ul class="pagination"></ul>
|
|
`.trim();
|
|
},
|
|
item: `
|
|
<tr class="clickable hoverable">
|
|
<td><span class="title"></span></td>
|
|
<td><span class="description"></span></td>
|
|
<td><a class="publisher-url"><span class="publisher"></span></a> (<span class="publishing-year"></span>), <span class="title-2"></span> <span class="version"></span>, <a class="publishing-url"><span class="publishing-url-2"></span></a></td>
|
|
<td class="right-align">
|
|
<a class="action-button btn-floating red waves-effect waves-light" data-action="delete-request"><i class="material-icons">delete</i></a>
|
|
<a class="action-button btn-floating service-color darken waves-effect waves-light service-2" data-action="view"><i class="material-icons">send</i></a>
|
|
</td>
|
|
</tr>
|
|
`.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
|
|
};
|
|
},
|
|
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'
|
|
]
|
|
};
|
|
|
|
constructor(listElement, options = {}) {
|
|
super(listElement, {...SpaCyNLPPipelineModelList.options, ...options});
|
|
}
|
|
|
|
init (user) {
|
|
this._init(user.spacy_nlp_pipeline_models);
|
|
}
|
|
|
|
onClick(event) {
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
}
|