[v6] feat: New filelist field - #8337
Conversation
|
I've already added lab examples but you can also test via standablone following blueprint: title: Filelist field
tabs:
basics:
label: Basics
icon: box
fields:
plain:
label: 1 – Plain
type: filelist
withHelp:
label: 2 – Help text
type: filelist
help: Every file of this page, nothing else configured
noImages:
label: 3 – image false
type: filelist
image: false
customText:
label: 4 – Custom text and info
type: filelist
text: "{{ file.alt }}"
info: "{{ file.template.or('no template') }}"
emptyState:
label: 5 – Empty state
type: filelist
template: does-not-exist
empty: Nothing here, this is the custom empty text
layouts:
label: Layouts
icon: dashboard
fields:
list:
label: 6 – layout list
type: filelist
layout: list
cardlets:
label: 7 – layout cardlets
type: filelist
layout: cardlets
cards:
label: 8 – layout cards
type: filelist
layout: cards
cardsSmall:
label: 9 – layout cards, size small
type: filelist
layout: cards
size: small
table:
label: 10 – layout table
type: filelist
layout: table
tableColumns:
label: 11 – layout table with columns
type: filelist
layout: table
columns:
alt:
label: Alt text
template:
label: Template
value: "{{ file.template.or('–') }}"
data:
label: Data
icon: filter
fields:
parent:
label: 12 – parent query
type: filelist
parent: site.find("photography").children.first
help: Files of the first album, with a link to it
query:
label: 13 – query
type: filelist
query: page.images.filterBy("template", "image")
template:
label: 14 – template image
type: filelist
template: image
help: 5 of 7 files
pagination:
label: 15 – limit 3
type: filelist
limit: 3
sortBy:
label: 16 – sortBy filename desc
type: filelist
sortBy: filename desc
help: Manual sorting must be off
flip:
label: 17 – flip
type: filelist
flip: true
help: Manual sorting must be off
options:
label: Options
icon: cog
fields:
min:
label: 18 – min 10
type: filelist
min: 10
help: Invalid, must block publishing
max:
label: 19 – max 3
type: filelist
max: 3
help: Invalid, upload disabled
maxExact:
label: 20 – max 7
type: filelist
max: 7
help: Valid but full, upload disabled
noCreate:
label: 21 – create false
type: filelist
create: false
search:
label: 22 – search
type: filelist
search: true
batch:
label: 23 – batch
type: filelist
batch: true
uploadTemplate:
label: 24 – upload template image
type: filelist
template: image
help: Uploads should use the image template |
distantnative
left a comment
There was a problem hiding this comment.
Great start! Some first thoughts and questions.
|
This is already looking great!! I love the general direction |
825a1f5 to
46b1ce5
Compare
46b1ce5 to
148aad1
Compare
|
I've created a new sandbox branch with an example setup for the file list field that's indentical to the files section https://github.com/getkirby/sandbox/tree/feat/filelist-field It all works perfectly, except validation. (invalid tab) The invalid state is not showing up correctly and the form can be submitted. But other than that I feel like this is pretty much complete. I was wondering if we should maybe start a new v6/feat/section-migration branch and merge all those migration tasks into that first. Then we could catch last minute inconsistencies between migrated classes there before we merge everything into v6/develop. What do you think @afbora & @distantnative? Side note: @distantnative I feel like we broke something in the file dropdowns (not related to this PR) They are super slow for me in the sandbox at the moment. Not just for the filelist field but also in files sections. |
|
Makes sense to me with the extra branch to collect all of these changes first. And with the drop-down you mean the options dropdown? |
|
@distantnative yes, the options dropdown |
|
@bastianallgeier Thanks for testing it! Validation: the publishing part actually works — with Small heads-up: your blueprint uses About the extra branch: sounds good to me, that makes it much easier to spot differences between the migrated classes. |
|
@afbora I think the blueprint option should stay And it would be great to have the red invalid state as well. If we now all migrate to fields, we even have more need that all fields behave the same. |
|
@distantnative Both done.
For the invalid state: fields only got it through a native input inside them, which a list does not have. I gave |
|
I am wondering if we should use |
|
I like the idea to reuse our validators. @afbora could you try how much work this is? If it's too complicated or too "dirty" I would skip it for now. Otherwise we could add it to the PR. |
|
@bastianallgeier @distantnative I tried it and pushed it. Just a try, I can revert it. Split it like @distantnative said: Good part: it removed more than it added. The One thing I found on the way: |
8c6fe96 to
e9d9d25
Compare
e9d9d25 to
f810f5c
Compare
Description
This is part of merging sections into fields (#7859). @distantnative suggested to start by rebuilding one section as a real field class, so this PR does the
filessection.The name
filelistis only a working name for now —filesis already taken by the file picker, and we still have to decide how to solve that.What is in here:
ModelListField, an abstract base class with everything a list of models needs.pagelistbuilds on it in the follow-up PR.FileListFieldon top of it, registered astype: filelist.I tried to keep the behaviour exactly like the current files section, no redesign. Same props, same defaults, same error messages. The blueprint option is still called
search, only the internal name issearchable, as @distantnative suggested.There is also one small fix in
BaseField:isSubmittable()was missing, so a field without a value crashed on save. It is a separate commit, since it also affectsSectionFieldandInfoField.@bastianallgeier reported that an invalid list was not marked as such.
k-fieldcan now pass an invalid state down to its label, so this works for every field, not just this one.Changelog
🎉 Features
filelistfield which lists the files of a page, like the files section does✨ Enhancements
🐛 Bug fixes
Docs
The field works like the files section, but as a field:
Options:
batch,columns,create,empty,flip,image,info,layout,limit,max,min,page,parent,query,search,size,sortable,sortBy,template,text— pluswhenandwidth, which sections cannot do.For review team