]project-open[ Core : Dynamic Views
]project-open[ Core

Dynamic Views

Requirements

Frequent new modules need to extend the ListPages of important business objects (such as companies, projects, ...) by their additional columns. For example the P/O Timesheet module may need to add a column to the ProjectListPage with the amount of hours spend on every projects. The P/O Core module may not know about this future necessity in the moment is is implemented. So we want to allow a-posteriori extension of ListPages.

Dynamic Views are also required/desired when showing information about subclasses of objects, such as an EmployeeListPage. The EmployeeListPage may want to add a column such as "Monthly Salary", which does not make sense in the general UserListPage. Dynamic Views allow to have a single .tcl/.adp page showing different views, depending on URL runtime parameters.

Design

To allow for dynamic extensibility, we keep all column information in a database table:

create table im_view_columns (
       column_id				integer
constraint im_view_columns_pk
primary key,
view_id integer not null
constraint im_view_view_id_fk
references im_views,
column_name varchar(100) not null,
-- tcl command being executed using "eval" for rendering the column
column_render_tcl varchar(4000),
-- add to select statement for when the column name results from an "as" command
-- for ex., you can customize viewing columns
extra_select varchar(4000),
extra_where varchar(4000),
sort_order integer not null,
-- set of permission tokens that allow viewing this column,
-- separated with spaces and OR-joined
visible_for varchar(1000)
);

Im_views contains a mapping of names to view_ids and provides RI to im_view_columns:

create table im_views (
view_id integer
constraint im_views_pk
primary key,
view_name varchar(100)
constraint im_views_name_un
not null unique,
visible_for varchar(1000)
);
There is a typical ListPage example that shows how everything fits together.