-
Notifications
You must be signed in to change notification settings - Fork 45
Replace Quickselect in Maintenance form with HTMX #3425
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
Merged
Changes from 1 commit
Commits
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 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 @@ | ||
| Use HTMX for selecting and modifying components for Maintenance tasks. Replaces Quickselect implementation. |
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
42 changes: 42 additions & 0 deletions
42
python/nav/web/templates/maintenance/_component-search-results.html
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 @@ | ||
| {% if results %} | ||
| {% for component_type, result in results.items %} | ||
| <div class="component-group"> | ||
| <label for="id_{{ component_type }}" style="font-weight: bold;">{{ result.label }}</label> | ||
| <select multiple id="id_{{ component_type }}" name="{{ component_type }}"> | ||
| {% if result.has_grouping %} | ||
| {% for optgroup, options in result.values %} | ||
| <optgroup label="{{ optgroup }}"> | ||
| {% for option in options %} | ||
| <option value="{{ option.id }}">{{ option }}</option> | ||
| {% endfor %} | ||
| </optgroup> | ||
| {% endfor %} | ||
| {% else %} | ||
| {% for option in result.values %} | ||
| <option value="{{ option.id }}">{{ option }}</option> | ||
| {% endfor %} | ||
| {% endif %} | ||
| </select> | ||
| <div class="row"> | ||
| <button | ||
| type="button" | ||
| class="button secondary small" | ||
| hx-post="{% url 'maintenance-component-select' %}" | ||
| hx-target="#selected-components" | ||
| hx-include="#id_{{ component_type }}, #selected-components input" | ||
| hx-on::after-request="document.getElementById('id_{{ component_type }}').selectedIndex = -1;" | ||
| > | ||
| Add {{ result.label }} | ||
| </button> | ||
| <button | ||
| type="button" class="button secondary small" | ||
| onclick="Array.from(document.getElementById('id_{{ component_type }}').options).forEach(opt => opt.selected = true);" | ||
| > | ||
| Select all | ||
| </button> | ||
| </div> | ||
| </div> | ||
| {% endfor %} | ||
| {% else %} | ||
| <strong>No hits</strong> | ||
| {% endif %} |
52 changes: 52 additions & 0 deletions
52
python/nav/web/templates/maintenance/_selected-components-list.html
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,52 @@ | ||
| {% load maintenance %} | ||
| {% for key, identifiers in selected.items %} | ||
| {% for id in identifiers %} | ||
| <input type="hidden" name="{{ key }}" value="{{ id }}"/> | ||
| {% endfor %} | ||
| {% endfor %} | ||
| {% if components %} | ||
| <div class="row"> | ||
| <button | ||
| type="button" | ||
| class="button tiny secondary" | ||
| onclick="document.querySelectorAll('#component-list input[type=checkbox]').forEach(cb => cb.checked = true);" | ||
| > | ||
| Select all | ||
| </button> | ||
| <button | ||
| type="button" | ||
| class="button tiny secondary" | ||
| onclick="document.querySelectorAll('#component-list input[type=checkbox]').forEach(cb => cb.checked = false);" | ||
| > | ||
| Unselect all | ||
| </button> | ||
| </div> | ||
| <ul id="component-list" class="no-bullet"> | ||
| {% for trail in components %} | ||
| {% with trail|last as component %} | ||
| <li> | ||
| <div> | ||
| <input type="hidden" name="{{ component|component_db_table }}" value="{{ component.pk }}"/> | ||
| <input type="checkbox" name="remove_{{ component|component_db_table }}" value="{{ component.pk }}"/> | ||
| {{ component|model_verbose_name }}: | ||
| </div> | ||
| <div> | ||
| {% include "maintenance/frag-component-trail.html" %} | ||
| </div> | ||
| </li> | ||
| {% endwith %} | ||
| {% endfor %} | ||
| </ul> | ||
| <button | ||
| name="remove" | ||
| hx-post="{% url 'maintenance-component-select' %}" | ||
| hx-target="#selected-components" | ||
| hx-include="#selected-components input" | ||
| class="button small secondary" | ||
| > | ||
| Remove selected | ||
| </button> | ||
| {% else %} | ||
| <p>(none)</p> | ||
| <button disabled="disabled" class="button small secondary">Remove selected</button> | ||
| {% endif %} |
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.