Skip to content

Commit

Permalink
Merge branch 'main' into grady/formalizesurlstructure
Browse files Browse the repository at this point in the history
  • Loading branch information
gbdubs committed Jan 22, 2024
2 parents d59608d + 1449b1b commit 71df3b6
Show file tree
Hide file tree
Showing 16 changed files with 73 additions and 38 deletions.
6 changes: 3 additions & 3 deletions cmd/server/pactasrv/conv/oapi_to_pacta.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ func AnalysisTypeFromOAPI(at api.AnalysisType) (pacta.AnalysisType, error) {
return "", oapierr.BadRequest("analysisTypeFromOAPI: unknown analysis type", zap.String("analysis_type", string(at)))
}

func HoldingsDateFromOAPI(hd *api.HoldingsDate) (*pacta.HoldingsDate, error) {
if hd == nil {
func HoldingsDateFromOAPI(hd api.HoldingsDate) (*pacta.HoldingsDate, error) {
if hd.Time == nil {
return nil, nil
}
return &pacta.HoldingsDate{
Time: hd.Time,
Time: *hd.Time,
}, nil
}

Expand Down
26 changes: 10 additions & 16 deletions cmd/server/pactasrv/conv/pacta_to_oapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ func InitiativeUserRelationshipToOAPI(i *pacta.InitiativeUserRelationship) (*api
}, nil
}

func HoldingsDateToOAPI(hd *pacta.HoldingsDate) (*api.HoldingsDate, error) {
func HoldingsDateToOAPI(hd *pacta.HoldingsDate) (api.HoldingsDate, error) {
if hd == nil {
return nil, nil
return api.HoldingsDate{}, nil
}
return &api.HoldingsDate{
Time: hd.Time,
return api.HoldingsDate{
Time: &hd.Time,
}, nil
}

Expand All @@ -208,12 +208,9 @@ func IncompleteUploadToOAPI(iu *pacta.IncompleteUpload) (*api.IncompleteUpload,
if err != nil {
return nil, oapierr.Internal("incompleteUploadToOAPI: failureCodeToOAPI failed", zap.Error(err))
}
var hd *api.HoldingsDate
if iu.Properties.HoldingsDate != nil {
hd, err = HoldingsDateToOAPI(iu.Properties.HoldingsDate)
if err != nil {
return nil, oapierr.Internal("incompleteUploadToOAPI: holdingsDateToOAPI failed", zap.Error(err))
}
hd, err := HoldingsDateToOAPI(iu.Properties.HoldingsDate)
if err != nil {
return nil, oapierr.Internal("incompleteUploadToOAPI: holdingsDateToOAPI failed", zap.Error(err))
}
return &api.IncompleteUpload{
Id: string(iu.ID),
Expand Down Expand Up @@ -255,12 +252,9 @@ func PortfolioToOAPI(p *pacta.Portfolio) (*api.Portfolio, error) {
if err != nil {
return nil, oapierr.Internal("initiativeToOAPI: portfolioInitiativeMembershipToOAPIInitiative failed", zap.Error(err))
}
var hd *api.HoldingsDate
if p.Properties.HoldingsDate != nil {
hd, err = HoldingsDateToOAPI(p.Properties.HoldingsDate)
if err != nil {
return nil, oapierr.Internal("portfolioToOAPI: holdingsDateToOAPI failed", zap.Error(err))
}
hd, err := HoldingsDateToOAPI(p.Properties.HoldingsDate)
if err != nil {
return nil, oapierr.Internal("portfolioToOAPI: holdingsDateToOAPI failed", zap.Error(err))
}
return &api.Portfolio{
Id: string(p.ID),
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/pactasrv/portfolio.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (s *Server) UpdatePortfolio(ctx context.Context, request api.UpdatePortfoli
mutations = append(mutations, db.SetPortfolioDescription(*request.Body.Description))
}
if request.Body.PropertyHoldingsDate != nil {
hd, err := conv.HoldingsDateFromOAPI(request.Body.PropertyHoldingsDate)
hd, err := conv.HoldingsDateFromOAPI(*request.Body.PropertyHoldingsDate)
if err != nil {
return nil, err
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/server/pactasrv/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ func (s *Server) StartPortfolioUpload(ctx context.Context, request api.StartPort
}
owner := &pacta.Owner{ID: actorInfo.OwnerID}
properties := pacta.PortfolioProperties{}
if request.Body.PropertyHoldingsDate != nil {
properties.HoldingsDate, err = conv.HoldingsDateFromOAPI(request.Body.PropertyHoldingsDate)
if err != nil {
return nil, err
}
properties.HoldingsDate, err = conv.HoldingsDateFromOAPI(request.Body.PropertyHoldingsDate)
if err != nil {
return nil, err
}
properties.ESG = conv.OptionalBoolFromOAPI(request.Body.PropertyESG)
properties.External = conv.OptionalBoolFromOAPI(request.Body.PropertyExternal)
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/analysis/ContextualListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ const reportButtonClasses = computed(() => {
:portfolio-id="props.portfolioId"
:portfolio-group-id="props.portfolioGroupId"
:initiative-id="props.initiativeId"
:warn-for-duplicate="hasAnyAudits"
class="p-button-sm"
@started="() => emit('refresh')"
/>
Expand All @@ -137,6 +138,7 @@ const reportButtonClasses = computed(() => {
:portfolio-id="props.portfolioId"
:portfolio-group-id="props.portfolioGroupId"
:initiative-id="props.initiativeId"
:warn-for-duplicate="hasAnyReports"
class="p-button-sm"
@started="() => emit('refresh')"
/>
Expand Down
28 changes: 26 additions & 2 deletions frontend/components/analysis/RunButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script setup lang="ts">
import { type RunAnalysisReq, type Analysis, type AnalysisType } from '@/openapi/generated/pacta'
import { useConfirm } from 'primevue/useconfirm'
const { linkToAnalysis } = useMyDataURLs()
const { require: confirm } = useConfirm()
const pactaClient = usePACTA()
const { loading: { withLoading } } = useModal()
const i18n = useI18n()
Expand All @@ -14,6 +16,7 @@ const tt = (key: string) => t(`${prefix}.${key}`)
interface Props {
analysisType: AnalysisType
name: string
warnForDuplicate?: boolean
portfolioGroupId?: string
portfolioId?: string
initiativeId?: string
Expand Down Expand Up @@ -54,15 +57,36 @@ const request = computed<RunAnalysisReq>(() => {
throw new Error('No portfolio, portfolio group or initiative ID provided')
}
})
const runAnalysis = () => {
const startRun = () => {
emit('started')
return withLoading(
clicked.value = true
void withLoading(
() => pactaClient.runAnalysis(request.value)
.then((resp) => { analysisId.value = resp.analysisId })
.then(() => { void refreshAnalysisState() }),
`${prefix}.runAnalysis`,
)
}
const runAnalysis = () => {
if (!props.warnForDuplicate) {
startRun()
return
}
confirm({
header: tt('ConfirmationHeader'),
message: tt('ConfirmationMessage'),
icon: 'pi pi-copy',
position: 'center',
blockScroll: true,
reject: () => { clicked.value = false },
rejectLabel: tt('Cancel Run'),
rejectIcon: 'pi pi-times',
acceptLabel: tt('Run Anyway'),
accept: startRun,
acceptIcon: 'pi pi-check',
})
}
const refreshAnalysisState = async () => {
const aid = analysisId.value
if (!aid) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/inputs/HoldingsDate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ interface Emits {
const emit = defineEmits<Emits>()
const model = computed<Date | undefined>({
get: () => props.value ? new Date(props.value.time) : undefined,
set: (value: Date | undefined) => { emit('update:value', value ? ({ time: value.toISOString() }) : undefined) },
get: () => props.value?.time ? new Date(props.value.time) : undefined,
set: (value: Date | undefined) => { emit('update:value', value ? ({ time: value.toISOString() }) : ({ time: undefined })) },
})
</script>

Expand Down
4 changes: 4 additions & 0 deletions frontend/components/modal/Group.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@
<!-- TODO(grady) Remove This in Production Environments -->
<ModalMissingTranslations />
<PVToast />
<PVConfirmDialog
class="w-30rem"
style="max-width: calc(100vw - 1rem);"
/>
</div>
</template>
6 changes: 5 additions & 1 deletion frontend/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,11 @@
"components/analysis/RunButton": {
"Run": "Run",
"AnalysisTypeAUDIT": "Audit",
"AnalysisTypeREPORT": "Report"
"AnalysisTypeREPORT": "Report",
"ConfirmationHeader": "Run Duplicate Analysis?",
"ConfirmationMessage": "It looks like there is already a run for this analysis - if you have changed the settings or underlying data for this analysis, a new run may be warranted, but otherwise this will just return the same analysis as above.",
"Run Anyway": "Run Anyway",
"Cancel Run": "Nevermind"
},
"components/portfolio/group/ListView": {
"Created At": "Created At",
Expand Down
2 changes: 1 addition & 1 deletion frontend/openapi/generated/pacta/models/HoldingsDate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ export type HoldingsDate = {
/**
* The time at which the holdings are represented at
*/
time: string;
time?: string;
};

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type IncompleteUpload = {
* Description of the upload
*/
description: string;
propertyHoldingsDate?: HoldingsDate;
propertyHoldingsDate: HoldingsDate;
/**
* If set, this portfolio represents ESG data
*/
Expand Down
2 changes: 1 addition & 1 deletion frontend/openapi/generated/pacta/models/Portfolio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export type Portfolio = {
* The list of initiatives that this portfolio is a member of
*/
initiatives?: Array<PortfolioInitiativeMembershipInitiative>;
propertyHoldingsDate?: HoldingsDate;
propertyHoldingsDate: HoldingsDate;
/**
* If set, this portfolio represents ESG data
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import type { StartPortfolioUploadReqItem } from './StartPortfolioUploadReqItem'

export type StartPortfolioUploadReq = {
items: Array<StartPortfolioUploadReqItem>;
propertyHoldingsDate?: HoldingsDate;
/**
* The holdings date of the portfolio, if set
*/
propertyHoldingsDate: HoldingsDate;
/**
* If set, this portfolio represents ESG data
*/
Expand Down
4 changes: 2 additions & 2 deletions frontend/pages/upload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ interface FileStateDetail extends FileState {
effectiveError?: string | undefined
}
const holdingsDate = useState<HoldingsDate | undefined>(`${prefix}.holdingsDate`, () => undefined)
const holdingsDate = useState<HoldingsDate>(`${prefix}.holdingsDate`, () => ({ time: undefined }))
const esg = useState<OptionalBoolean>(`${prefix}.esg`, () => OptionalBoolean.OPTIONAL_BOOLEAN_UNSET)
const external = useState<OptionalBoolean>(`${prefix}.external`, () => OptionalBoolean.OPTIONAL_BOOLEAN_UNSET)
const engagementStrategy = useState<OptionalBoolean>(`${prefix}.engagementStrategy`, () => OptionalBoolean.OPTIONAL_BOOLEAN_UNSET)
Expand All @@ -50,7 +50,7 @@ const isProcessing = useState<boolean>(`${prefix}.isProcessing`, () => false)
const fileStates = useState<FileState[]>(`${prefix}.fileState`, () => [])
const reset = () => {
holdingsDate.value = undefined
holdingsDate.value = { time: undefined }
esg.value = OptionalBoolean.OPTIONAL_BOOLEAN_UNSET
external.value = OptionalBoolean.OPTIONAL_BOOLEAN_UNSET
engagementStrategy.value = OptionalBoolean.OPTIONAL_BOOLEAN_UNSET
Expand Down
4 changes: 4 additions & 0 deletions frontend/plugins/primevue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import Calendar from 'primevue/calendar'
import Card from 'primevue/card'
import Chips from 'primevue/chips'
import Column from 'primevue/column'
import ConfirmDialog from 'primevue/confirmdialog'
import ConfirmationService from 'primevue/confirmationservice'
import DataTable from 'primevue/datatable'
import Dialog from 'primevue/dialog'
import Dropdown from 'primevue/dropdown'
Expand Down Expand Up @@ -42,6 +44,7 @@ export default defineNuxtPlugin(({ vueApp }) => {
vueApp.component('PVCard', Card)
vueApp.component('PVChips', Chips)
vueApp.component('PVColumn', Column)
vueApp.component('PVConfirmDialog', ConfirmDialog)
vueApp.component('PVDataTable', DataTable)
vueApp.component('PVDialog', Dialog)
vueApp.component('PVDropdown', Dropdown)
Expand All @@ -62,4 +65,5 @@ export default defineNuxtPlugin(({ vueApp }) => {
vueApp.component('PVTriStateCheckbox', TriStateCheckbox)

vueApp.directive('tooltip', Tooltip)
vueApp.use(ConfirmationService)
})
6 changes: 4 additions & 2 deletions openapi/pacta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,7 @@ components:
type: object
required:
- items
- propertyHoldingsDate
- propertyESG
- propertyExternal
- propertyEngagementStrategy
Expand All @@ -1517,6 +1518,7 @@ components:
items:
$ref: '#/components/schemas/StartPortfolioUploadReqItem'
propertyHoldingsDate:
description: The holdings date of the portfolio, if set
$ref: '#/components/schemas/HoldingsDate'
propertyESG:
description: If set, this portfolio represents ESG data
Expand Down Expand Up @@ -1626,8 +1628,6 @@ components:
description: The time at which the signed URL will expire.
HoldingsDate:
type: object
required:
- time
properties:
time:
type: string
Expand All @@ -1641,6 +1641,7 @@ components:
- description
- createdAt
- adminDebugEnabled
- propertyHoldingsDate
- propertyESG
- propertyExternal
- propertyEngagementStrategy
Expand Down Expand Up @@ -1708,6 +1709,7 @@ components:
- createdAt
- adminDebugEnabled
- numberOfRows
- propertyHoldingsDate
- propertyESG
- propertyExternal
- propertyEngagementStrategy
Expand Down

0 comments on commit 71df3b6

Please sign in to comment.