diff --git a/app/static/css/nopaque.css b/app/static/css/nopaque.css index 3cdd89ac..9094c451 100644 --- a/app/static/css/nopaque.css +++ b/app/static/css/nopaque.css @@ -90,6 +90,9 @@ indicator will show up how the column is sorted right now.; */ .service[data-service]:before { content: "help"; } +.service[data-service="corpus"]:before { + content: "book"; +} .service[data-service="merge_images"]:before { content: "burst_mode"; } diff --git a/app/static/js/nopaque.lists.js b/app/static/js/nopaque.lists.js index 8f72fc92..da255d30 100644 --- a/app/static/js/nopaque.lists.js +++ b/app/static/js/nopaque.lists.js @@ -1,106 +1,25 @@ -class CorpusList extends List { - constructor(idOrElement, subscriberList, options={}) { - super(idOrElement, {...CorpusList.DEFAULT_OPTIONS, ...options}); +class RessourceList extends List { + constructor(idOrElement, subscriberList, dataMapper=null, options={}) { + super(idOrElement, {...RessourceList.options, ...options}); + this.dataMapper = dataMapper; subscriberList.push(this); } - _init(corpora) { - this.addCorpora(Object.values(corpora)); + _init(ressources) { + this.addRessources(Object.values(ressources)); } _update(patch) { - let item, corpusStatusElement, operation, pathArray; + let item, pathArray; - for (operation of patch) { - /* "/corpusId/valueName" -> ["corpusId", "valueName"] */ + for (let operation of patch) { + /* "/ressourceId/valueName" -> ["ressourceId", "valueName"] */ pathArray = operation.path.split("/").slice(1); switch(operation.op) { case "add": - this.addCorpora([operation.value]); - break; - case "remove": - this.remove("id", pathArray[0]); - break; - case "replace": - item = this.get("id", pathArray[0])[0]; - switch(pathArray[1]) { - case "status": - item.values({status: operation.value, _status: operation.value}); - break; - default: - break; - } - default: - break; - } - } - } - - - addCorpora(corpora) { - let data = []; - for (let corpus of corpora) { - data.push({description: corpus.description, - id: corpus.id, - link: `/corpora/${corpus.id}`, - status: corpus.status, - title: corpus.title}); - } - this.add(data); - } -} -CorpusList.DEFAULT_OPTIONS = { - item: `