Flask-AppBuilder icon indicating copy to clipboard operation
Flask-AppBuilder copied to clipboard

Relation columns are shown which should be hidden

Open ThomasP0815 opened this issue 2 years ago • 11 comments

Environment

Flask-Appbuilder version: 4.1.3

Describe the expected results

I extended the example "quickhowto" by excluding the field "contact_group" from search.

class ContactModelView(ModelView): datamodel = SQLAInterface(Contact) ... search_exclude_columns = ["contact_group"]

I expected this result:

image

Describe the actual results

I extended the example "quickhowto" by excluding the field "contact_group" from search.

class ContactModelView(ModelView): datamodel = SQLAInterface(Contact) ... search_exclude_columns = ["contact_group"]

I got this:

image

Analysis:

I think the pull request #1862 causes this problem. image

I think issue #1867 is also related to this problem.

ThomasP0815 avatar Jul 18 '22 13:07 ThomasP0815

@ThomasP0815,

search_exclude_columns does not relate with the edit form. Why were you expecting for the field to be excluded?

dpgaspar avatar Jul 22 '22 09:07 dpgaspar

@dpgaspar

get_filter_args changes self._filters thats why exclude_cols does not include the relation anymore!

image

ThomasP0815 avatar Jul 22 '22 12:07 ThomasP0815

Sorry, I may be miss understanding, this what you've reported. So you've excluded contact_group from the search and it's rendered on the edit form, this is expected

Screenshot 2022-07-22 at 16 16 44

dpgaspar avatar Jul 22 '22 15:07 dpgaspar

I'll double check

dpgaspar avatar Jul 22 '22 15:07 dpgaspar

Navigation path:

  • menu "Contacts" -> "List Groups"
  • show "Friends"
  • tab "List Contact"
  • edit "Abbey Szkarlat Faraday Etti"
  • "contact group" field should be hidden

ThomasP0815 avatar Jul 23 '22 06:07 ThomasP0815

why should it be hidden? we are excluding it from search not from the edit form

dpgaspar avatar Jul 25 '22 12:07 dpgaspar

I know, but excluding this field from search triggers this issue!

counter question, why was this field hidden in the past (using version 3.4.5)?

ThomasP0815 avatar Jul 25 '22 13:07 ThomasP0815

Tested on 3.4.5 an got the same behaviour.

For example using the examples quickhowto, create a new ModelView:

class ContactModelView2(ModelView):
    datamodel = SQLAInterface(Contact)

    list_columns = ["name", "personal_celphone", "birthday", "contact_group.name"]

    base_order = ("name", "asc")
    edit_columns = ["name", "personal_celphone", "birthday", "contact_group"]
    search_exclude_columns = ["contact_group"]

...
appbuilder.add_view(
    ContactModelView2, "List Contacts2", icon="fa-envelope", category="Contacts"
)

On the UI, the search is excluded: Screenshot 2022-07-27 at 10 46 45

The edit form still shows contact_group: Screenshot 2022-07-27 at 10 48 01

dpgaspar avatar Jul 27 '22 09:07 dpgaspar

Yes this result is alwright, but you didn't follow the navigation path!

  • menu "Contacts" -> "List Groups"
  • show "Friends"
  • tab "List Contact"
  • edit "Abbey Szkarlat Faraday Etti"
  • "contact group" field should be hidden image

ThomasP0815 avatar Jul 27 '22 11:07 ThomasP0815

oh! I see what you mean, it's on the related model views. sorry

It's a bug, needs to be fixed

dpgaspar avatar Jul 27 '22 14:07 dpgaspar

@ThomasP0815 got a fix up: https://github.com/dpgaspar/Flask-AppBuilder/pull/1898

dpgaspar avatar Jul 29 '22 13:07 dpgaspar

Thank you for the bug report, this is currently fixed on master. Will make a new release soon

dpgaspar avatar Aug 16 '22 10:08 dpgaspar