Skip to content
Snippets Groups Projects
Select Git revision
  • d63effd98c023bc9772ccf6665c3940e0695e3fb
  • master default protected
  • cmp_tool-improvement
  • v0.15
  • v0.14
  • v0.13
  • v0.12
  • v0.11
  • v0.09
  • v0.08
  • v0.07
  • v0.06
  • v0.05
13 results

cmp_icu.h

Blame
  • Citation.vue 1.71 KiB
    <template>
      <v-row
        no-gutters>
        <v-col
          v-if="!loading"
          lg="10">
          {{ citation }}
        </v-col>
        <v-col
          v-if="!$vuetify.display.mdAndDown"
          lg="2"
          class="cite-style">
          <v-select
            v-model="style"
            :items="styles"
            item-title="title"
            item-value="value"
            dense
            variant="outlined"
            single-line />
        </v-col>
      </v-row>
    </template>
    
    <script>
    export default {
      props: {
        identifier: {
          type: Object,
          default () {
            return {}
          }
        }
      },
      data () {
        return {
          loading: false,
          styles: [
            { title: 'APA', value: 'text/bibliography;style=apa' },
            { title: 'IEEE', value: 'text/bibliography;style=ieee' },
            { title: 'BibTeX', value: 'text/bibliography;style=bibtex' }
          ],
          style: 'text/bibliography;style=apa',
          citation: null
        }
      },
      watch: {
        style () {
          this.loadCitation()
        },
        pid () {
          this.loadCitation()
        }
      },
      mounted () {
        this.loadCitation()
      },
      methods: {
        loadCitation () {
          if (!this.identifier || !this.style) {
            return
          }
          this.loading = true
          const identifierService = useIdentifierService()
          identifierService.findOne(this.identifier.id, this.style)
            .then((citation) => {
              this.citation = citation
              this.loading = false
            })
            .catch(({code, message}) => {
              this.loading = false
              const toast = useToastInstance()
              if (typeof code !== 'string') {
                return
              }
              toast.error(this.$t(`${code}: ${message}`))
            })
        }
      }
    }
    </script>
    <style scoped>
    .cite-style {
      cursor: pointer !important;
    }
    </style>