Skip to content

Commit

Permalink
Move canon'al dataset to the top of citation modal
Browse files Browse the repository at this point in the history
Canonical dataset citation is now before the "this version" citation in the citation modal on dataset landing pages.

Issue #2541
  • Loading branch information
robyngit committed Oct 17, 2024
1 parent ce860dd commit 270324e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/js/views/CanonicalDatasetHandlerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,12 @@ define([
citationModalView.citationContainer.prepend(heading);

// Add the citation for the canonical dataset
citationModalView.insertCitation(view.citationModel, false);

// Add a heading for the canonical dataset citation
const headingOriginal = document.createElement("h5");
headingOriginal.textContent = CITATION_TITLE_CANONICAL;
citationModalView.citationContainer.append(headingOriginal);
citationModalView.insertCitation(view.citationModel);
citationModalView.citationContainer.prepend(headingOriginal);
});
},

Expand Down
26 changes: 19 additions & 7 deletions src/js/views/citations/CitationModalView.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define([
"models/CitationModel",
"views/CitationView",
"text!templates/citations/citationModal.html",
], function ($, _, Backbone, Clipboard, Citation, CitationView, Template) {
], ($, _, Backbone, Clipboard, Citation, CitationView, Template) => {
"use strict";

/**
Expand All @@ -17,7 +17,7 @@ define([
* @classcategory Views
* @extends Backbone.View
*/
var CitationModalView = Backbone.View.extend(
const CitationModalView = Backbone.View.extend(
/** @lends CitationModalView.prototype */ {
/**
* Classes to add to the modal
Expand Down Expand Up @@ -195,22 +195,34 @@ define([
* views to insert additional citation views into the modal.
* @param {CitationModel} model - The citation model to use. If not
* provided, the model passed to the view will be used.
* @param {boolean} after - If true, the citation will be inserted after
* any existing citations. If false, the citation will be inserted before
* any existing citations.
* @returns {CitationView} - Returns the CitationView that was inserted
* into the modal
*/
insertCitation: function (model) {
insertCitation(model, after = true) {
const container = this.citationContainer;
if (!container) return;
if (!container) return null;

// Create a new CitationView
var citationView = new CitationView({
const citationView = new CitationView({
model: model || this.model,
style: this.style,
createTitleLink: false,
});

// Render the CitationView
citationView.render();
const citationEl = citationView.render().el;

// Insert the CitationView into the modal
container.appendChild(citationView.el);
if (after) {
container.appendChild(citationEl);
} else {
container.prepend(citationEl);
}

return citationView;
},

/**
Expand Down

0 comments on commit 270324e

Please sign in to comment.