From 722b1ba651ec16dcdd5e97575345e5472c0064c7 Mon Sep 17 00:00:00 2001 From: laurenwalker Date: Mon, 6 Nov 2017 18:04:40 -0500 Subject: [PATCH] Checking in an experimental EMLTaxonView that is not used by the app, but was originally created as a start to refactoring the Taxa rendering in the Editor. See #25 --- .../webapp/js/views/metadata/EMLTaxonView.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js diff --git a/metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js b/metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js new file mode 100644 index 000000000..74532af21 --- /dev/null +++ b/metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js @@ -0,0 +1,67 @@ +/* +* +* ------------ WARNING --------------- +* This view is not hooked up to the overall app. It is not used anywhere. +* This view was created as a starting point for refactoring the Taxon section. +* The Taxon tables in the Editor should have its own views. This was a starting point on that but it is not finished. + For now the taxon information is all rendered in the EML211View. +*/ + +/* global define */ +define(['underscore', 'jquery', 'backbone', 'models/metadata/eml211/EMLTaxonCoverage', + 'text!templates/metadata/taxonomicClassificationTable.html', + 'text!templates/metadata/taxonomicClassificationRow.html'], + function(_, $, Backbone, EMLTaxonCoverage, TaxonomicClassificationTable, TaxonomicClassificationRow){ + + var EMLTaxonView = Backbone.Model.extend({ + + className: "row-fluid taxonomic-coverage", + + tagName: "div" + + initialize: function(options){ + if(!options) + var options = {}; + + this.isNew = options.isNew || false; + this.model = options.model || new EMLTaxonCoverage(); + }, + + // Creates a table to hold a single EMLTaxonCoverage element (table) for + // each root-level taxonomicClassification + render: function(coverage) { + + var finishedEl = $('
'); + $(finishedEl).data({ model: coverage }); + $(finishedEl).attr("data-category", "taxonomic-coverage"); + + var classifications = coverage.get("taxonomicClassification"); + + // Make a textarea for the generalTaxonomicCoverage + var generalCoverageEl = $(document.createElement('textarea')) + .addClass("medium text") + .attr("data-category", "generalTaxonomicCoverage") + .text(coverage.get('generalTaxonomicCoverage') || "" ); + + $(finishedEl).append($(document.createElement('h5')).text('General Taxonomic Coverage')); + $(finishedEl).append(generalCoverageEl); + + // taxonomicClassifications + $(finishedEl).append($(document.createElement('h5')).text('Taxonomic Classification(s)')); + + // Makes a table... for the root level + for (var i = 0; i < classifications.length; i++) { + $(finishedEl).append(this.createTaxonomicClassifcationTable(classifications[i])); + } + + // Create a new, blank table for another taxonomicClassification + var newTableEl = this.createTaxonomicClassifcationTable(); + + $(finishedEl).append(newTableEl); + + return finishedEl; + } + }); + + return EMLTaxonView; +}); \ No newline at end of file