Skip to content
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

Don't generate entries for Abstract Models in more areas (Fixes #194) #197

Merged

Conversation

GeoMaciolek
Copy link
Contributor

(Hope the multiple edits here isn't too messy - if need be, we can roll it up into one.)

Regarding Issue #194 - the fixes pushed a few days ago in 0e1ef96 didn't handle all of the issues, so I've replicated the ``filter(model => !model.abstract)` in a few other generators:

  • api_py()
  • urls_py()
  • index_htm()
  • htmx_htm()
  • serializers()

All of those seem correct to me. The one I'm less certain about is a change around line 216 in rendering.js - I'm not sure how const apps is used. This might break stuff, or it might not. My testing didn't indicate any issues, but I don't have the whole test harness working - I mostly did it by hand, so, not all code paths for sure. Help & testing would be appreciated!

    const apps = keys(this.store.getters.projectData(projectid).apps).filter(
      app_id => this.store.getters.appData(app_id) !== undefined
    ).map(app_id =>{
      const app = this.store.getters.appData(app_id)

      if (app == undefined) return

      // In the line below - I added the filter
      const models = this.get_models(app_id).filter(model => !model.abstract)

@mmcardle
Copy link
Owner

@GeoMaciolek Thanks for the PR, I will try to get to look at it soon.

@GeoMaciolek GeoMaciolek changed the title More Abstract Model fixes Don't generate entries for Abstract Models in more areas (Fixes #194) Jun 15, 2023
@@ -220,7 +220,7 @@ class Renderer {

if (app == undefined) return

const models = this.get_models(app_id)
const models = this.get_models(app_id).filter(model => !model.abstract)
Copy link
Owner

@mmcardle mmcardle Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So i think at this point we should create a new function

get_concrete_models(appid) {
  return this.get_models(appid).filter(model => !model.abstract)
}

and use it everywhere you have it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes perfect sense, will do!

@mmcardle
Copy link
Owner

The const apps on line 216 is used as part of the rendering of the browsable tree in the UI, so I don't think your changes will affect this.

@GeoMaciolek
Copy link
Contributor Author

Did as suggested; new get_concrete_models(). We even saved a few lines, replacing a couple places where you'd had multi-line versions of the filter, like below:

// ######## Old Line ~1232 ########
    const models = this.get_models(appid).filter((modelData)=> {
      // Do not include abstract models in form views
      return !modelData.abstract
    })

// ######## Changed To ########
    // Do not include abstract models in form views
    const models = this.get_concrete_models(appid)

@mmcardle
Copy link
Owner

Looks good, tests pass, testing locally

@mmcardle mmcardle merged commit 957bede into mmcardle:master Jun 20, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants