-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
d903395
commit 722b1ba
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
metacatui/src/main/webapp/js/views/metadata/EMLTaxonView.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); |