Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIR-1246 MIR.defaultCitationStyle should not be ignored #908

Merged
merged 2 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ jobs:
- name: Set up test dependencies
run: |
# PPA by Mozilla for ESR releases
sudo add-apt-repository ppa:mozillateam/ppa
# replace 'sudo add-apt-repository ppa:mozillateam/ppa' with simple commands as workaround for https://github.com/orgs/community/discussions/69720
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0AB215679C571D1C8325275B9BDB3D89CE49EC21
sudo add-apt-repository "deb https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu/ focal main"

sudo apt update
sudo apt install firefox-esr chromium-browser chromium-chromedriver dbus-x11
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
(function() {
$(document).ready(function () {
let objectID = $("#mir-csl-cite").attr("data-object-id");
const citeSelect = $("#mir-csl-cite");
let objectID = citeSelect.attr("data-object-id");
let defaultStyle = citeSelect.attr("data-default-selected");

$('#mir-csl-cite').on('change', function() {
getCitation(objectID, $(this).val(), false);
localStorage.setItem('style', $(this).val());
});

loadStyle(objectID);
loadStyle(objectID, defaultStyle);
});

function getCitation(objectID, style, first) {
Expand All @@ -30,14 +32,20 @@
});
}

function loadStyle(objectID) {
function loadStyle(objectID, defaultStyle) {
let style = localStorage.getItem('style');
if (style !== undefined && style !== null && style !== '') {
getCitation(objectID, style, true);
$('#mir-csl-cite').val(style);
}
else {
getCitation(objectID, 'deutsche-sprache', true);
if(defaultStyle){
getCitation(objectID, defaultStyle, true);
$('#mir-csl-cite').val(defaultStyle);
} else {
getCitation(objectID, 'deutsche-sprache', true);
console.warn("No default style defined. Using 'deutsche-sprache'.");
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion mir-module/src/main/resources/xsl/metadata/mir-citation.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
<xsl:with-param name="delimiter" select="','" />
</xsl:call-template>
</xsl:variable>
<select class="form-control input-sm" id="mir-csl-cite" data-object-id="{/mycoreobject/@ID}">
<select class="form-control input-sm" id="mir-csl-cite"
data-default-selected="{$MIR.defaultCitationStyle}"
data-object-id="{/mycoreobject/@ID}">
<xsl:for-each select="exslt:node-set($cite-styles)/token">
<option value="{.}">
<xsl:variable name="cslDocument" select="document(concat('resource:', text(), '.csl'))"/>
Expand Down
Loading