-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds Missing Line Item Initiative Management Features (#175)
- Loading branch information
Showing
12 changed files
with
270 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script setup lang="ts"> | ||
import { type Portfolio, type AccessBlobContentResp } from '@/openapi/generated/pacta' | ||
const { t } = useI18n() | ||
const pactaClient = usePACTA() | ||
const { error: { handleError } } = useModal() | ||
interface Props { | ||
portfolio: Portfolio | ||
} | ||
const props = defineProps<Props>() | ||
const prefix = 'components/portfolio/DownloadButton' | ||
const statePrefix = `${prefix}[${useStateIDGenerator().id()}]` | ||
const tt = (key: string) => t(`${prefix}.${key}`) | ||
const downloadInProgress = useState<boolean>(`${statePrefix}.downloadInProgress`, () => false) | ||
const doDownload = async () => { | ||
const blob = props.portfolio.blob | ||
if (!blob) { | ||
handleError(new Error(`Portfolio did not have blob associated with it, and could not be downloaded: ${props.portfolio.id}`)) | ||
return | ||
} | ||
const blobId = blob.id | ||
downloadInProgress.value = true | ||
const resp: AccessBlobContentResp = await pactaClient.accessBlobContent({ items: [{ blobId }] }) | ||
const response = await fetch(resp.items[0].downloadUrl) | ||
const data = await response.blob() | ||
const element = document.createElement('a') | ||
element.href = URL.createObjectURL(data) | ||
const fileName = `${blob.fileName}` | ||
element.download = fileName | ||
document.body.appendChild(element) | ||
element.click() | ||
document.body.removeChild(element) | ||
downloadInProgress.value = false | ||
} | ||
</script> | ||
|
||
<template> | ||
<PVButton | ||
:loading="downloadInProgress" | ||
:icon="downloadInProgress ? 'pi pi-spinner pi-spin' : 'pi pi-download'" | ||
class="p-button-secondary p-button-outlined p-button-xs" | ||
:label="tt('Download')" | ||
@click="doDownload" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.