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

Improve UX with bulk edit in record app #2359

Merged
merged 4 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
17 changes: 12 additions & 5 deletions src/components/record/related-table-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -715,8 +715,12 @@ const RelatedTableActions = ({
{relatedModel.isPureBinary && relatedModel.canDelete && renderButton('Unlink records', false)}

{allowCustomModeRelated(relatedModel) && renderCustomModeBtn()}

{relatedModel.canEdit && renderButton('Bulk Edit', false)}
{/*
* if user can edit, also check for create permission
* - if they can't create, allow edit if there are some rows set
* - disable button if can create but no rows
*/}
{relatedModel.canEdit && (relatedModel.canCreate || relatedModel.recordsetState.page?.length > 0) && renderButton('Bulk Edit', false)}

{renderButton('Explore', false)}
</div>
Expand Down Expand Up @@ -754,6 +758,7 @@ const RelatedTableActions = ({
</ChaiseTooltip>
);
case 'Bulk Edit':
const disableBulkEdit = relatedModel.recordsetState.page?.length < 1;
return (
<ChaiseTooltip
placement='top'
Expand All @@ -764,11 +769,13 @@ const RelatedTableActions = ({
}
>
<a
className={`chaise-btn bulk-edit-link ${
tertiary ? 'chaise-btn-tertiary dropdown-button' : 'chaise-btn-secondary'
}`}
className={`chaise-btn bulk-edit-link
jrchudy marked this conversation as resolved.
Show resolved Hide resolved
${tertiary ? ' chaise-btn-tertiary dropdown-button' : ' chaise-btn-secondary'}
${disableBulkEdit ? ' disabled': ''}`
}
href={editLink}
onClick={onBulkEdit}
aria-disabled={disableBulkEdit}
>
<span className='chaise-btn-icon fa fa-pencil'></span>
<span>Bulk Edit</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ describe('View existing record,', function() {
expect(chaisePage.recordPage.getRelatedTables().count()).not.toBe(testParams.no_related_data.tables_order.length, "The full set of related tables were not properly hidden");
})
});

it('should have "booking" related table with bulk edit disabled when no rows', () => {
const btn = chaisePage.recordPage.getBulkEditLink('booking', true);

expect(btn.isPresent()).toBeTruthy();
expect(btn.getAttribute('class')).toContain('disabled', 'Bulk edit is not disabled');
});

it('should have "accommodation_collections" related table with bulk edit removed when the user cannot create and there are no rows are present', () => {
const btn = chaisePage.recordPage.getBulkEditLink('accommodation_collections', true);
expect(btn.isPresent()).not.toBeTruthy();
});
});

describe("For side panel table of contents in Record App", function() {
Expand Down
Loading