Adding name control

Adding name control

Status: IsProposal

Author

JimFulton

Problem

Adding objects and add views collaborate to provide a UI for adding objects to containers:

     -------------             -----------             ------------
     |           |  <<views>>  |          |  <<views>>  |          |
     | Container |<- - - - - - |  Adding  |<- - - - - - | Add View |
     |           |             | <<view>> |             | <<view>> |
     -------------             ------------             ------------

The adding object represents the interests of the container:

  • It figures out what's addable
  • It manages naming, according to the container's naming policies.
  • It decides what page to display after an object is added.

The add view is responsible for collecting necessary initial information and properly creating the object. It is not responsible for naming the object.

To prevent the add view from being responsible for naming, we initially collected names on pages before displaying add views. This approach had two problems:

  • The user sometimes had to view an extra page, to input the name,
  • The name wasn't shown on the add view page(s). This meant that the user had less information than they wanted when viewing the add view and that the user couldn't change their mind about the name when filling out the other information.

To solve these problems, we recently added a new method, renderAddButton, to adding objects. Add views use this method to display add buttons on forms. If a name is needed, the adding will include an input box next to the add button. This approach is too magic and doesn't give enough control to the add view.

Proposal

Simplify the collaboration for inputing new object names by shifting more responsibility to add views. Adding views will still be responsible for deciding whether a name should be input, but add views will be responsible for collecting the name if it is allowed.

Adding objects will implement a new boolean method nameAllowed:

      def nameAllowed():
          """Return whether names can be input by the user.
          """

We will deprecate and eventually remove the renderAddButton method.

Add views will be responsible for checking nameAllowed and collecting a name if it returns True. Adding views will then set contentName on the adding object before calling add.



( 97 subscribers )