8.1 Welcome to a New Chapter
In this chapter, we embark on creating a knowledge baseâa comprehensive module designed to help us manage and organize documents, tasks, and information seamlessly. By designing and implementing a tree-structured document collection, weâll establish an efficient system for tracking document status, managing attachments, and linking related tasks.
8.2 Exploring Database Design
8.2.1 Initial Design and Creating the Document Collection
Weâll begin with a straightforward database design by building a âDocument Collectionâ to catalog all document information. Key fields in the Document Collection include:
- Title: Single line text.
- Content: Markdown(Vditor).
- Document Status: Single select, with options including Draft, Published, Archived, and Deleted.
- Attachment: Attachment, Allows adding files and images to enrich document content.
- Related Task: A many-to-one relationship field to link the document with a task for easy reference in task management.
As our system evolves, weâll continue to add fields for more detailed document management.
8.2.2 Constructing a Tree Structure for Directory Management
A tree collection (provided by the plugin plugin-collection-tree), is a collection structure mirrors a tree, where each data item may have one or more child items, and those child items can, in turn, have their own descendants.
To ensure organization and hierarchy, weâll structure our Document Collection as a Tree collection, allowing for intuitive parent-child classification. This setup automatically generates the following fields:
- Parent ID: Identifies the parent document for the current document.
- Parent: A many-to-one field establishing parent-child relationships.
- Children: A one-to-many field that enables viewing all child documents under a parent document.
These fields are essential to maintaining the directory hierarchy, so itâs recommended not to alter them.
Weâll also establish an association with the Task Collection (Many-to-One), complete with inverse field, so that document lists can be directly created within the task association popup.
8.3 Creating the Document Management Page
8.3.1 Adding a New Document Management Menu
In the main system menu, add a new pageââDocument Managementâ, then select an appropriate icon. Next, create a table block for our Document Collection, enabling basic actions like Add, Delete, Edit, and Search, and input test data to validate the design of the data collection.
Exercise
- Add a parent document named âDocument 1â on the Document Management page.
- Under âDocument 1,â add a child document named âChapter 1.â
8.3.2 Converting to a Tree Table View
I know youâre probably wondering why itâs not a catalog tree structure.
By default, the table block displays as a regular table. Hereâs how to convert it to a tree table view:
-
Click on the top right corner of the table block > Tree Table.
You will notice that the moment you select it, a âExpand Allâ toggle appears below the Tree Table.
At the same time, the previously created âChapter Oneâ disappears.
-
Click on the âExpand Allâ option below the Tree Table to activate it.
Now, we can see the parent-child structure of the document displayed more intuitively, allowing us to easily view and expand all document levels.
Letâs proceed with the âAdd Sub-recordâ action.
Tree table conversion complete!
8.3.3 Configuring âAdd Child Recordâ
To add child records, weâll configure the necessary elements. When the Parent Record field is selected, it defaults to âread-onlyâ as new entries are created within the current document directory.
If there is too much task data, you might find it particularly troublesome to assign related tasks. We can set a default value for task filtering, making it equal to the tasks associated with the parent record.
The default value may not take effect immediately, letâs close and click again to see that it has been auto-filled~!
8.4 Configuring Form Templates and Task Associations
8.4.1 Creating Table and Form Templates
To ease future management, save the Document Table along with its create/edit forms as templates for reuse on other pages.
8.4.2 Displaying a Copied Document Table
In the Task view popup, add a new tab titled âDocuments.â Within this tab, add a form block > Other Records > Documents > âCopy Templateâ > and import the previously created document table template. (Ensure you select Copy Template).
This method streamlines document list creation.
8.4.3 Adjusting Task Associations
Since we copied an external table template, itâs not yet linked with the Task Collection. You might notice it displays all document data, which isnât ideal.
This situation is quite common. If we have not created a corresponding relationship field but still need to display related data, we must manually link the two. (Note: We use a copy of the template, not a reference template; otherwise, all changes we make will synchronize with other tables block!)
- Data Display Association
We click on the top right corner of the table block and Set the data scopeâ to:
ăTask/IDă= ăCurrent Popup Record/IDă
Successfully, the documents retained within the table are those associated with our task.
- Add form block association.
Enter the Add Block screen:
For fields related to associated tasks, set the default value to > [Parent Popup Record].
The parent popup is part of the âViewâ operation for the current task data and will directly link to the corresponding task data.
Setting it to read-only (view mode)indicates that only the current task can be linked within this popup.
Done! Now, newly added and displayed items will all be associated with the document of the current task.
If youâre attentive, you might add the association filter in âEditâ and âAdd Subtask.â
To make the tree structure clearer and the Actions Column neater, letâs move the title to the first column.
8.5 Filtering and Searching in Document Management
8.5.1 Adding a Filter Block
Add a filter block to Documents to enable advanced search options.
- Add a filter block on the Document Management page.
- Select the form for filtering and drag it to the top.
- Check fields such as Title, Status, and Task as filter criteria.
- Add âFilterâ and âResetâ actions.
This filter form acts as a search box, allowing for rapid document retrieval with keyword entry.
8.5.2 Connecting Data Blocks
At this point, you may notice that clicking yields no result. We need one final step: linking blocks with search functionality to each other.
-
Click on Settings in the upper right corner of the block and select Connecting Data Blocks.
Here, youâll see a list of available blocks that can be linked. Since we created a document form, it will search for all data blocks related to the document table (thereâs only one on this page) and display them as options. No need to worry about getting confused, as moving the mouse over an option will automatically focus the screen on the corresponding block.
-
Click to enable the block you want to link and test the search.
Click the configuration button in the top-right corner of the filter block to link it to the main data block of the document table. This way, whenever you set a condition in the filter block, the table block automatically updates the results based on the condition.
8.6 Setting Permissions for the Knowledge Base
To protect documents and standardize management, assign permissions based on user roles, allowing different users to view, edit, or delete documents according to their permissions.
However, we will be upgrading the document database to add features for news and task announcements, allowing for more flexible permissions.
8.7 Summary and Next Steps
In this chapter, we built the foundation of a knowledge base, incorporating a Document Collection, Tree Collection, and task associations. With added filter blocks and reusable templates, weâve optimized document management for efficiency.
Next, weâll build a personal dashboard featuring data analysis charts and key information displays!
Keep exploring and creating endless possibilities! If you encounter any issues along the way, donât forget to check the NocoBase Documentation or join the NocoBase Community for discussions and support.s