Skip to content

Commit e704b04

Browse files
committed
Update
1 parent 7de9dfc commit e704b04

5 files changed

Lines changed: 209 additions & 62 deletions

File tree

doc/dev-examples.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
25. Developing Examples
66
=======================
77

8-
After module
9-
8+
Building examples is similar to building tests described in the last chapter.
109

1110
- structure
1211
- app config (database)

doc/dev-object-modeling.rst

Lines changed: 154 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -5,37 +5,133 @@
55
26. x0-Object Modeling
66
======================
77

8-
The following sections explain how to design custom x0 system objects and define
9-
their specifications for seamless integration into the core system.
8+
The following sections explain how to design **custom** *x0-system-objects* and
9+
define their **specifications** for seamless integration into the core system.
1010

1111
26.1. Basic Modeling Rules
1212
--------------------------
1313

14-
You should have a solid understanding of the following x0 fundamentals before
14+
You should have a **solid understanding** of the following *x0* fundamentals before
1515
continuing:
1616

1717
- Base Classes / Inheritance
18-
- Child Objects
18+
- Child Objects / Parent Object
1919
- Event Handler / Callbacks
2020
- Building Object Structure (DOM)
2121
- Modifying Runtime Data
22-
- Object Realtime Updating
22+
- Object Realtime Updates
23+
- Object Initialization
24+
- Adding Context Menu Functionality
2325

2426
26.1.1. Base Classes / Inheritance
2527
**********************************
2628

2729
You should familiarize yourself with the x0 *Core Base Model*.
2830
Refer to: :ref:`devoopmodel_base`.
2931

30-
26.1.2. Child Objects
31-
*********************
32+
Any **custom** *x0-system-object* must inherit ``sysBaseObject`` in its prototype.
33+
34+
.. code-block:: javascript
35+
36+
//- inherit sysBaseObject
37+
sysObjNewcomer.prototype = new sysBaseObject();
38+
39+
26.1.2. Child Objects / Parent Object
40+
*************************************
41+
42+
The ``self.ChildObjects[]`` model in ``sysBaseObject.js`` is an array that
43+
manages the child objects of a ``sysBaseObject`` instance. It functions as a
44+
recursive container for hierarchical object structures within the
45+
*x0-framework*.
46+
47+
1. Initialization
48+
49+
In any new modeled Object's constructor, ``this.ChildObjects[]`` must be initialized
50+
as an empty array:
51+
52+
.. code-block:: javascript
53+
54+
this.ChildObjects = new Array(); //- Child Objects
55+
56+
2. Child Object Relationships
57+
58+
Each child object in the array is an instance of ``sysBaseObject`` or its derived classes.
59+
A parent-child relationship is established using the ``ParentObject`` property.
60+
61+
This enables any child object to directly access its parent(s).
62+
63+
.. code-block:: javascript
64+
65+
//- Do something in the ParentObject
66+
this.ParentObject.doSomething();
67+
68+
//- Do something in the ParentObject.ParentObject
69+
this.ParentObject.ParentObject.doSomething();
70+
71+
3. Add Objects
72+
73+
Adding objects to self is done like this:
74+
75+
.. code-block:: javascript
76+
77+
//- add new sysObjDiv()
78+
let Obj1 = new sysObjDiv();
79+
Obj1.ObjectID = 'MyDiv1';
80+
81+
//- add Obj1 to parent
82+
this.addObject(Obj1);
83+
84+
see: :ref: sysBaseObject.addObject()
85+
86+
4. Propagate Object(s) to DOM
87+
88+
.. code-block:: javascript
89+
90+
//- render all ParentObject.ChildObjects[]
91+
this.ParentObject.renderObject();
3292
3393
26.1.3. Event Handler / Callbacks
3494
*********************************
3595

96+
If you want to process native DOM Events (not *x0-events*),
97+
in any new modeled Object's constructor, ``this.EventListeners[]`` must be
98+
initialized as an empty array:
99+
100+
.. code-block:: javascript
101+
102+
this.EventListeners = new Array(); //- Array of EventListener Objects
103+
104+
1. Add Event Listeners
105+
106+
.. code-block:: javascript
107+
108+
let EventListenerObj = new Object();
109+
EventListenerObj['Type'] = 'mousedown'; //- Event Type 'mousedown'
110+
EventListenerObj['Element'] = this.EventListenerCallback.bind(this); //- Callback Method
111+
this.EventListeners['ListenerID'] = EventListenerObj; //- Add Listener with ListenerID
112+
113+
2. Multiple Event Listeners
114+
115+
When adding multiple Event Listeners, processing order will be preserved.
116+
117+
3. Event Listener Activation
118+
119+
After adding Event Listeners in Realtime Objects, they have to be explicitely
120+
activated before working.
121+
122+
.. code-block:: javascript
123+
124+
this.processEventListener();
125+
126+
4. sysButtonCallback Object
127+
128+
The ``sysButtonCallback`` *x0-object* can be used to asbtract ...
129+
36130
26.1.4. Building DOM Object Structure
37131
*************************************
38132

133+
See :ref:`devporting`.
134+
39135
26.1.5. Modifying Runtime Data
40136
******************************
41137

@@ -44,34 +140,59 @@ Refer to: :ref:`devoopmodel_base`.
44140
- RuntimeAppend(Data)
45141
- XML-RPC Async Data
46142

47-
26.1.6. Modifying Runtime Data
48-
******************************
143+
26.1.6. Updating Realtime Objects
144+
*********************************
145+
146+
1. remove()
147+
2. removeParent()
148+
3. RTfunctions
149+
4. Examples
150+
151+
26.1.7. Object Loading / Initialization
152+
***************************************
153+
154+
1. init()
155+
156+
26.1.8.Adding Context Menu Functionality
157+
****************************************
158+
159+
1. Add Event Listener init()
160+
2. Setup Context Menu
161+
3. Eventually extend
49162

50-
- Different approaches remove() and removeParent() + RTfunctions
51163

52164
26.2. Building an Object Like sysObjDynRadioList.js
53165
---------------------------------------------------
54166

55167
This section explains how to create a dynamic system object similar to
56-
`sysObjDynRadioList.js` in the x0 framework. It focuses on the structure,
57-
methods, and key principles used in `sysObjDynRadioList`.
168+
``sysObjDynRadioList.js`` in the *x0-framework*. It focuses on the structure,
169+
methods, and key principles used in ``sysObjDynRadioList``.
170+
171+
26.2.1. Overview
172+
****************
58173

59-
- Overview
174+
The ``sysObjDynRadioList`` is a **dynamic object** designed to manage a list of
175+
**radio buttons**, with rows that can be added or removed at runtime. Each row
176+
includes a **radio button**, an **input field**, and **associated controls**.
60177

61-
The sysObjDynRadioList is a dynamic object designed to manage a list of radio
62-
buttons, with rows that can be added or removed at runtime. Each row includes a
63-
radio button, an input field, and associated controls.
178+
26.2.2. Key Components
179+
**********************
64180

65-
- Key Components:
181+
1. Base Object Inheritance:
182+
Inherits from ``sysBaseObject`` for core functionality.
183+
2. Dynamic Rows:
184+
Rows are represented by ``sysObjDynRadioListRow``, which also inherits from ``sysBaseObject``.
185+
3. Callbacks and Events:
186+
Used for adding/removing rows and handling user interactions.
187+
4. JSON Configuration:
188+
Utilized for defining object attributes and styles.
66189

67-
1. Base Object Inheritance: Inherits from sysBaseObject for core functionality.
68-
2. Dynamic Rows: Rows are represented by sysObjDynRadioListRow, which also inherits from sysBaseObject.
69-
3. Callbacks and Events: Used for adding/removing rows and handling user interactions.
70-
4. JSON Configuration: Utilized for defining object attributes and styles.
190+
26.2.3. Step-by-Step Guide
191+
**************************
71192

72-
- Step-by-Step Guide
193+
Following, a Step-by-Step Guide, guiding you through the creation process.
73194

74-
26.2.1. Create the Base Class
195+
26.2.2. Create the Base Class
75196
*****************************
76197

77198
Start by defining your main object, inheriting from sysBaseObject:
@@ -88,7 +209,7 @@ Start by defining your main object, inheriting from sysBaseObject:
88209
// Inherit from sysBaseObject
89210
sysObjDynRadioList.prototype = new sysBaseObject();
90211
91-
26.2.2. Initialize the Object
212+
26.2.3. Initialize the Object
92213
*****************************
93214

94215
Define the init method to set up the object structure and default components:
@@ -120,10 +241,11 @@ Define the init method to set up the object structure and default components:
120241
);
121242
};
122243
123-
26.2.3. Define the Row Class
244+
26.2.4. Define the Row Class
124245
****************************
125246

126-
Each row in the list is represented by sysObjDynRadioListRow. This class manages its elements (radio button, input field, and optional remove button):
247+
Each row in the list is represented by ``sysObjDynRadioListRow``. This class manages its
248+
elements (radio button, input field, and optional remove button):
127249

128250
.. code-block:: javascript
129251
@@ -169,10 +291,10 @@ Each row in the list is represented by sysObjDynRadioListRow. This class manages
169291
}
170292
};
171293
172-
26.2.4. Add Rows Dynamically
294+
26.2.5. Add Rows Dynamically
173295
****************************
174296

175-
The add method in sysObjDynRadioList creates new rows dynamically:
297+
The add method in ``sysObjDynRadioList`` creates new rows dynamically:
176298

177299
.. code-block:: javascript
178300
@@ -201,7 +323,7 @@ The add method in sysObjDynRadioList creates new rows dynamically:
201323
this.renderObject(this.DOMParentID);
202324
};
203325
204-
26.2.5. Handle Row Removal
326+
26.2.6. Handle Row Removal
205327
**************************
206328

207329
The remove method in sysObjDynRadioListRow is used to remove a row:
@@ -220,10 +342,10 @@ In the parent object, the remove method manages the array of rows:
220342
this.RowItems[RowIndex].remove();
221343
};
222344
223-
26.2.6. Define Object Structure
345+
26.2.7. Define Object Structure
224346
*******************************
225347

226-
Use the addObjects method to define the DOM structure for each row:
348+
Use the ``addObjects`` method to define the DOM structure for each row:
227349

228350
.. code-block:: javascript
229351
@@ -269,7 +391,7 @@ Use the addObjects method to define the DOM structure for each row:
269391
sysFactory.setupObjectRefsRecursive(ObjDefs, this);
270392
};
271393
272-
26.2.7. Conclusion
394+
26.2.8. Conclusion
273395
******************
274396

275397
By following this guide, you can create dynamic objects similar to sysObjDynRadioList.js.

doc/dev-oop-classes.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@
88
22.1. sysBaseObject.removeParent
99
--------------------------------
1010

11-
- Purpose
11+
22.1.1. Purpose
12+
***************
1213

1314
The removeParent() method is used to remove an object's parent relationship and its
1415
associated DOM elements. This ensures that the object is detached from its parent both
1516
logically (in the object hierarchy) and visually (in the DOM).
1617

17-
- Method Signature
18+
22.1.2. Method Signature
19+
************************
1820

1921
.. code-block:: javascript
2022
2123
sysBaseObject.prototype.removeParent = function()
2224
23-
- How It Works
25+
22.1.3. How It Works
26+
********************
2427
2528
* DOM Element Removal:
2629
Checks if the DOM element associated with the object exists.
@@ -33,7 +36,8 @@ logically (in the object hierarchy) and visually (in the DOM).
3336
* Error Handling:
3437
Catches and logs any errors that occur during the removal process.
3538
36-
- Usage Example
39+
22.1.4. Usage Example
40+
*********************
3741
3842
Suppose you have a hierarchical structure of objects (e.g., a parent object with multiple children).
3943
If you need to remove a parent object along with its DOM representation, you can call the removeParent() method.
@@ -44,7 +48,8 @@ If you need to remove a parent object along with its DOM representation, you can
4448
const parentObject = sysFactory.getObjectByID('parent-id');
4549
parentObject.removeParent();
4650
47-
- Code Walkthrough
51+
22.1.5. Code Walkthrough
52+
************************
4853
4954
.. code-block:: javascript
5055
@@ -65,7 +70,8 @@ If you need to remove a parent object along with its DOM representation, you can
6570
}
6671
};
6772
68-
- Key Points
73+
22.1.6. Key Points
74+
******************
6975

7076
1. DOM Management:
7177
Ensures that any associated DOM elements are properly removed to avoid memory leaks.
@@ -76,7 +82,8 @@ If you need to remove a parent object along with its DOM representation, you can
7682
3. Error Resilience:
7783
Handles potential errors gracefully, ensuring that the application remains stable.
7884

79-
- When to Use
85+
22.1.7. When to Use
86+
*******************
8087

8188
- Use removeParent() when you need to:
8289
Detach an object and its associated DOM element from the object hierarchy.

0 commit comments

Comments
 (0)