-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closes #16009 - Added styling to form templates to enable floating button groups #17523
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
Merged
jeremystretch
merged 10 commits into
netbox-community:develop
from
atownson:issue_16009
Oct 15, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8715f6f
#16009 Added btn-float-group style class and added to form templates …
7de5efd
Merge branch 'develop' into issue_16009
jeremystretch 30e6704
#16009 Removed floating div background and moved filter form buttons …
3b8a3dc
Added style classes to represent left and right justified floating bu…
1e03eb4
Added TypeScript to handle conditionally floating the object list forms
0cf8264
Fix TS import
1bfb6e6
Added null check for the button group
6d5af67
Update TS styling
3c36549
Satisfy prettier check
ba4b5fe
Merge branch 'develop' into issue_16009
jeremystretch 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,42 @@ | ||
import { getElements } from '../util'; | ||
|
||
/** | ||
* Conditionally add and remove a class that will float the button group | ||
* based on whether or not items in the list are checked | ||
*/ | ||
function toggleFloat(): void { | ||
const checkedCheckboxes = document.querySelector<HTMLInputElement>( | ||
'input[type="checkbox"][name="pk"]:checked', | ||
); | ||
const buttonGroup = document.querySelector<HTMLDivElement>( | ||
'div.form.form-horizontal div.btn-list', | ||
); | ||
if (!buttonGroup) { | ||
return; | ||
} | ||
const isFloating = buttonGroup.classList.contains('btn-float-group-left'); | ||
if (checkedCheckboxes !== null && !isFloating) { | ||
buttonGroup.classList.add('btn-float-group-left'); | ||
} else if (checkedCheckboxes === null && isFloating) { | ||
buttonGroup.classList.remove('btn-float-group-left'); | ||
} | ||
} | ||
|
||
/** | ||
* Initialize floating bulk buttons. | ||
*/ | ||
export function initFloatBulk(): void { | ||
for (const element of getElements<HTMLInputElement>('input[type="checkbox"][name="pk"]')) { | ||
element.addEventListener('change', () => { | ||
toggleFloat(); | ||
}); | ||
} | ||
// Handle the select-all checkbox | ||
for (const element of getElements<HTMLInputElement>( | ||
'table tr th > input[type="checkbox"].toggle', | ||
)) { | ||
element.addEventListener('change', () => { | ||
toggleFloat(); | ||
}); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.