Skip to content

Commit

Permalink
Checking in an experimental EMLTaxonView that is not used by the app,
Browse files Browse the repository at this point in the history
but was originally created as a start to refactoring the Taxa rendering
in the Editor. See #25
  • Loading branch information
laurenwalker committed Nov 6, 2017
1 parent d903395 commit 722b1ba
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js
Original file line number Diff line number Diff line change
@@ -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 = $('<div class="row-fluid taxonomic-coverage"></div>');
$(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;
});

0 comments on commit 722b1ba

Please sign in to comment.