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

feat(cat-voices): loading document into proposal builder #1493

Open
wants to merge 27 commits into
base: main
Choose a base branch
from

Conversation

damian-molinski
Copy link
Contributor

@damian-molinski damian-molinski commented Jan 9, 2025

Description

This PR adds wiring of Repositories - Services - Blocs - widgets for Document to be displayed in ProposalBuilder. At the moment Documents are always loaded from assets json.

Related Issue(s)

Resolves #1465

Description of Changes

Proposal Builder paths

workspace/proposal_builder/draft?templateId=:templateId
workspace/proposal_builder/:proposalId

Not yet sure what templateId will be, is it DocumentId or smth else.

  1. New draft without specifying templateId (query param), active campaign default template will be used.
  2. New draft with templateId will load that.
  3. Editing existing proposal is done with second path.

Guidance

Removed existing code (types, weights etc) as its not used and only clouds current code. To be implemented using MarkdownData.

DocumentBuilderSectionTile

Properties widgets are commented out because definition type casing is not working at the moment. Added TODO to comment out later. Using placeholder text for now.

TagGroupDefinition and TagSelectionDefinition throw UnsupportedError because those are children of SingleGroupedTagSelectorDefinition.

Models

Changed Campaign to CampaignBase (same with Proposal). We're not 100% sure how CampaignBase/ProposalBase will look like but most likely most, if not all, current properties will be removed because all information's will come from Document.

CampaignBase/ProposalBase will be returned by corresponding repository and later service will use DocumentRepository to get it Document and build Campaign/Proposal with it.

DocumentRepository is using Lock when fetching DocumentSchema because multiple same documents may try to access same schema which should be loaded only once.

Document

document and schema json's are moved to assets package. Should be removed once DocumentRepository won't depend on them. This will require changing back flutter_test to test in repository package.

Screenshots

Screenshot 2025-01-15 at 10 34 57

Related Pull Requests

Uncomment DocumentBuilderSectionTile properties widgets when casting works in
#1503

Please confirm the following checks

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream module

@damian-molinski damian-molinski added do not review yet Do not review yet dart Pull requests that update Dart code F14 labels Jan 9, 2025
@damian-molinski damian-molinski self-assigned this Jan 9, 2025
Copy link
Contributor

github-actions bot commented Jan 9, 2025

Test Report | ${\color{lightgreen}Pass: 384/385}$ | ${\color{red}Fail: 1/385}$ |

Copy link
Contributor

github-actions bot commented Jan 9, 2025

Test Report | ${\color{lightgreen}Pass: 360/367}$ | ${\color{red}Fail: 7/367}$ |

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 374/378}$ | ${\color{red}Fail: 4/378}$ |

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 374/378}$ | ${\color{red}Fail: 4/378}$ |

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 392/392}$ | ${\color{red}Fail: 0/392}$ |

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 392/392}$ | ${\color{red}Fail: 0/392}$ |

@damian-molinski damian-molinski marked this pull request as ready for review January 15, 2025 10:33
@damian-molinski damian-molinski added review me PR is ready for review and removed do not review yet Do not review yet labels Jan 15, 2025
Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 392/392}$ | ${\color{red}Fail: 0/392}$ |

Comment on lines +82 to +83
// TODO(damian-molinski): not sure what should go here.
schemaUrl: proposalTemplate.propertiesSchema,
Copy link
Contributor

Choose a reason for hiding this comment

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

Most likely this should be the url from where we fetch the schema but since we will get it as binary not as json this semantically doesn't make sense since the url should lead directly to the schema json, not schema encoded in some form.

Copy link
Contributor

Choose a reason for hiding this comment

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

I asked the architects about it

Comment on lines +105 to +106
documentId: newDocumentId,
documentVersion: newDocumentId,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we create a document for the first time, not sure if the version should be set. The id is required, the version is optional - I think we only set the version if we edit something. Can you try to confirm it?

Comment on lines +4 to +20
abstract base class DocumentBase extends Equatable {
/// Unique identifier of document. Uuid-v7
final String id;

/// Documents are immutable so [id] does not change but we can have
/// different versions of same document.
final String version;

const DocumentBase({
required this.id,
required this.version,
});

@override
@mustCallSuper
List<Object?> get props => [id, version];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Documents will have more metadata fields, some of them will be specific to some types of documents, like proposals, schemas or comments.

We can't just add all of them here, and the Document is not a good place either. I think the current Document could be the base that others extend from and we could add a ProposalDocument extends Document that has these extra metadata fields. Also in the ProposalDocument we can have a getter for extracting some fields from the dynamic structure of the document like budget or title, it would be a good place to put logic specific to proposals. Then we can have CommentDocument, etc.

Imho the id and version are repeating themselves across all types of documents so they could be in the base class.

The docs are here: https://input-output-hk.github.io/catalyst-libs/branch/feat_signed_object/architecture/08_concepts/signed_doc/spec/#abstract

Copy link
Contributor

Choose a reason for hiding this comment

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

Another idea would be to have a ProposalDocument class that has the document as a field but doesn't extend it. Then it would be easier to maintain the DocumentBuilder because it wouldn't have to know about these extra metadata fields that are specific to each type of the document.

Imho this solution is more scalable than extending a Document.

Copy link
Contributor

Test Report | ${\color{lightgreen}Pass: 392/392}$ | ${\color{red}Fail: 0/392}$ |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dart Pull requests that update Dart code F14 review me PR is ready for review
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

🛠️ [TASK] : Load proposal into proposal builder page
2 participants