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

Recordedit with association picker when adding rows using prefill #2490

Merged
merged 55 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
dcd0fae
changes to show and association picker before record edit form input
jrchudy Jun 8, 2024
6a8d6c2
breadcrumb added
jrchudy Jun 11, 2024
600be7d
wait for foreign key data to process before adding more forms and fil…
jrchudy Jun 13, 2024
0690d9c
add more popup modal
jrchudy Jun 14, 2024
547d5d2
show association modal before loading the app page
jrchudy Jun 21, 2024
6619dab
initialize form provider while showing the modal instead of waiting
jrchudy Jun 28, 2024
a541836
add fk column names for the to mapping of the relation
jrchudy Jul 1, 2024
04f1e98
add/remove selected rows when forms removed, input value is updated/r…
jrchudy Jul 12, 2024
9518804
pending hide button for multi set
jrchudy Jul 12, 2024
f219e0e
disable set some button, don't clone unique fk data
jrchudy Jul 15, 2024
8ebf91d
clean up changes, add comments for new functions
jrchudy Jul 16, 2024
6825a66
some more function changes and comments
jrchudy Jul 16, 2024
d6337ce
checkout ermerstJS branch for tests
jrchudy Jul 16, 2024
2cf244d
move prefill object to the provider instead of creating it each time …
jrchudy Jul 16, 2024
a6ae717
bug in refactoring
jrchudy Jul 16, 2024
e403567
fix check that broke domain filter support after refactoring
jrchudy Jul 16, 2024
84c54be
foreign key dropdown support to update the association selected rows …
jrchudy Jul 18, 2024
f023f88
Merge branch 'master' into recordedit-w-association-picker
jrchudy Jul 18, 2024
047c703
comments and update some conditional checks to be more robust
jrchudy Jul 19, 2024
6b17af6
fix test case that has the modal showing for a non-unique pair of fke…
jrchudy Jul 19, 2024
b4efc30
disabled rows in modal have tooltips and button is removed for all di…
jrchudy Jul 26, 2024
8be3047
changes to add tooltips to modal and dropdown rows that are disabled.…
jrchudy Aug 2, 2024
cdd1e0e
resolve merge conflicts
jrchudy Aug 2, 2024
967edeb
check if leaf column is defined before checking/setting the reference
jrchudy Aug 13, 2024
ed1bf14
Merge branch 'master' into recordedit-w-association-picker
jrchudy Aug 13, 2024
8ae338b
condense checks
jrchudy Aug 13, 2024
9cccd0f
comment and remove uneeded variable import
jrchudy Aug 14, 2024
385e1f3
Merge branch 'master' into recordedit-w-association-picker
jrchudy Aug 15, 2024
7439e9a
update chaise changes with APIs added to ermrestJS
jrchudy Aug 26, 2024
53f33cf
PR comments addressed. refactored disabled rows to create an object u…
jrchudy Aug 26, 2024
9281f1c
remove state variable for row that is selected
jrchudy Aug 26, 2024
7483983
Merge branch 'master' into recordedit-w-association-picker
jrchudy Sep 3, 2024
09faf07
update with changes made to ermrestJS
jrchudy Sep 3, 2024
563a5d9
always initialize prefill in RE
jrchudy Sep 4, 2024
cba40c0
fix a few more bugs initializing how recordedit is used
jrchudy Sep 5, 2024
43675ec
adjust styles
jrchudy Sep 6, 2024
ae05526
use bulkcreatefkobject api
jrchudy Sep 10, 2024
62f1078
Merge branch 'master' into recordedit-w-association-picker
jrchudy Sep 16, 2024
f2922dc
add test cases for modal and dropdown inputs
jrchudy Sep 18, 2024
11699e4
fix bug in code that was causing a test case to fail for another unre…
jrchudy Sep 19, 2024
dc5f28f
change check to use constant instead of test value
jrchudy Sep 19, 2024
1bacdc5
rename variables and functions
jrchudy Sep 19, 2024
1a531e3
rename variable and use new alert type in other place
jrchudy Sep 20, 2024
f7a45ee
address comments from the PR
jrchudy Sep 26, 2024
38e13ee
type in foreign key dropdown field. Make sure selected row value is c…
jrchudy Sep 26, 2024
98cfec9
another variable name change since it's the props for recordset only,…
jrchudy Sep 26, 2024
8143cb2
add test case for the edge case of closing the initial modal that sho…
jrchudy Sep 26, 2024
3186b3d
rename variable to be more informative
jrchudy Sep 26, 2024
dfb5d49
use API from ermrestJS to generate ID for a row with linked data
jrchudy Sep 30, 2024
0958f6a
merge conflicts and added modal title test
jrchudy Oct 1, 2024
236f445
move styles, remove console.log, change function name
jrchudy Oct 1, 2024
dac9c00
remove style
jrchudy Oct 1, 2024
510eeb9
remove log and change name of logged stack path
jrchudy Oct 1, 2024
3d5fa56
update logging.md
jrchudy Oct 1, 2024
1d0bc88
remove branch checkout
jrchudy Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/components/input-switch/foreignkey-dropdown-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,14 @@ const ForeignkeyDropdownField = (props: ForeignkeyDropdownFieldProps): JSX.Eleme
* @param selectedRow tuple object from ERMrestJS that represents the dropdown row
* @param onChange
*/
const onRowSelected = (selectedRow: any, onChange: any) => {
const onRowSelected = (selectedRow: SelectedRow, onChange: any) => {
setCheckedRow(selectedRow);

const rowToAdd: SelectedRow = {
displayname: selectedRow.displayname,
uniqueId: selectedRow.uniqueId,
data: selectedRow.data
}

const column = props.columnModel.column;

// if the recordedit page's table is an association table with a unique key pair, track the selected rows
if (props.foreignKeyCallbacks?.updateBulkForeignKeySelectedRows) {
props.foreignKeyCallbacks.updateBulkForeignKeySelectedRows(usedFormNumber, rowToAdd);
props.foreignKeyCallbacks.updateBulkForeignKeySelectedRows(usedFormNumber, selectedRow);
}

callOnChangeAfterSelection(
Expand Down
16 changes: 9 additions & 7 deletions src/components/input-switch/foreignkey-field.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ const ForeignkeyField = (props: ForeignkeyFieldProps): JSX.Element => {
);

let currentSelectedRow;
RFSH marked this conversation as resolved.
Show resolved Hide resolved
// there is a value in the input but no selected row yet because of prefill showing an association picker on recordedit page load
if (getValues(props.name) && props.foreignKeyCallbacks?.bulkForeignKeySelectedRows) {
// find row in bulkForeignKeySelectedRows
currentSelectedRow = props.foreignKeyCallbacks.bulkForeignKeySelectedRows.filter((row: SelectedRow) => {
// if an input is empty, there won't be a row defined in `bulkForeignKeySelectedRows`
return row && row.displayname.value === getValues(props.name);
})[0];
const inputFKData = props.foreignKeyData?.current[`c_${usedFormNumber}-${props.columnModel.column.RID}`];
if (inputFKData) {
currentSelectedRow = {
displayname: {
value: getValues(props.name),
isHTML: false
},
uniqueId: props.columnModel.column.generateUniqueId(inputFKData)
}
}

setRecordsetModalProps({
Expand Down
6 changes: 3 additions & 3 deletions src/components/modals/recordset-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export type RecordestModalProps = {
* and instead is just going to call this function. This is done this way
* so we can apply the logic to disable the submit button
*/
onSelectedRowsChanged?: (SelectedRow: SelectedRow[]) => boolean,
onSelectedRowsChanged?: (SelectedRow: SelectedRow[]) => boolean | string,
/**
* The function that will be called on submit
* Note: the modal won't close on submit and if that's the expected behavior,
Expand Down Expand Up @@ -249,7 +249,7 @@ const RecordsetModal = ({
</>
)
break;
case RecordsetDisplayMode.FK_BULK:
case RecordsetDisplayMode.FK_POPUP_BULK_CREATE:
submitText = 'Continue';
submitTooltip = (
<>
Expand Down Expand Up @@ -314,7 +314,7 @@ const RecordsetModal = ({
<Title displayname={recordsetProps.parentTuple?.displayname} />
</div>
);
case RecordsetDisplayMode.FK_BULK:
case RecordsetDisplayMode.FK_POPUP_BULK_CREATE:
return (
<div>
<span>Select a set of </span>
Expand Down
3 changes: 3 additions & 0 deletions src/components/recordedit/form-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ const FormContainer = ({
const handleRemoveForm = (formIndex: number, formNumber: number) => {
setRemoveFormIndex(formNumber);
setRemoveClicked(true);

console.log('index: ', formIndex);
jrchudy marked this conversation as resolved.
Show resolved Hide resolved
console.log('number: ', formNumber);
removeForm([formIndex]);
};

Expand Down
4 changes: 2 additions & 2 deletions src/components/recordedit/form-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ const FormRow = ({
* - the column is a foreignkey
* - and the column is the one used for associating to the leaf table of the association
*/
if (bulkFKObject?.isUnique && column.isForeignKey && bulkFKObject.leafColumn.name === colName) {
if (columnModel.isLeafInUniqueBulkForeignKeyCreate) {
tempForeignKeyCallbacks.getDisabledTuples = disabledTuplesPromise(
column.reference.contextualize.compactSelectForeignKey,
column.reference.contextualize.compactSelectBulkForeignKey,
bulkFKObject.disabledRowsFilter(),
bulkForeignKeySelectedRows
);
Expand Down
7 changes: 4 additions & 3 deletions src/components/recordedit/key-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const KeyColumn = ({

const {
appMode, columnModels, columnPermissionErrors,
config, forms, logRecordeditClientAction, reference
config, forms, logRecordeditClientAction
} = useRecordedit();

const onToggleClick = (cmIndex: number) => {
Expand Down Expand Up @@ -75,8 +75,9 @@ const KeyColumn = ({
const canShowMultiFormBtn = (columnIndex: number) => {
const cm = columnModels[columnIndex];

const bulkFKObject = reference.bulkCreateForeignKeyObject
if (bulkFKObject?.isUnique && cm.column.name === bulkFKObject.leafColumn.name) {
// hide the button if the foreign key values for this column are part of a unique key
// and the other part of that key is the prefiiled column that triggered the bulkForeignKey UI
if (cm.isLeafInUniqueBulkForeignKeyCreate) {
return false
}

Expand Down
Loading
Loading