mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-12 09:00:40 +00:00
Change RessourceList
This commit is contained in:
@ -1,7 +1,13 @@
|
||||
class RessourceList extends List {
|
||||
constructor(idOrElement, subscriberList, dataMapper=null, options={}) {
|
||||
super(idOrElement, {...RessourceList.options, ...options});
|
||||
this.dataMapper = dataMapper;
|
||||
constructor(idOrElement, subscriberList, type, options={}) {
|
||||
if (!['corpus', 'job'].includes(type)) {
|
||||
console.error("Unknown Type!");
|
||||
return;
|
||||
}
|
||||
super(idOrElement, {...RessourceList.options['common'],
|
||||
...RessourceList.options[type],
|
||||
...options});
|
||||
this.type = type;
|
||||
subscriberList.push(this);
|
||||
}
|
||||
|
||||
@ -43,19 +49,15 @@ class RessourceList extends List {
|
||||
|
||||
|
||||
addRessources(ressources) {
|
||||
if (this.dataMapper) {
|
||||
this.add(ressources.map(x => this.dataMapper(x)));
|
||||
} else {
|
||||
this.add(ressources);
|
||||
}
|
||||
this.add(ressources.map(x => RessourceList.dataMapper[this.type](x)));
|
||||
}
|
||||
}
|
||||
RessourceList.dataMapper = {
|
||||
corpus: corpus => ({creation_date: corpus.creation_date,
|
||||
description: corpus.description,
|
||||
id: corpus.id,
|
||||
link: `/corpora/${corpus.id}`,
|
||||
service: "corpus",
|
||||
"analyse-link": `/corpora/${corpus.id}/analyse`,
|
||||
"edit-link": `/corpora/${corpus.id}`,
|
||||
status: corpus.status,
|
||||
title: corpus.title}),
|
||||
job: job => ({creation_date: job.creation_date,
|
||||
@ -67,32 +69,53 @@ RessourceList.dataMapper = {
|
||||
title: job.title})
|
||||
};
|
||||
RessourceList.options = {
|
||||
item: `<tr>
|
||||
<td>
|
||||
<a class="btn-floating disabled">
|
||||
<i class="material-icons service"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<b class="title"></b><br>
|
||||
<i class="description"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge new status" data-badge-caption=""></span>
|
||||
</td>
|
||||
<td class="right-align">
|
||||
<a class="btn-small link waves-effect waves-light">View<i class="material-icons right">send</i>
|
||||
</td>
|
||||
</tr>`,
|
||||
page: 4,
|
||||
pagination: {innerWindow: 8, outerWindow: 1},
|
||||
valueNames: ["creation_date",
|
||||
"description",
|
||||
"title",
|
||||
{data: ["id"]},
|
||||
{name: "link", attr: "href"},
|
||||
{name: "service", attr: "data-service"},
|
||||
{name: "status", attr: "data-status"}]};
|
||||
common: {page: 4, pagination: {innerWindow: 8, outerWindow: 1}},
|
||||
corpus: {item: `<tr>
|
||||
<td>
|
||||
<a class="btn-floating disabled">
|
||||
<i class="material-icons service">book</i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<b class="title"></b><br>
|
||||
<i class="description"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge new status" data-badge-caption=""></span>
|
||||
</td>
|
||||
<td class="right-align">
|
||||
<a class="btn-small edit-link waves-effect waves-light"><i class="material-icons">edit</i></a>
|
||||
<a class="btn-small analyse-link waves-effect waves-light">Analyse<i class="material-icons right">search</i></a>
|
||||
</td>
|
||||
</tr>`,
|
||||
valueNames: ["creation_date", "description", "title",
|
||||
{data: ["id"]},
|
||||
{name: "analyse-link", attr: "href"},
|
||||
{name: "edit-link", attr: "href"},
|
||||
{name: "status", attr: "data-status"}]},
|
||||
job: {item: `<tr>
|
||||
<td>
|
||||
<a class="btn-floating disabled">
|
||||
<i class="material-icons service"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<b class="title"></b><br>
|
||||
<i class="description"></i>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge new status" data-badge-caption=""></span>
|
||||
</td>
|
||||
<td class="right-align">
|
||||
<a class="btn-small link waves-effect waves-light">View<i class="material-icons right">send</i></a>
|
||||
</td>
|
||||
</tr>`,
|
||||
valueNames: ["creation_date", "description", "title",
|
||||
{data: ["id"]},
|
||||
{name: "link", attr: "href"},
|
||||
{name: "service", attr: "data-service"},
|
||||
{name: "status", attr: "data-status"}]}
|
||||
};
|
||||
|
||||
|
||||
class ResultList extends List {
|
||||
|
Reference in New Issue
Block a user