Add Authorities to lookups

Issue #926 resolved
Ghislain Hachey created an issue

No description provided.

Comments (4)

  1. Brian Lewis repo owner

    To add the ability to edit a table to the lookups table maintenance the steps are quite straightforward:

    1. In Sql Server make sure the table has the ‘ChangeTracked’ fields: ie
      pCreateUser, pCreateDateTime, pEditUser, pEditDateTime, pRowversion
    2. Create a model in Pineapples.Data for the table. You can use the POCOGenerator tool for this, or may be possible to inherit from SimpleCodeTable or SequencedCodeTable. Add a table [Description] attribute to get this in the lookups editor. Also note if you ultimately want to get a dropdown list of some other lookup in the editor grid, add the [ClientLookup] attribute to the field. The better this class is defined by attributes, the better the result will be.
    3. Change the primary key to code (string) or ID(int) and rely on the [Column] attribute to map this to the correct field name.

    4. Add the new entity collection to PineapplesEFContext

    5. In Pineapples, add a new controller for this object to controllers_api or controllers_api/lookups Choice depends on whether this is a ‘lookup;’ table or an application entity (e.g. for authorities, I’d go with controllers_api).
      This controller should inherit from TableMaintenanceController. Typically you’ll copy and modify an existing one, so be careful to set up all the generic parameters correctly, for the data type of the key etc., check the [RoutePrefrix] also.
    6. To get this to be editable in #!/tables, add the new controller name to LookupsController.editableTables. This is the source of the dropdown list of editable tables in #!/tables.
    7. This should now work. You’ll get a default viewMode constructed from the table definition. This will respect data types and sizes to give a good approximation. You can override this by putting a customised viewmode into the ViewModes folder. Simpest way to do this is to generate the automatic one, capture the result (e.g. from Fiddler) and edit it.

    TROUBLESHOOTING: use fiddler to make sure that you are getting the correct api calls generated for your entity type. Be especially careful that a PUT should include the primary key value e.g. api/authorities/foo. If you are not getting the primary key in the url, check step 3. (and note how this relates to getIdFromElem in ConfigRestangularPinappples).

  2. Brian Lewis repo owner

    In summary, this is built on communication between Restangular, Web Api and EntityFramework. The reusable plumbing is implemented in the TableMaintenanceController base class, and the DynamicBinder<> generic

  3. Log in to comment