diff --git a/app/Mail/ReviewStepNotificationMail.php b/app/Mail/ReviewStepNotificationMail.php index caac4add..d56819a9 100644 --- a/app/Mail/ReviewStepNotificationMail.php +++ b/app/Mail/ReviewStepNotificationMail.php @@ -21,7 +21,7 @@ class ReviewStepNotificationMail extends Mailable * * @return void */ - public function __construct(public ManagementReviewStep $managementReviewStep, public User $user) + public function __construct(public ManagementReviewStep $managementReviewStep) { $this->previousStep = $managementReviewStep->previousStep->load('user'); $this->manuscriptRecord = $managementReviewStep->manuscriptRecord->load('user', 'manuscriptAuthors.author'); diff --git a/app/Policies/ManuscriptRecordPolicy.php b/app/Policies/ManuscriptRecordPolicy.php index f8d751bb..bc404a5e 100644 --- a/app/Policies/ManuscriptRecordPolicy.php +++ b/app/Policies/ManuscriptRecordPolicy.php @@ -74,7 +74,6 @@ public function update(User $user, ManuscriptRecord $manuscriptRecord) if ($user->id === $manuscriptRecord->user_id) { return true; } - return $manuscriptRecord->shareables->firstWhere('user_id', $user->id)?->isEditable(); case ManuscriptRecordStatus::IN_REVIEW: return $manuscriptRecord->managementReviewSteps->contains('user_id', $user->id); diff --git a/resources/src/locales/en.json b/resources/src/locales/en.json index a4274181..3143fa92 100644 --- a/resources/src/locales/en.json +++ b/resources/src/locales/en.json @@ -242,7 +242,8 @@ "your-email": "Your email", "your-first-name": "Your first name", "your-last-name": "Your last name", - "your-password": "Your password" + "your-password": "Your password", + "share": "Share" }, "create-author-dialog": { "title": "Create a new author" @@ -451,8 +452,7 @@ "withdrawn-by-applicant": "Withdrawn by Applicant", "withdrawn-details": "The manuscript was withdrawn by the applicant. The manuscript record will be archived after 30 days." }, - "manuscript-record": { - }, + "manuscript-record": {}, "mrf": { "abstract-must-be-at-least-250-characters": "Abstract must be at least 250 characters", "additional-information-of-importance": "Potential Public Interest", @@ -668,5 +668,10 @@ "withdraw-manuscript-dialog": { "text": "Withdraw this manuscript. This lets us know that this manuscript will not be published and closes this manuscript record.", "title": "Withdraw this manuscript" + }, + "shareable-dialog": { + "user-create-text": "User with whom you want to share. The user will receive an email notification once you share this resource.", + "abilities-text": "By default, the user has the ability to view the ressource. You can also allow th user to edit and delete this resource.", + "expiry-date-text": "By default, the resource is shared until you manually remove the ability. If you prefer, you can also set an expiration date at which time the user will no longer be able to access this resource." } } diff --git a/resources/src/locales/fr.json b/resources/src/locales/fr.json index 0fc335a6..e5a08390 100644 --- a/resources/src/locales/fr.json +++ b/resources/src/locales/fr.json @@ -242,7 +242,8 @@ "your-email": "Votre courriel", "your-first-name": "Ton prénom", "your-last-name": "Votre nom de famille", - "your-password": "Votre mot de passe" + "your-password": "Votre mot de passe", + "share": "Partager" }, "create-author-dialog": { "title": "Créer un nouvel auteur" @@ -451,8 +452,7 @@ "withdrawn-by-applicant": "Retiré par le demandeur", "withdrawn-details": "Le manuscrit a été retiré par le demandeur. \nLe régistre du manuscrit sera archivé après 30 jours." }, - "manuscript-record": { - }, + "manuscript-record": {}, "mrf": { "abstract-must-be-at-least-250-characters": "Le résumé doit comporter au moins 250 caractères", "additional-information-of-importance": "Intérêt public potentiel", @@ -668,5 +668,10 @@ "withdraw-manuscript-dialog": { "text": "Retirez ce manuscrit. \nCela nous permet de savoir que ce manuscrit ne sera pas publié et ferme ce registre de manuscrit.", "title": "Retirer ce manuscrit" + }, + "shareable-dialog": { + "expiry-date-text": "Par défaut, la ressource est partagée jusqu'à ce que vous supprimiez manuellement la capacité. \nSi vous préférez, vous pouvez également définir une date d'expiration à laquelle l'utilisateur ne pourra plus accéder à cette ressource.", + "abilities-text": "Par défaut, l'utilisateur a la possibilité de visualiser la ressource. \nVous pouvez également autoriser l'utilisateur à modifier et supprimer cette ressource.", + "user-create-text": "L'utilisateur avec lequel vous souhaitez partager. \nL'utilisateur recevra une notification par e-mail une fois que vous partagerez cette ressource." } } diff --git a/resources/src/models/ManuscriptRecord/views/ManuscriptRecordSharingView.vue b/resources/src/models/ManuscriptRecord/views/ManuscriptRecordSharingView.vue index bf0cdcd2..64ff378c 100644 --- a/resources/src/models/ManuscriptRecord/views/ManuscriptRecordSharingView.vue +++ b/resources/src/models/ManuscriptRecord/views/ManuscriptRecordSharingView.vue @@ -13,7 +13,7 @@ @@ -24,6 +24,9 @@ shareable-type="manuscript-records" :shareable="editShareableItem" :shareable-model-id="manuscript?.data.id" + :disabled-user-ids="disabledUserIds" + @created="shareableCreated" + @updated="shareableUpdated" /> @@ -60,8 +63,9 @@ onMounted(async () => { loading.value = false; }); +const authStore = useAuthStore(); const readonly = computed(() => { - return manuscript.value?.can?.update === false; + return manuscript.value?.data.user_id !== authStore.user?.id; }); const $q = useQuasar(); @@ -89,6 +93,13 @@ async function deleteShareable(shareable: ShareableResource) { */ const showShareDialog = ref(false); const editShareableItem = ref(undefined); +const disabledUserIds = computed(() => { + const ids = shareables.value?.data.map((s) => s.data.user.data.id) || []; + if (manuscript.value?.data.user_id !== undefined) { + ids.push(manuscript.value.data.user_id); + } + return ids; +}); function createShareable() { editShareableItem.value = undefined; @@ -102,6 +113,21 @@ function editShareable(shareable: ShareableResource) { editShareableItem.value = shareable.data; showShareDialog.value = true; } + +function shareableCreated(shareable: ShareableResource) { + shareables.value?.data.push(shareable); + showShareDialog.value = false; +} + +function shareableUpdated(shareable: ShareableResource) { + const index = shareables.value?.data.findIndex( + (s) => s.data.id === shareable.data.id, + ); + if (index !== undefined && index !== -1) { + shareables.value?.data.splice(index, 1, shareable); + } + showShareDialog.value = false; +} diff --git a/resources/src/models/Shareable/components/ShareItemDialog.vue b/resources/src/models/Shareable/components/ShareItemDialog.vue index 13f3ac2f..62b09ded 100644 --- a/resources/src/models/Shareable/components/ShareItemDialog.vue +++ b/resources/src/models/Shareable/components/ShareItemDialog.vue @@ -1,20 +1,23 @@