Improve documentation and test coverage

Created on 15 September 2023, over 1 year ago
Updated 17 September 2023, over 1 year ago

Problem/Motivation

Improve documentation and test coverage.

Steps to reproduce

Proposed resolution

  • Add a kernel test CssGeneratorTest which tests behaviour of the advancedform.cssgenerator service with various inputs & expected outputs
  • Add a CssGeneratorInterface and allow the service to throw an exception if the rules input is invalid?
  • ๐Ÿ› selected-xxx classes not removed on select updates Active
  • Document steps to set up a content type, term and complex field so that behaviour is documented
  • Document syntax for CSS rules

Remaining tasks

User interface changes

  • Improve documentation of rules syntax
  • Improve documentation of how to use

API changes

  • Interface for CSS generator

Data model changes

๐Ÿ“Œ Task
Status

Active

Version

2.0

Component

User interface

Created by

๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @xurizaemon
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Steps to configure term-based behaviour

    1. Create a content type "page"
    2. Create a term "page subtype"
    3. Add two terms, "standard" and "complex"
    4. Add an entity reference field "page subtype" to the page content type, referencing the term
    5. Add a field "complex field" to the page content type
    6. Configure rules so that "complex field" is shown when the term selected is "complex" (class is "selected-standard" or "selected-complex" on the node create form
    7. Go to node edit or node create, use term selector to determine field visibility
  • @xurizaemon opened merge request.
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Adding related issue ๐Ÿ› selected-xxx classes not removed on select updates Active where test coverage for fields hidden by select option conditions is added.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    What threw me about this was that the rules syntax seems to ask you to incorporate a space, OR to add an additional selector inside the square brackets.

    Actual usage "in the wild" appears to be like this (now "documented" in the test coverage):

    .node-page-form:[.selected-standard-page .field--name-field-intro]
    

    This will generate:

    form.advanced-form-filtered.node-page-form.selected-standard-page .field--name-field-intro {
      display: none;
    }
    

    Which works because .selected-standard-page is applied to the create/edit form when term "Standard Page" is selected in a term <select>.

    Without the class inside the square brackets, I found I had to include an additional space to make the selectors work, and that felt unintuitive.

    Honestly the whole "rules to CSS" thing feels unintuitive and I'd probably use SASS today and keep the JS, but that's another issue.

Production build 0.71.5 2024