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

RIS file not exporting from Shiny app #176

Closed
rootsandberries opened this issue May 31, 2024 · 6 comments
Closed

RIS file not exporting from Shiny app #176

rootsandberries opened this issue May 31, 2024 · 6 comments
Assignees

Comments

@rootsandberries
Copy link
Collaborator

I get the following message when trying to export RIS (csv and bibtex are working fine):

Warning in export_ris(rv$latest_unique, file) :
Function saves a RIS file, so filename should (usually) end in .ris. For now, name is used as provided.

Final Mapping:
DB : cite_source_include
C7 : cite_label_include
C8 : cite_string_include
C1 : duplicate_id
C2 : record_ids
Do you want to proceed with this mapping? (yes/no): y
Export cancelled. Please modify your user_mapping argument and try again.

When I choose yes or no, it exports a file with this name: downloadRis.html and also gives me the following error (weirdly, nothing actually saves when I save this file or when I change the extension to RIS).

Export cancelled. Please modify your user_mapping argument and try again.

@TNRiley
Copy link
Collaborator

TNRiley commented May 31, 2024

I noticed the same thing and have it listed on issue #152 which has a number of consolidated shiny issues.

@TNRiley
Copy link
Collaborator

TNRiley commented May 31, 2024

This error is due to a change I made recently to help users map IDs and tags to specific fields. I wanted to give the user an option to review the mapping before export. I'm not sure if we could replicate this function in the shiny export, but that would be nice. I'll keep looking at this - I'm also going to remove it from #152 as this mapping function would be useful.

@TNRiley
Copy link
Collaborator

TNRiley commented May 31, 2024

possible to add these option in the shiny with this? - I'm not experienced with the shiny UI file. Let's discuss.

export_ris_shiny <- function(input, output, session, citations, filename = "output.ris") {
  
  # Default mapping of RIS fields to citations columns
  default_mapping <- reactive({
    list(
      "DB" = input$cite_source_include,
      "C7" = input$cite_label_include,
      "C8" = input$cite_string_include,
      "C1" = input$duplicate_id,
      "C2" = input$record_ids
    )
  })
  
  observeEvent(input$confirm_mapping, {
    # Rename the citations columns according to the final mapping
    for (field in names(default_mapping())) {
      if (default_mapping()[[field]] %in% names(citations)) {
        citations <- citations %>% dplyr::rename(!!field := .data[[default_mapping()[[field]]]])
      }
    }
    
    # Currently, write_refs does not accept tibbles, thus converted
    write_refs(as.data.frame(citations), file = filename)
  })
}

need to add the appropriate input widgets to your UI for the user to select the mapping, and an action button with the ID confirm_mapping for the user to confirm the mapping.

@DrMattG
Copy link
Collaborator

DrMattG commented Jun 17, 2024

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

@TNRiley
Copy link
Collaborator

TNRiley commented Jul 2, 2024

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

I'm still running into export issues with the .ris in the shiny, still tries do download as downloadRis.htm

@DrMattG
Copy link
Collaborator

DrMattG commented Jul 3, 2024

I changed the function back so it is able to download RIS - with the default mapping for the moment (so the shiny works) whilst I try and include mapping choices

I'm still running into export issues with the .ris in the shiny, still tries do download as downloadRis.htm

Because I forgot to merge the pull request!

@TNRiley TNRiley closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants