Skip to content

Commit

Permalink
Merge pull request #629 from CDLUC3/bug/narrative-pdf-is-not-removed-…
Browse files Browse the repository at this point in the history
…from-upload-plan

Bug/narrative pdf is not removed from upload plan
  • Loading branch information
jupiter007 authored Jul 10, 2024
2 parents c6c3297 + 5a1540b commit 66d9be9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/controllers/api/v3/drafts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ def update_narrative
dmp.narrative.purge if (create_params[:narrative].present? || create_params[:remove_narrative].present?) &&
dmp.narrative.attached?

# Remove the narrative from the metadata if it was purged
dmp.metadata.fetch('dmp', {})['draft_data']['narrative'] = {} if dmp.metadata.fetch('dmp', {})['draft_data'].present? && create_params[:remove_narrative].present?

# Attach the narrative PDF if applicable
dmp.metadata.fetch('dmp', {})['title'] = create_params[:title] if create_params[:title].present?
dmp.narrative.attach(create_params[:narrative]) if create_params[:narrative].present?

if dmp.save
@drafts = [dmp]
render json: render_to_string(template: '/api/v3/drafts/index'), status: :ok
Expand Down
2 changes: 1 addition & 1 deletion react-client/src/pages/plan/setup/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function DmpSetup() {

<div className="dmpui-field-fileinput-group">
<div>
{dmp.narrative && (
{dmp.narrative?.url && (
<>
<p>
<a href={dmp.narrative?.url} target="_blank">{dmp.narrative?.file_name}</a>
Expand Down

0 comments on commit 66d9be9

Please sign in to comment.