In this tutorial, we'll explore the concept of reusability in your Ketroute Framework using the low-code module approach. The Ketroute Framework allows you to efficiently manage components by simply creating configuration files. We'll use a component example called "department" to demonstrate how this works.
Reusability is a key principle in software development that allows you to use existing code for new functions without rewriting it. This not only saves time but also reduces errors and ensures consistency across your application. In your framework, reusability is achieved by defining configurations for components instead of manually creating forms, validations, audit logging and SQL statements.
Let's consider a "department" component with the following modules:
To enable these modules using the low-code approach, you need to create a configuration file where various parameters and methods are defined.
The table name where the department records are saved. This is defined using the tableName method.
$objConfig->tableName ('department');
Define the list of fields and their properties such as name, label, whether they are required, size limitations, and any special validations or formatting.
$objConfig->text('department_name', 'department-name', 1)->max(100);
$objConfig->telephone('telephone', 'telephone', 0)->max(20);
$objConfig->text('address', 'address', 0)->max(255);
$objConfig->text('business_unit_name', 'department-business-unit', 1)->max(100);
Define the fields from the table that the user will see on the list page using the listFields method.
$objConfig->listFields(array('department_id','business_unit_name','telephone','address','status_id'));
Define the fields you want users to see for sorting results.
$objConfig->sortFields(array('department_name' => KSystemManager::SORT_ASCENDING));
Define the fields for filtering results using the groupFilterField method.
$objConfig->groupFilterField('fbdn', $field = 'department_name', 'department-name');
$objConfig->groupFilterField('fbtl', $field = 'telephone', 'telephone');
$objConfig->groupFilterField('fbad', $field = 'address', 'address');
Define the fields that users can export to a PDF or Excel file.
$objConfig->exportFields(array('department_name','telephone','address','business_unit_name'));
Define the fields users must complete in forms for adding or editing records using the addFields and editFields methods.
$objConfig->addFields(array('department_name','telephone','address','business_unit_name'));
$objConfig->editFields(array('department_name','telephone','address','business_unit_name'));
Define the fields users will see when viewing the record using the viewFields method.
$objConfig->viewFields(array('department_name','telephone','address','business_unit_name', 'created_by', 'created_date', 'modified_by', 'modified_date));
The low-code module approach the Ketroute Framework significantly simplifies the process of managing components. By creating configuration files, you can quickly define the necessary parameters for your modules, ensuring efficiency, consistency, and flexibility. This method allows you to focus more on the business logic and less on the repetitive tasks of form creation and validation.
Feel free to extend this tutorial with more complex examples and additional configurations to cover other aspects of the Ketroute Framework.
Your download is here.