This tool generates HTML view for a database table; to be added to Node++ project. Requires also adding compatible DAO/ORM class to the project.
You can try view generated for products live.
You can define up to 4 levels of authorization. Middle levels can have further restrictions if column is defined: only the records belonging to the current user will be accessible. For example, the table may have columns
cust_id. These columns can be specified for the Middle and Low levels, respectively. Then the sales rep will be able to access only the records belonging to their customers, that is records with
sales_rep=<user ID>, and the customer will only be able to access theirs.
In order for authorization to work properly, the table has to have single column as a primary key – either integer or string – and it needs to be the first column in the table definition.
Session levels and access permissions can easily be changed at any time by defining macros outside the generated files (see generated
*.h file). On the other hand, binding columns affect generated logic so in the case change is required, re-generating will be better than manually changing previously generated code.
Use macros in
Both table and column should be uppercase. Action means for example
EDIT. Device type can be
MOB. Device or column might not always be present.
By default, all columns' labels are simply capitalized columns' names. To change this define:
#define VIEW_PRODUCTS_QUANTITY "In Stock"
Most of the rendered HTMLs are based on tables. There is a group of macros as the placeholders for CSS's
class="xyz" to style many aspects of them, including separate classes for odd and even rows. See generated header file for the complete list.
By default, all columns except of TEXT and BLOB types will be shown on the list. If you want to hide some of them, you can set those which would be hidden – separately for the desktop and phone screen.
#define VIEW_PRODUCTS_LIST_DSK_HIDE_QUANTITY /* quantity will not be shown on the list on desktop */
#define VIEW_PRODUCTS_LIST_MOB_HIDE_QUANTITY /* quantity will not be shown on the list on the phone */
You can also make columns read-only:
It's possible to automatically handle small lists as combo boxes. How to use it:
npp_app.hmust contain value-description pairs as macros.
For example, if
products had a column
allowed_abroad char(1) then in
#define VIEW_PRODUCTS_ENUM_ALLOWED_ABROAD_01_VAL 'Y'
#define VIEW_PRODUCTS_ENUM_ALLOWED_ABROAD_01_DESC "Yes"
#define VIEW_PRODUCTS_ENUM_ALLOWED_ABROAD_02_VAL 'N'
#define VIEW_PRODUCTS_ENUM_ALLOWED_ABROAD_02_DESC "No"
Instead of showing
N, there would be
No as the values. In the edit form, instead of input box there would be a combo box.
Maximum number of options for each column is 10.
Sometimes there's a need for additional actions' buttons or additional columns from joined tables to be shown with the current record. Manually adding such a code would make it difficult to generate the views again. To solve this there are several places in the generated code for such custom injections. You can add to
#define VIEW_PRODUCTS_LIST_BEFORE_TABLE code to be called before HTML table, i.e. for additional actions' buttons
#define VIEW_PRODUCTS_LIST_DISABLE_NEW hides New Record button
#define VIEW_PRODUCTS_LIST_DSK_BEFORE_HEADERS code to be called inside the HTML table row, before the first header (th)
#define VIEW_PRODUCTS_LIST_DSK_AFTER_HEADERS code to be called inside the HTML table row, after the headers set (th)
#define VIEW_PRODUCTS_LIST_DSK_BEFORE_COLUMNS code to be called inside the HTML table row, before the first column
#define VIEW_PRODUCTS_LIST_DSK_AFTER_COLUMNS code to be called inside the HTML table row, after the columns
#define VIEW_PRODUCTS_DETAILS_BEFORE_TABLE code to be called before HTML table, i.e. for additional actions' buttons
#define VIEW_PRODUCTS_DETAILS_BEFORE_COLUMNS code to be called inside the HTML table, before the first column
#define VIEW_PRODUCTS_DETAILS_AFTER_COLUMNS code to be called inside the HTML table, after the columns
#define VIEW_PRODUCTS_EDIT_BEFORE_COLUMNS code to be called inside the HTML table, before the first column
#define VIEW_PRODUCTS_EDIT_AFTER_COLUMNS code to be called inside the HTML table, after the columns
#define VIEW_PRODUCTS_ON_SAVE code to be called when saving the record, inside the try block
#define VIEW_PRODUCTS_ON_REMOVE code to be called when removing the record, inside the try block
All above placeholders are after permission checking.
As apparently there's no standard for filtering URLs, I decided to optimize it for clarity and shortness. I tried to avoid special characters that would force ugly URL encoding. Here's the summary:
*** strings ***
name=john name LIKE '%john%'
name_eq=john name = 'john'
name_sw=john name LIKE 'john%'
name_neq=john name != 'john'
name_in=john,johnny name IN ('john', 'johnny')
name_nin=john,johnny name NOT IN ('john', 'johnny')
*** numbers ***
price=123 price = 123
price_eq=123 price = 123
price_neq=123 price != 123
price_lt=123 price < 123
price_lte=123 price <= 123
price_gt=123 price > 123
price_gte=123 price >= 123
price_in=123,222 price IN (123, 222)
price_nin=123,222 price NOT IN (123, 222)
Order can be specified by
o parameter, i.e.:
Descending order is indicated by
od parameter, i.e.:
Generator v.1.0.0, last update 2020-04-30 (Sorting)
Session level ≥ UID column:
Session level ≥ UID column:
All other – including not logged in – sessions:
Copyright © 2018–2021 Jurek Muszyński