mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Use custom List classes for corpora and job lists.
This commit is contained in:
		@@ -31,15 +31,13 @@
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
<script>
 | 
			
		||||
  corpusList = new List("corpus-list", {valueNames: ["title"],
 | 
			
		||||
                                        page: 4,
 | 
			
		||||
                                        pagination: true});
 | 
			
		||||
  corpusList.on("filterComplete", updatePagination);
 | 
			
		||||
  corpusList.on("searchComplete", updatePagination);
 | 
			
		||||
  createCorpusElements(corpusList);
 | 
			
		||||
  subscribers.corpora.push(function() {
 | 
			
		||||
    console.log('[Corpora]: Something changed.');
 | 
			
		||||
  });
 | 
			
		||||
  var corpusListOptions = {item: '<a><span class="title"></span><span class="description"></span></a>',
 | 
			
		||||
                           page: 4,
 | 
			
		||||
                           pagination: true,
 | 
			
		||||
                           valueNames: ["description", "title", {data: ["id"]}]}
 | 
			
		||||
  var corpusList = new CorpusList("corpus-list", corpusListOptions, true);
 | 
			
		||||
  corpusList.on("filterComplete", List.updatePagination);
 | 
			
		||||
  corpusList.on("searchComplete", List.updatePagination);
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<div class="col s12">
 | 
			
		||||
@@ -76,45 +74,13 @@
 | 
			
		||||
  </div>
 | 
			
		||||
</div>
 | 
			
		||||
<script>
 | 
			
		||||
  var template = '<a><span class="title"></span></a>'
 | 
			
		||||
  var jobList = new List("job-list", {item: '<a><span class="title"></span></a>',
 | 
			
		||||
                                      page: 4,
 | 
			
		||||
                                      pagination: true,
 | 
			
		||||
                                      valueNames: ["description",
 | 
			
		||||
                                                   "title",
 | 
			
		||||
                                                   {data: ["id"]}]});
 | 
			
		||||
  jobList.on("filterComplete", updatePagination);
 | 
			
		||||
  jobList.on("searchComplete", updatePagination);
 | 
			
		||||
  createJobElements(jobList);
 | 
			
		||||
  subscribers.jobs.push(function(delta) {
 | 
			
		||||
    for (key in delta) {
 | 
			
		||||
      if (key === "_t") {continue;}
 | 
			
		||||
      if (key.startsWith("_")) {
 | 
			
		||||
        jobList.remove("id", delta[key][0].id);
 | 
			
		||||
      } else if (Array.isArray(delta[key])) {
 | 
			
		||||
        jobElement = createJobElement(delta[key][0]);
 | 
			
		||||
        listItem = jobList.add({"description": delta[key][0].description,
 | 
			
		||||
                                "title": delta[key][0].title,
 | 
			
		||||
                                "id": delta[key][0].id})[0];
 | 
			
		||||
        listItem.elm.replaceWith(jobElement);
 | 
			
		||||
        listItem.elm = jobElement;
 | 
			
		||||
      } else {
 | 
			
		||||
        var listItem = jobList.get("id", jobs[parseInt(key)].id)[0];
 | 
			
		||||
        if (delta[key]["status"]) {
 | 
			
		||||
          var jobStatusElement = listItem.elm.querySelector(".status");
 | 
			
		||||
          jobStatusElement.classList.remove(STATUS_COLORS[delta[key]["status"][0]]);
 | 
			
		||||
          jobStatusElement.classList.add(STATUS_COLORS[delta[key]["status"][1]]);
 | 
			
		||||
          jobStatusElement.innerHTML = delta[key]["status"][1];
 | 
			
		||||
        }
 | 
			
		||||
        if (delta[key]["description"]) {
 | 
			
		||||
          listItem.values({"description": delta[key]["description"][1]});
 | 
			
		||||
        }
 | 
			
		||||
        if (delta[key]["title"]) {
 | 
			
		||||
          listItem.values({"title": delta[key]["title"][1]});
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  });
 | 
			
		||||
  jobListOptions = {item: '<a><span class="title"></span><span class="description"></span></a>',
 | 
			
		||||
                    page: 4,
 | 
			
		||||
                    pagination: true,
 | 
			
		||||
                    valueNames: ["description", "title", {data: ["id"]}]}
 | 
			
		||||
  var jobList = new JobList("job-list", jobListOptions, true);
 | 
			
		||||
  jobList.on("filterComplete", List.updatePagination);
 | 
			
		||||
  jobList.on("searchComplete", List.updatePagination);
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
<div id="new-corpus-modal" class="modal">
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user