rules icon indicating copy to clipboard operation
rules copied to clipboard

feature driven directory structure

Open GregOnNet opened this issue 4 years ago • 3 comments

Currently, all rules are collected in one rules-folder. The main reason for that is that the file user-rules.ts collects all rules and is referenced in app.module.ts.

In terms of discoverability it would be nice to be able placing rules as near to the entity as possible.

star-wars/
┣ model/
┃ ┣ character.ts
┃ ┣ character.rule.oss
┃ ┣ character.rule.oss.ts
┃ ┗ lightsaber-color.ts
┣ star-wars-routing.module.ts
┣ star-wars.component.ts
┗ star-wars.module.ts

To be able to do this it would be needed to simplify registering rules in metaUI.

// app.module.ts
import * as app from './rules/app-rules';

// ...
imports: [
  MetaUIModule.forRoot({
    rules: {
      appRules
    }
  })
]

// star-wars.module.ts
import * as characterRules from './rules/user-rules';

// ...
imports: [
  MetaUIModule.registerRules({
    characterRules
  })
]

Open questions

In app.module.ts a name is set for the rule: 'metaui.rules.user-rules' For what is this name needed?

const rules: any[] = config.get('metaui.rules.user-rules') || [];

rules.push(userRules);
config.set('metaui.rules.user-rules', rules);

GregOnNet avatar Aug 10 '20 05:08 GregOnNet

It woudl be definitelly possible and it should be in the same folder as entity itself. The only thing we would have to reference this in user-rules.ts.

instead of :

./ts/xxx.oss.ts

it would be:

../some app folder/some subfolder/model/xxx.oss.ts

fkolar avatar Aug 10 '20 07:08 fkolar

Cool,

we can also provide schematics to create rules like components and link them to the correct module.

GregOnNet avatar Aug 11 '20 09:08 GregOnNet

To your open question:

I need to store rules in correct order. E.g. ifyou want to use your rules in the library to create some reusable page

  1. Register rules From Library
  2. Register Rules from App.

But if we make this to work

 MetaUIModule.forRoot({
    rules: {
      appRules
    }
  })

I can imagine better solution than this

config.set('metaui.rules.user-rules', [...config.get('metaui.rules.user-rules', .. userRules.]);

We will be able to use this registerRules both for libraries as well as application.

fkolar avatar Aug 11 '20 17:08 fkolar