Skip to content

Commit

Permalink
pkp/pkp-lib#7505 Load Jats when changes happen to publication
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Dec 4, 2023
1 parent 87698c9 commit 3041c58
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 62 deletions.
56 changes: 28 additions & 28 deletions src/components/ListPanel/contributors/ContributorsListPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ export default {
this.$emit('updated:contributors', newContributors);
}
this.closeFormModal();
this.getAndUpdatePublication();
},
/**
Expand All @@ -374,20 +376,7 @@ export default {
openPreviewModal() {
this.isLoading = true;
$.ajax({
url: this.publicationApiUrl,
type: 'GET',
context: this,
error: this.ajaxErrorCallback,
success(publication) {
this.$emit('updated:publication', publication);
this.isModalOpenedPreview = true;
},
complete(r) {
this.isLoading = false;
},
});
this.getAndUpdatePublication();
},
/**
Expand Down Expand Up @@ -445,6 +434,8 @@ export default {
},
);
this.$emit('updated:contributors', newContributors);
this.getAndUpdatePublication();
},
complete(r) {
this.isLoading = false;
Expand Down Expand Up @@ -529,6 +520,8 @@ export default {
cancelOrdering() {
this.$emit('updated:contributors', this.itemsBeforeReordering);
this.getAndUpdatePublication();
this.itemsBeforeReordering = null;
this.isOrdering = false;
},
Expand Down Expand Up @@ -563,20 +556,7 @@ export default {
success(contributors) {
this.$emit('updated:contributors', contributors);
// Update the publication in the background so that
// any author strings are updated
$.ajax({
url: this.publicationApiUrl,
context: this,
type: 'GET',
success(publication) {
this.$emit('updated:publication', publication);
},
complete() {
this.isLoading = false;
this.isOrdering = false;
},
});
this.getAndUpdatePublication();
},
error: this.ajaxErrorCallback,
complete() {
Expand Down Expand Up @@ -651,6 +631,26 @@ export default {
this.$emit('updated:contributors', newItems);
},
/**
* Update the publication in the background so that
* any author strings are updated
*/
getAndUpdatePublication() {
$.ajax({
url: this.publicationApiUrl,
context: this,
type: 'GET',
success(publication) {
this.$emit('updated:publication', publication);
},
complete() {
this.isLoading = false;
this.isOrdering = false;
},
});
},
},
};
</script>
Expand Down
60 changes: 26 additions & 34 deletions src/components/ListPanel/jats/SubmissionJatsListPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
<pkp-header>
<h2>{{ title }}</h2>
<template #actions>
<div v-if="existingJatsFile">
<pkp-button
<div v-if="isDefaultContent">
<pkp-button
v-if="
publication.status !== getConstant('STATUS_PUBLISHED') &&
canEditPublication
"
:disabled="isLoading"
:isWarnable="true"
@click="openDeleteModal"
ref="uploadXMLButton" @click="openFileBrowser"
>
{{ t('common.delete') }}
{{ t('common.upload') }}
</pkp-button>
</div>
<div v-else>
<pkp-button
<pkp-button
v-if="
publication.status !== getConstant('STATUS_PUBLISHED') &&
canEditPublication
"
ref="uploadXMLButton" @click="openFileBrowser">
{{ t('common.upload') }}
:disabled="isLoading"
:isWarnable="true"
@click="openDeleteModal"
>
{{ t('common.delete') }}
</pkp-button>
</div>
<pkp-button ref="downloadJatsXMLButton" @click="downloadJatsXML">
Expand All @@ -44,14 +45,14 @@
</pre>
</div>
<div>
<div v-if="existingJatsFile" class="filePanel__hasData">
<div class="filePanel__fileContentFooter">
<span>{{ lastModifiedAtActual }}</span>
<div v-if="isDefaultContent" class="filePanel__hasData">
<div class="filePanel__defaultContentFooter">
<span>{{ t('publication.jats.autoCreatedMessage') }}</span>
</div>
</div>
<div v-else>
<div class="filePanel__defaultContentFooter">
<span>{{ t('publication.jats.autoCreatedMessage') }}</span>
<div class="filePanel__fileContentFooter">
<span>{{ lastModifiedAtActual }}</span>
</div>
</div>
</div>
Expand Down Expand Up @@ -161,18 +162,11 @@ export default {
this.fetchWorkingJatsFile();
},
computed: {
defaultJatsContent() {
return this.workingJatsProps['defaultJatsContent'];
},
existingJatsFile() {
return this.workingJatsProps['existingJatsFile'];
isDefaultContent() {
return this.workingJatsProps['isDefaultContent'];
},
workingJatsContent() {
if (this.existingJatsFile) {
return this.existingJatsFile['jatsContent'];
} else {
return this.defaultJatsContent;
}
return this.workingJatsProps['jatsContent'];
},
/**
* URL to the API endpoint for the current publication
Expand All @@ -187,15 +181,15 @@ export default {
lastModifiedAtActual() {
var actual = '';
if (this.existingJatsFile) {
if (!this.isDefaultContent) {
actual = this.i18nLastModifiedAt.replace(
'{$modificationDate}',
this.existingJatsFile.updatedAt,
this.workingJatsProps.updatedAt,
);
actual = actual.replace(
'{$username}',
this.existingJatsFile.uploaderUserName,
this.workingJatsProps.uploaderUserName,
);
}
Expand Down Expand Up @@ -298,8 +292,8 @@ export default {
*/
downloadJatsXML() {
// Ensure existingJatsFile.url is available and is a string containing the URL
if (this.existingJatsFile && this.existingJatsFile.url) {
const downloadUrl = this.existingJatsFile.url;
if (!this.workingJatsProps.isDefaultContent) {
const downloadUrl = this.workingJatsProps.url;
// Create a link element
const link = document.createElement('a');
Expand All @@ -315,8 +309,8 @@ export default {
// Remove the link from the DOM
document.body.removeChild(link);
} else if (this.defaultJatsContent) {
const jatsContent = this.defaultJatsContent;
} else {
const jatsContent = this.workingJatsProps.jatsContent;
const blob = new Blob([jatsContent], { type: 'application/xml' });
const blobUrl = URL.createObjectURL(blob);
Expand All @@ -330,8 +324,6 @@ export default {
// Clean up the URL object
URL.revokeObjectURL(blobUrl);
document.body.removeChild(link);
} else {
console.error('Download URL is not available.');
}
},
},
Expand All @@ -342,7 +334,7 @@ export default {
}
if (newValue != null && newValue[0] != null) {
if (newValue[0].hasOwnProperty('existingJatsFile')) {
if (newValue[0].hasOwnProperty('jatsContent')) {
this.workingJatsProps = newValue[0];
this.hasLoadedContent = true;
}
Expand Down

0 comments on commit 3041c58

Please sign in to comment.