-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
Batch editing #6842
base: v5/develop
Are you sure you want to change the base?
Batch editing #6842
Conversation
this.$panel.dialog.open({ | ||
component: "k-remove-dialog", | ||
props: { | ||
text: `Do you really want to delete ${this.selected.length} items at once? This action cannot be undone.` |
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.
Todo:
Turn into i18n string.
@@ -231,6 +309,24 @@ export default { | |||
this.searching = !this.searching; | |||
this.searchterm = null; | |||
}, | |||
onSelect(event, item) { | |||
if (event.target.checked) { |
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.
Todo:
Making this depend on the event (and more specifically a checkbox event) that many layers up from the actual input seems not ideal to me. Can this just accept the item as parameter and decide what to do based on whether the item is already in the selected array or not?
key: 'file.delete.multiple', | ||
); | ||
} | ||
} |
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.
Discussion:
I of course understand why it is implemented like this currently, but for a core method in this class, it seems a bit unusual to swallow the actual exceptions and just throw this vague one. Not sure there is a better way.
I just wondering if it wouldn't be better if |
Getting Ideal solution: shouldn't be able to select non-deletable models. |
When batch is active, the status icon is still clickable. If you click the status icon, both the status dialog opens and batch selection works. A user may accidentally delete the model while trying to change the status while batch mode is active. Ideal solutions:
|
@afbora that's wrong. Reloading should not be necessary. Already blocking the checkbox would be ideal indeed, but also a lot harder to implement. That's why I went for a simpler first solution that just skips the ones that cannot be deleted during the request. |
@bastianallgeier I've tested again and page is not reloading after the error. |
5b791a2
to
7ebcdfb
Compare
I've added table selection and it's working great CleanShot.2024-12-10.at.12.19.59.mp4 |
@bastianallgeier Is it testable for bug-fixes? |
@afbora no, I still need to look into the exception issue. |
@afbora I've fixed it now and it's working fine for me. |
Co-authored-by: Nico Hoffmann ෴. <[email protected]>
@bastianallgeier Deletion doesn't work with paginated sections. pages:
type: pages
batch: true
limit: 2 |
Sorry for a slightly Off Topic remark: But I see you're touching the "ID" column of table views and conditionally using them as a checkbox for multi-select. I know of multiple projects that are hiding the ID column (because it's the only way to get rid of this column as it's not configurable). Is there any way to hide the column and still be able to use this new multi-select possibility? |
@afbora can you give more context. What happens in that case? |
@pReya if the id column is disabled, it should still be visible when the select mode is on. |
AFAIK the ID column can't be disabled. It needs to be hidden via CSS (see linked forum post). So what I'm trying to say is: While you're working on this – is there any chance, you can allow disabling/hiding it while still allowing multi-select? See also https://kirby.nolt.io/460 |
@bastianallgeier Nothing happened. Just getting |
@nilshoerrmann if you have some good tips how to implement drag handles outside of a |
@distantnative I would put the handle inside the first cell (which ever that is in the current table) and move it outside using |
Oh, the |
By the way, I've read in the linked issue about the issues with hover interactions: as long as you don't remove the handle from the content flow with |
@distantnative If you apply the following CSS to https://lab.getkirby.com/public/lab/components/items/4_table the drag handle will be outside of the table with sorting functionality intact, showing on hover: .k-table .k-table-index-column {
/* ↑ this would need a dedicated first column with a different name, e. g. .k-table-sorting-column */
overflow: auto;
position: relative;
width: 0;
padding: 0;
}
.k-table .k-table-index-column .k-sort-handle {
/* display: none; ← remove this */
position: absolute;
translate: -2rem;
left: 0;
top: 0;
opacity: 0;
width: 2rem;
}
.k-table thead th:first-child {
position: initial;
}
.k-table .k-table-index {
display: none; /* ← this removes the index number which would have to move to the second column instead */
}
.k-table .k-table-sortable-row:hover .k-sort-handle {
opacity: 1;
} In this case the first index column will be visually hidden. So it's a proof of concept that this works with a "ghost" column. Tested in Firefox and Safari. There is a display error with images inside the table when sorting (outline cut off by image) but that's unrelated to the above styles. |
Another issue I see with placing the select in the ID cell (and thus hiding the number) is – numbers are very useful to see during batch edit if they are something editors actually work with. The number is the clearest and easiest indicator for specific rows, so I do see the use case of eg. jotting down or agreeing on numbers of the items to delete (or otherwise edit, once that's possible). Pretty much the exact opposite use case of what @pReya wrote, but the same issue (showing select in the space reserved for numbers). |
Changelog
Features
Enhancements
Kirby\Cms\Pages::delete(array $ids)
andKirby\Cms\Files::delete(array $ids)
methods to handle batch delete for multiple files in a collection.selectable
property for the<k-item>
and<k-items>
components. When set to true, the items show checkboxes and emit an select event, when the checkbox is clicked.files
andpages
sections introduce newdelete
API endpoints. Those endpoints can take a set of page or file ids and will delete each one. Errors will be caught and sent back in the details array of the final thrown exception.Breaking changes
Docs
batch
option for pages and files sectionsReady?
For review team