guardian / typerighter

Even if you’re the right typer, couldn’t hurt to use Typerighter!
Apache License 2.0
276 stars 12 forks source link

Add and edit dictionary rules in rule manager #447

Closed samanthagottlieb closed 1 year ago

samanthagottlieb commented 1 year ago

What does this change?

This adds the ability to add and edit dictionary rules in the rule manager.

The rule edit panel will include fewer fields than the panel for other rules, only including the following fields: Rule type, Pattern, Source, Tags.

The Source (category) will be automatically set to 'Collins dictionary addition' when adding a new dictionary rule. This is so we can distinguish between 'Collins Dictionary' rules and rules created by Guardian users.

The Source field will be disabled for dictionary rules, to prevent users from changing this to a different non-dictionary related source. When editing existing 'Collins Dictionary' rules, it will no longer be possible for users to change the source.

Previously the logic was using the rule category to determine which rules to include when instantiating the Dictionary matcher. This PR changes this so that a single dictionary matcher is created for all rules with the 'dictionary' rule type. This is to enable us to assign different categories/sources to newly created dictionary rules.

There are outstanding questions on whether it should be possible for users to batch edit dictionary rules at the same time as different rule types. The logic added in this PR that defaults dictionary rules to have a specific rule source (when creating/editing a single rule) could have an impact on batch editing. There are also some preexisting quirks with batch editing that could have an impact on batch editing different rule types - I captured these issues in a Trello card.

Trello card is here.

How to test

Adding a rule:

Editing a rule

Images

Before

Screenshot 2023-10-11 at 17 31 39

After

Screenshot 2023-10-11 at 17 34 08 - Screenshot 2023-10-11 at 17 15 05