This page is your one-stop shop for managing all the important terms and definitions used in your system. Think of it as a digital dictionary specifically tailored to your business needs!
Here's what you can do:
-
Search: Quickly find the term you're looking for by typing it in the search bar. You can search by:
- Term in Arabic
- Term in English
- Explanation in Arabic
- Explanation in English
- Notes in Arabic
- Notes in English
- Card ID number
-
Filter: Narrow down your search results using the filter options:
- Approved: Shows terms that have been officially approved.
- Not Approved: Shows terms that are still pending approval.
- Approved with Note: Shows terms that have been approved, but with additional comments.
-
View Details: Click on any term card to expand it and see its full details, including:
- Term in Arabic and English
- Detailed explanation in both Arabic and English
- Additional notes in both languages (if available)
- Approval status
-
Copy Information: Easily copy the Arabic or English explanations to your clipboard using the copy buttons on each card.
-
Add New Terms: Need to define a new term? Simply click the "+" button to open the "Add New Term" form. You can provide:
- Term in Arabic and English
- Detailed explanation in both languages
- Additional notes (optional)
- Initial approval status
-
Edit Existing Terms: Found a mistake? Need to update a definition? You can edit the Arabic and English explanations and notes directly on each card. Don't forget to save your changes!
-
Delete Terms: If a term is no longer relevant, you can delete it from the glossary. But be careful, deleting a term is permanent!
This page is designed to help you:
- Maintain consistency: Ensure everyone in your organization is using the same language and understanding of important terms.
- Improve communication: Facilitate clear and accurate communication by providing a shared repository of definitions.
- Boost efficiency: Quickly find the information you need, saving you time and effort.
We hope this user-friendly glossary management page helps you effectively manage your business terminology!
-
Import Statements:
- Imports necessary classes and modules from
flet
for UI elements. - Imports
Header
from a file namedheader.py
. - Imports elements from
palette.py
(presumably color definitions). - Imports
GlossaryManager
fromcontroller.py
andGlossaryModel
andsession
frommodel.py
.
- Imports necessary classes and modules from
-
GlossaryPage
Class:-
Purpose: This class is responsible for creating and managing the glossary page's UI and functionality.
-
Attributes:
page
: The Flet Page object.manager
: An instance of theGlossaryManager
class for handling glossary data.cards
: AColumn
widget to hold the individual term cards.search_bar
: ATextField
widget for searching terms.checkboxes
: A list ofCheckbox
widgets for filtering terms.add_term_button
: AFloatingActionButton
for adding new terms.header
: An instance of theHeader
class (presumably for the page header).
-
Methods:
-
__init__
:- Initializes the
GlossaryPage
object. - Sets up basic page properties (
scroll
,floating_action_button_location
, etc.). - Creates instances of
GlossaryManager
,Header
, search bar, checkboxes, and the "add term" button. - Calls
page_setup()
to build the UI. - Subscribes to the
pubsub
for updates and loads terms from the database.
- Initializes the
-
page_setup
:- Sets the page title, theme mode, language direction (RTL), and maximizes the window.
- Sets up custom fonts.
- Constructs the main layout using
SafeArea
,Container
,Column
, andRow
widgets to arrange search, filters, cards, and the "add term" button.
-
create_search_bar
:- Creates and returns the
TextField
widget for the search bar.
- Creates and returns the
-
create_checkboxes
:- Creates and returns a list of
Checkbox
widgets for filtering ("معتمد", "غير معتمد", "معتمد مع ملاحظة").
- Creates and returns a list of
-
create_add_term_button
:- Creates and returns the
FloatingActionButton
for adding new terms.
- Creates and returns the
-
filter_terms
:- Triggered when the search text or filter checkboxes change.
- Retrieves the search text and selected filter values.
- Calls the
search_terms
method of theGlossaryManager
to get filtered terms. - Updates the displayed cards using
update_cards
.
-
update_cards
:- Clears the existing cards and iterates through the provided
terms
. - For each term, calls
create_card
to create a card widget and adds it to thecards
column. - Updates the page to reflect the changes.
- Clears the existing cards and iterates through the provided
-
open_add_term_dialog
:- Creates and opens a dialog (
AlertDialog
) for adding new terms. - The dialog includes
TextField
widgets for term title, Arabic description, English description, Arabic notes, English notes, and aDropdown
for approval status. - Defines an
add_term
function (called when the "إضافة" button is pressed) to handle adding the new term to the database and updating the UI.
- Creates and opens a dialog (
-
load_terms_from_db
:- Queries the database using the
session
object to get all glossary terms. - Clears existing cards and creates a new card for each term loaded from the database.
- Queries the database using the
-
create_card
:- This lengthy method is responsible for creating a detailed card widget for a single glossary term.
- It includes
TextField
widgets for displaying and editing term information (Arabic/English descriptions, notes) and aDropdown
for the approval status. - It defines several helper functions:
on_copy_desc
,on_copy_desc_en
: Copy the Arabic/English descriptions to the clipboard.on_edit_desc
,on_edit_desc_en
: Enable/disable editing of the description and notes.on_clear
,on_clear_en
: Clear the text fields for Arabic/English descriptions and notes.on_delete
: Handles deleting the term (shows a confirmation dialog).on_approve_status_change
: Updates the term's approval status.on_save_changes
: Saves any changes made to the term back to the database.
-
on_update
:- Listens for updates from other users (likely through the
pubsub
). - If a new term (
GlossaryModel
) is received, a new card is created. - If a term ID (
int
) is received (indicating deletion), the corresponding card is removed.
- Listens for updates from other users (likely through the
-
on_hover
:- Implements a hover effect on the cards, changing the border color when the mouse hovers over a card.
-
-