I have the same issue here. https://github.com/ng-druid/platform/blob/master/modules/pages/src/lib/components/panel-page/panel-page.component.html
A bunch of worthless switches that need to be replaced with the plugin mechanism. On Friday, March 12, 2021 at 6:41:10 AM UTC-5 Todd Zmijewski wrote: > Also, this is not something I created. It's all inspired by Drupal. > > https://www.drupal.org/docs/drupal-apis/plugin-api/plugin-api-overview > > I worked with Drupal for a long while before seeing the light. However, > there are architectural pieces of that platform that are ingenious. The > plugin system being one of them. So I stole it… > > On Friday, March 12, 2021 at 6:37:45 AM UTC-5 Todd Zmijewski wrote: > >> Layout is an easy example of how this kind of works. >> >> >> https://github.com/ng-druid/platform/blob/master/modules/layout/src/lib/models/layout.models.ts >> >> A plugin is just a class that extends Plugin adding properties specific >> to that plugin/context. These are all properties that every instance of >> that class share. If they share the properties they can than be swapped out >> with one another. >> >> Inside the layout module I also declare the base layouts as plugins. >> >> >> https://github.com/ng-druid/platform/blob/master/modules/layout/src/lib/layout.factories.ts >> >> The idea being that any layout can take the place of another layout. Also >> the layouts can be added without altering the library source code. >> >> On Friday, March 12, 2021 at 6:30:18 AM UTC-5 Todd Zmijewski wrote: >> >>> I would somewhat disagree. If this is your own code and you don't need >>> to make it flexible enough to extend without adding more cases this is >>> fine. Its in no way a great solution nor one I would recommend but the >>> alternatives are much more complex. I really hate promoting my own projects >>> especially when they are no where near what I want them to be but >>> implementing some type of plugin system where each of those controls can be >>> swapped out with another so long as they implement the same interface seems >>> like it would work well. I have not used formly but have read the docs. I >>> think formly is a great solution for building dynamic forms. >>> >>> This is my project where I had to implement a plugin system basically >>> for the same reason. I started with a bunch of hard coded switch cases but >>> soon realized the limitation. So I migrated to tokens. Realized tokens are >>> not a great solution because services that have already been instantiated >>> don't get any updates. So decided to implement my own plugin service that >>> can not only be extended dynamically but discover plugins from any possibly >>> any location. Including locations outside my source code. Inspired by >>> Drupal. >>> >>> https://github.com/ng-druid/platform/tree/master/modules/plugin/src/lib >>> >>> On Wednesday, March 10, 2021 at 5:43:12 AM UTC-5 bastien...@gmail.com >>> wrote: >>> >>>> It seems you're creating some sort of dynamic form (display date picker >>>> if data is of type date ...) >>>> We have been using either ngx/formly or some angular dynamic component >>>> creation mechanism: https://angular.io/api/core/ComponentFactory >>>> >>>> Hope this helps >>>> >>>> *Bastien Lemaire* >>>> >>>> >>>> On Wed, 10 Mar 2021 at 11:39, john.mb...@gmail.com < >>>> john.mb...@gmail.com> wrote: >>>> >>>>> hi, as you can see in my code below, I am repeating code. I was just >>>>> wondering what the best way would be to refactor this code: >>>>> >>>>> ``` >>>>> <div class="my-2" *ngSwitchCase="'BPFDateTimeElement'"> >>>>> <core-date >>>>> [control]="form.get(section.objectID).get(rowElement.objectID)" >>>>> [element]="rowElement" >>>>> ></core-date> >>>>> </div> >>>>> <div class="my-2" *ngSwitchCase="'BPFBooleanElement'"> >>>>> <core-boolean >>>>> [control]="form.get(section.objectID).get(rowElement.objectID)" >>>>> [element]="rowElement" >>>>> ></core-boolean> >>>>> </div> >>>>> <div class="my-2" *ngSwitchCase="'BPFEntryElement'"> >>>>> <core-input >>>>> [control]="form.get(section.objectID).get(rowElement.objectID)" >>>>> [element]="rowElement" >>>>> ></core-input> >>>>> </div> >>>>> <div class="my-2" *ngSwitchCase="'BPFTextViewElement'"> >>>>> <core-textarea >>>>> [control]="form.get(section.objectID).get(rowElement.objectID)" >>>>> [element]="rowElement" >>>>> ></core-textarea> >>>>> </div> >>>>> <div class="my-2" *ngSwitchCase="'BPFPicklistElement'"> >>>>> <core-pick-list >>>>> [control]="form.get(section.objectID).get(rowElement.objectID)" >>>>> [element]="rowElement" >>>>> ></core-pick-list> >>>>> ``` >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Angular and AngularJS discussion" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to angular+u...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/angular/2818053c-c552-4084-a846-9bad28f832c7n%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/angular/2818053c-c552-4084-a846-9bad28f832c7n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- You received this message because you are subscribed to the Google Groups "Angular and AngularJS discussion" group. To unsubscribe from this group and stop receiving emails from it, send an email to angular+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/angular/458891ba-8721-4def-82a9-f2acbea9e79bn%40googlegroups.com.