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-1412 Show MD5 sum for each file in the derivate file list #1089

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
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,10 @@ ul ul span.cbNum {
word-break: break-all;
padding-right: 20px;
}

.file_md5 {
&.hidden {
display: none;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<a href="{{href}}">
{{name}}
</a>
<div class="file_md5 hidden">
<span class="file_md5_label">{{getI18n "mir.derivate.file.MD5"}}</span> {{md5}}
</div>
</td>
{{/contains}}
{{else}}
Expand Down
51 changes: 51 additions & 0 deletions mir-module/src/main/resources/META-INF/resources/js/mir/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,57 @@
}
});

// Element with the link to toggle to show/hide md5 sums
const toggleMD5LinkElement = '.toggleMD5Link';
// Derivate action dropdown toggle button element
const derivateActionDropdownToggleButton = '.headline .dropdown.options .dropdown-toggle';
// Element selector with md5 information
const md5ElementSelector = '.file_md5';
// Element selector for the derivate file box
const fileBoxSelector = '.file_box';

// Show/hide md5 sums by derivate files by clicking on the 'toggleMD5LinkElement' element
$(toggleMD5LinkElement).click((evt) => {
evt.preventDefault();
// Get a current derivate parent element
const currentDerivateIdParentElements = $(evt.currentTarget).closest(fileBoxSelector);
if (currentDerivateIdParentElements.length) {
// Get all elements for all files with the md5 sum
const currentMd5Elements = $(currentDerivateIdParentElements.get(0)).find(md5ElementSelector);
if (currentMd5Elements.length) {
// Show/hide every element
currentMd5Elements.each((index, element) => {
$(element).toggleClass('hidden');
});
}
}
});

// Getting i18n translation for the link to switch state 'show/hide MD5 amounts' depending on the visibility of the
// message with this amount when clicking on the 'derivateActionDropdownToggleButton' element
$(derivateActionDropdownToggleButton).click((evt) => {
Copy link
Member

@golsch golsch Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would define the dropdown more explicitly, the display should only refer to a specific derivate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

// Get a current derivate parent element
const currentDerivateIdParentElements = $(evt.currentTarget).closest(fileBoxSelector);
if (currentDerivateIdParentElements.length) {
// Get all elements for all files with the md5 sum
const currentMd5Elements = $(currentDerivateIdParentElements.get(0)).find(md5ElementSelector);
if (currentMd5Elements.length) {
// only the first element is checked for the presence/absence of a hidden class,
// assuming that the remaining elements of the current derivate meet this condition
const i18nKey = ($(currentMd5Elements.get(0)).hasClass('hidden'))
? ('component.mods.metaData.options.MD5.show')
: ('component.mods.metaData.options.MD5.hide');

// Get a current toggle element
const currentToggleMD5LinkElement = $(currentDerivateIdParentElements.get(0)).find(toggleMD5LinkElement);

if (currentToggleMD5LinkElement.length) {
getI18n(i18nKey, currentToggleMD5LinkElement.get(0));
}
}
}
});

var languageList = jQuery('#topnav .languageList');
jQuery('#topnav .languageSelect').click(function() {
languageList.toggleClass('hide');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,9 @@
const mirKeyURL = webApplicationBaseURL + "rsc/locale/translate/" + lang + "/mir.confirm.*";
const pagiKeyURL = webApplicationBaseURL + "rsc/locale/translate/" + lang + "/mir.pagination.*";
const uploadKeyURL = webApplicationBaseURL + "rsc/locale/translate/" + lang + "/mir.upload.drop.*";
const allRequests = Promise.all([ifsKeyURL, mirKeyURL, pagiKeyURL, uploadKeyURL]
const derivateFileKeyURL = webApplicationBaseURL + "rsc/locale/translate/" + lang + "/mir.derivate.file.*";
const allRequests = Promise.all([ifsKeyURL, mirKeyURL, pagiKeyURL, uploadKeyURL,
derivateFileKeyURL]
.map((url)=> fetch(url))
.map((promise)=> promise.then((response)=> response.json())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ component.mods.metaData.options.derivateLocked = Bearbeitung wg. PI ges
component.mods.metaData.options.updateDerivateName = Dateibereich verwalten
component.mods.metaData.options.startmets = im METS-Editor \u00F6ffnen
component.mods.metaData.options.zip = als Zip speichern
component.mods.metaData.options.MD5.show = MD5 Summen anzeigen
component.mods.metaData.options.MD5.hide = MD5 Summen ausblenden
component.pi.register.DNBURN = URN registrieren
component.pi.register.Datacite = DOI registrieren
component.pi.register.Epic = ePIC registrieren
Expand Down Expand Up @@ -915,3 +917,4 @@ subselect.category.title = Kategorie ausw\u00E4hlen

user.profile.id.orcid = Ihre ORCID iD
selfRegistration.error.mailExists = Die E-Mail-Adresse wird bereits verwendet.
mir.derivate.file.MD5 = MD5 Summe:
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ component.mods.metaData.options.derivateLocked = locked due to PI
component.mods.metaData.options.startmets = open in METS editor
component.mods.metaData.options.updateDerivateName = Manage file space
component.mods.metaData.options.zip = save as Zip
component.mods.metaData.options.MD5.show = Show MD5 sums
component.mods.metaData.options.MD5.hide = Hide MD5 sums
component.pi.register.DNBURN = register URN
component.pi.register.Datacite = register DOI
component.pi.register.Epic = register ePIC
Expand Down Expand Up @@ -286,6 +288,7 @@ mir.derivate.no_access.intern = To see the attached files you h
mir.derivate.no_access.ipAddressRange = You can access the attached files only from a computer in the library.
mir.derivate.not_full_access = You do not have the required rights to see all attached files.
mir.derivate.type = derivate type
mir.derivate.file.MD5 = MD5 sum:
mir.details.issue = No.
mir.details.personpopover.title = person details
mir.details.volume.journal = Vol.
Expand Down Expand Up @@ -867,3 +870,4 @@ subselect.category.cancel = Cancel
subselect.category.title = Choose category

user.profile.id.orcid = Your ORCID iD

Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,6 @@ mir.response.facet.modifiedby.title = Modificato da
mir.response.facet.mods.author.title = Autore

user.profile.id.orcid = Your ORCID iD
component.mods.metaData.options.MD5.show = Mostra somme MD5
component.mods.metaData.options.MD5.hide = Nascondi somme MD5
mir.derivate.file.MD5 = somma MD5:
6 changes: 6 additions & 0 deletions mir-module/src/main/resources/xsl/modsdetails-external.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,12 @@
<xsl:value-of select="i18n:translate('component.mods.metaData.options.updateDerivateName')" />
</a>
</li>
<li>
<!-- Link to toggle to show/hide md5 sum -->
<a href="#" class="option dropdown-item toggleMD5Link">
<xsl:value-of select="i18n:translate('component.mods.metaData.options.MD5.show')" />
</a>
</li>
</xsl:if>
<xsl:if test="key('rights', $deriv)/@write and iview2:getSupportedMainFile($deriv) and normalize-space($MIR.METSEditor.enable)='true'">
<li>
Expand Down
Loading