-
Notifications
You must be signed in to change notification settings - Fork 0
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
Front-end for Initiative Portfolio Participation #91
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE portfolio_initiative_membership DROP PRIMARY KEY; | ||
|
||
COMMIT; |
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,5 @@ | ||
BEGIN; | ||
|
||
ALTER TABLE portfolio_initiative_membership ADD PRIMARY KEY (portfolio_id, initiative_id); | ||
|
||
COMMIT; |
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
Empty file.
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,154 @@ | ||
<script setup lang="ts"> | ||
import { incompleteUploadEditor } from '@/lib/editor' | ||
import { type IncompleteUpload } from '@/openapi/generated/pacta' | ||
import { selectedCountSuffix } from '@/lib/selection' | ||
|
||
const { | ||
humanReadableTimeFromStandardString, | ||
} = useTime() | ||
const pactaClient = usePACTA() | ||
const { loading: { withLoading } } = useModal() | ||
const i18n = useI18n() | ||
const { t } = i18n | ||
|
||
interface Props { | ||
incompleteUploads: IncompleteUpload[] | ||
} | ||
const props = defineProps<Props>() | ||
interface Emits { | ||
(e: 'refresh'): void | ||
} | ||
const emit = defineEmits<Emits>() | ||
|
||
interface EditorObject extends ReturnType<typeof incompleteUploadEditor> { | ||
id: string | ||
} | ||
|
||
const prefix = 'components/incompleteupload/ListView' | ||
const tt = (s: string) => t(`${prefix}.${s}`) | ||
|
||
const editorObjects = computed<EditorObject[]>(() => props.incompleteUploads.map((item) => ({ ...incompleteUploadEditor(item, i18n), id: item.id }))) | ||
|
||
const expandedRows = useState<EditorObject[]>(`${prefix}.expandedRows`, () => []) | ||
const selectedRows = useState<EditorObject[]>(`${prefix}.selectedRows`, () => []) | ||
|
||
const deleteIncompleteUpload = (id: string) => withLoading( | ||
() => pactaClient.deleteIncompleteUpload(id).then(() => { | ||
expandedRows.value = expandedRows.value.filter((row) => row.id !== id) | ||
}), | ||
`${prefix}.deletePortfolioGroup`, | ||
) | ||
const deleteSelected = async () => { | ||
await Promise.all( | ||
selectedRows.value.map((row) => deleteIncompleteUpload(row.id)), | ||
).then(() => { | ||
emit('refresh') | ||
selectedRows.value = [] | ||
}) | ||
} | ||
const saveChanges = (id: string) => { | ||
const index = editorObjects.value.findIndex((editorObject) => editorObject.id === id) | ||
const eo = presentOrFileBug(editorObjects.value[index]) | ||
return withLoading( | ||
() => pactaClient.updateIncompleteUpload(id, eo.changes.value).then(() => { emit('refresh') }), | ||
`${prefix}.saveChanges`, | ||
) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-column gap-3"> | ||
<p> | ||
TODO(#80) Write some copy about what Incomplete Uploads are, and direct users toward deleting them. | ||
</p> | ||
<div class="flex gap-2 flex-wrap"> | ||
<PVButton | ||
icon="pi pi-refresh" | ||
class="p-button-outlined p-button-secondary p-button-sm" | ||
:label="tt('Refresh')" | ||
@click="() => emit('refresh')" | ||
/> | ||
<PVButton | ||
:disabled="!selectedRows || selectedRows.length === 0" | ||
icon="pi pi-trash" | ||
class="p-button-outlined p-button-danger p-button-sm" | ||
:label="tt('Delete') + selectedCountSuffix(selectedRows)" | ||
@click="deleteSelected" | ||
/> | ||
</div> | ||
<PVDataTable | ||
v-model:selection="selectedRows" | ||
v-model:expanded-rows="expandedRows" | ||
:value="editorObjects" | ||
data-key="id" | ||
class="w-full" | ||
size="small" | ||
sort-field="editorValues.value.createdAt.originalValue" | ||
:sort-order="-1" | ||
> | ||
<PVColumn selection-mode="multiple" /> | ||
<PVColumn | ||
field="editorValues.value.name.originalValue" | ||
sortable | ||
:header="tt('Name')" | ||
/> | ||
<PVColumn | ||
field="editorValues.value.createdAt.originalValue" | ||
:header="tt('Created At')" | ||
sortable | ||
> | ||
<template #body="slotProps"> | ||
{{ humanReadableTimeFromStandardString(slotProps.data.editorValues.value.createdAt.originalValue).value }} | ||
</template> | ||
</PVColumn> | ||
<PVColumn | ||
expander | ||
header="Details" | ||
/> | ||
<template | ||
#expansion="slotProps" | ||
> | ||
<div class="surface-100 p-3"> | ||
<h2 class="mt-0"> | ||
Metadata | ||
</h2> | ||
<div class="flex flex-column gap-2 w-fit"> | ||
<div class="flex gap-2 justify-content-between"> | ||
<span>Created At</span> | ||
<b>{{ humanReadableTimeFromStandardString(slotProps.data.editorValues.value.createdAt.originalValue).value }}</b> | ||
</div> | ||
</div> | ||
<!-- TODO(grady) add failure information here. --> | ||
<StandardDebug | ||
:value="slotProps.data.editorValues.value" | ||
label="Editor Values" | ||
/> | ||
<h2 class="mt-5"> | ||
Editable Properties | ||
</h2> | ||
<IncompleteuploadEditor | ||
v-model:editor-values="slotProps.data.editorValues.value" | ||
:editor-fields="slotProps.data.editorFields.value" | ||
/> | ||
<div class="flex gap-3 justify-content-between"> | ||
<PVButton | ||
icon="pi pi-trash" | ||
class="p-button-danger p-button-outlined" | ||
:label="tt('Delete')" | ||
@click="async () => { await deleteIncompleteUpload(slotProps.data.id); emit('refresh') }" | ||
/> | ||
<div v-tooltip.bottom="slotProps.data.saveTooltip"> | ||
<PVButton | ||
:disabled="!slotProps.data.canSave.value" | ||
:label="tt('Save Changes')" | ||
icon="pi pi-save" | ||
icon-pos="right" | ||
@click="() => saveChanges(slotProps.data.id)" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
</PVDataTable> | ||
</div> | ||
</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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand these changes, specifically why these
LEFT JOIN
s are now structured as subqueries, since they just join on the portfolio ID anyway. I know you mentioned a "cardinality bug", but I don't follow how this fixes that, when the subqueries are grouping by the same thing we were initially grouping by anyway (portfolio ID).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question. This wasn't clear to me and took a while to debug. Here's my best explanation for posterity:
After playing around with some row-based solutions, I found this was the simplest way (and probably the most extensible/easy to change: do your group-bys where it's not over a join result, and then just select). This also has the advantage of not generating huge cross products when the cardinality of the subtables is large (as it might be in this case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh yeah, sure enough:
produces
When asking the internet about this, I got the suggestion:
Which involves subqueries but otherwise seems like the simplest approach, and I think applies here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally fair, that approach also would work. I think the downside of it is when we have multiple columns from
a
orb
(and because memberships will often have anid
and acreated at
, I think this is most cases), a nested query in the select statement then needs to be either (a) assumed order equivalent across multiple expressions, which might be the case or might not, or (b) needs to be multi-selected and the unnested (i.e. put into a composite object, then decomposed).