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

Codegen: Add column to existing list #68

Closed
7 tasks
jozef-slezak opened this issue Feb 3, 2021 · 2 comments
Closed
7 tasks

Codegen: Add column to existing list #68

jozef-slezak opened this issue Feb 3, 2021 · 2 comments
Assignees
Labels
ready issue was reviewed and is ready for development
Projects

Comments

@jozef-slezak
Copy link
Contributor

jozef-slezak commented Feb 3, 2021

Description:

We need to extend current solution to be able not only generate table from scratch, but also to be able to add new column at specific position.

Proposed solution:

  • check if component exists at given position
  • every generator must implement function insertColumn
  • need to implement WidgetContext from codegen interfaces diagram and use it in generators
  • parse existing react typescript source code from parent context - SourceFileContext (it will contains source code of generated page) using Abstract Syntax Tree (AST - use typescript compiler API)
  • transform source code by adding new column to table (we need to preserve original formatting)
  • create code snippet using typescript compiler factory API (https://ts-ast-viewer.com/)
insertColumn(componentPosition: SourcePosition, property: Property, columnIndex?: number)

Aceptance criteria:

  • GIVEN have defined interface
    WHEN i use generator to generate table
    THEN it use methods from implemented interface
  • GIVEN have defined tests for add new column
    WHEN i run these tests
    THEN all tests will pass
  • GIVEN have generated table without column field1
    and columnIndex is not defined
    WHEN i call insertColumn with field1
    THEN generated table will contains field1 at the end of the table
  • GIVEN have generated table without column field1
    and columnIndex is defined
    WHEN i call insertColumn with field1
    THEN generated table will contains field1 at the defined position
  • GIVEN have generated table with column field1
    WHEN i call insertColumn with field1
    THEN field1 wont be added again
  • GIVEN have any type of supported table type
    WHEN i call insertColumn
    THEN all tables support this action
  • GIVEN already generated table
    and using specific formatting within table
    WHEN i insert new column
    THEN inserted column will preserve defined formatting
@jozef-slezak jozef-slezak added the help wanted Extra attention is needed label Feb 3, 2021
@jozef-slezak jozef-slezak changed the title Simple task related to job description Generator: add column to existing table Feb 15, 2021
@jozef-slezak jozef-slezak pinned this issue Mar 9, 2021
@jozef-slezak jozef-slezak added this to To do in codegen Apr 19, 2021
@mat-app mat-app changed the title Generator: add column to existing table Generator: add column to existing list Apr 21, 2021
@mat-app mat-app changed the title Generator: add column to existing list Generator: Add column to existing list Apr 21, 2021
@mat-app mat-app changed the title Generator: Add column to existing list Codegen: Add column to existing list Apr 21, 2021
@mat-app mat-app added the not ready issue is not ready for development label Apr 21, 2021
@mat-app mat-app self-assigned this Apr 22, 2021
@mat-app mat-app added ready issue was reviewed and is ready for development and removed not ready issue is not ready for development labels Apr 22, 2021
@jozef-slezak
Copy link
Contributor Author

Useful functions in existing codebase:

3a7d7b4#diff-722ffe81d10ea05a849cc753ac0a939d99433539e148e85dc9c97f57807f018aR19

1f78b37#diff-96dab814d3ba51e56b4087d42c76afaba52f68cb551edd8d235a152f7dea7391R38

export function startOfJsxIdentifier(code: string, source: SourceLineCol) {

jozef-slezak added a commit that referenced this issue May 8, 2021
jozef-slezak added a commit that referenced this issue May 8, 2021
jozef-slezak added a commit that referenced this issue May 8, 2021
@mat-app mat-app removed the help wanted Extra attention is needed label May 18, 2021
@jozef-slezak
Copy link
Contributor Author

@mat-app, think about adding same column twice. Please, check the presence of the key in the json and second time ad a suffix to the key.

codegen automation moved this from To do to Done Jul 2, 2021
@jozef-slezak jozef-slezak unpinned this issue Jul 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready issue was reviewed and is ready for development
Projects
Development

No branches or pull requests

2 participants