presentation and tutorial enhancements

This commit is contained in:
Eric Espie
2021-10-08 16:34:26 +02:00
parent 43150860c4
commit c4ef26f92a
13 changed files with 142 additions and 8 deletions

View File

@@ -77,8 +77,28 @@
<section id="twig-base-presentation">
<h1>Twig Base Presentation<a class="headerlink" href="#twig-base-presentation" title="Permalink to this headline"></a></h1>
<p>This feature is intended to help extension creators to design forms in a <em>modern</em> way.</p>
<p>The <strong>Twig Base</strong> feature is based on MVC structure:</p>
<img alt="../_images/MVC.png" src="../_images/MVC.png" />
<p>When creating an extension following this structure, some parts have to be done:</p>
<dl class="field-list simple">
<dt class="field-odd">Model</dt>
<dd class="field-odd"><p>Optional part to define the specific data model for the extension</p>
</dd>
<dt class="field-even">Service</dt>
<dd class="field-even"><p>Recommended part to produce the data to be displayed</p>
</dd>
<dt class="field-odd">Controller</dt>
<dd class="field-odd"><p>Mandatory part to gather the data from the <em>Service</em> and display using the <em>View</em>.
The <em>Controller</em> contains an automatic routing mechanism to be selected by the <em>operation</em> parameter.</p>
</dd>
<dt class="field-even">View</dt>
<dd class="field-even"><p>Mandatory part to display the data given by the <em>Controller</em></p>
</dd>
<dt class="field-odd">End point</dt>
<dd class="field-odd"><p>Mandatory part receiving the request and calling the <em>Controller</em></p>
</dd>
</dl>
</section>

View File

@@ -144,7 +144,7 @@ The name of the method is built from the operation name by adding <em>Operation<
<div class="code-block-caption"><span class="caption-text">index.php</span><a class="headerlink" href="#id4" title="Permalink to this code"></a></div>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="linenos"> 1</span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="linenos"> 2</span>
<span class="linenos"> 3</span><span class="k">namespace</span> <span class="nx">MyCompany\iTop\SystemInformation</span><span class="p">;</span>
<span class="linenos"> 3</span><span class="k">namespace</span> <span class="nx">MyCompany\iTop\MyModule</span><span class="p">;</span>
<span class="linenos"> 4</span>
<span class="linenos"> 5</span><span class="k">use</span> <span class="nx">MyCompany\iTop\MyModule\Controller\MyModuleController</span><span class="p">;</span>
<span class="linenos"> 6</span>
@@ -165,6 +165,25 @@ The method <code class="docutils literal notranslate"><span class="pre">HandleOp
<p>For more comfort during the development of your module, you can <a class="reference external" href="https://www.itophub.io/wiki/page?id=latest%3Acustomization%3Adatamodel#installing_the_toolkit">install the toolkit</a> and update your iTop with symlinks.</p>
<p>if you go to your module page <code class="docutils literal notranslate"><span class="pre">https://localhost/itop/pages/exec.php?exec_module=my-module&amp;exec_page=index.php</span></code> you should see:</p>
<img alt="../../_images/Step2.png" src="../../_images/Step2.png" />
<p>You will notice that if you work with an iTop from an official package (not the sources from <code class="docutils literal notranslate"><span class="pre">https://github.com/Combodo/iTop</span></code>, when you modify the twig template, the result does not change.</p>
<p>In this case, youll have to add the following parameter to your iTop configuration:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="o">&lt;?</span><span class="nx">php</span>
<span class="sd">/**</span>
<span class="sd"> *</span>
<span class="sd"> * Configuration file, generated by the iTop configuration wizard</span>
<span class="sd"> *</span>
<span class="sd"> * The file is used in MetaModel::LoadConfig() which does all the necessary initialization job</span>
<span class="sd"> *</span>
<span class="sd"> */</span>
<span class="nv">$MySettings</span> <span class="o">=</span> <span class="k">array</span><span class="p">(</span>
<span class="c1">// developer_mode.enabled: If true then unlocks dev env functionalities, see \utils::IsDevelopmentEnvironment</span>
<span class="s1">&#39;developer_mode.enabled&#39;</span> <span class="o">=&gt;</span> <span class="k">true</span><span class="p">,</span>
<span class="c1">// ...</span>
<span class="p">);</span>
</pre></div>
</div>
</section>
</section>

View File

@@ -128,6 +128,7 @@
</pre></div>
</div>
</div>
<p><em>Disclaimer: The code is for tutorial only, dont use it in production as no check is done on the entries</em></p>
<p>The corresponding template must be created <code class="docutils literal notranslate"><span class="pre">templates/SelectMonth.html.twig</span></code></p>
<div class="literal-block-wrapper docutils container" id="id3">
<div class="code-block-caption"><span class="caption-text">templates/SelectMonth.html.twig</span><a class="headerlink" href="#id3" title="Permalink to this code"></a></div>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -4,6 +4,26 @@
Twig Base Presentation
======================
This feature is intended to help extension creators to design forms in a *modern* way.
The **Twig Base** feature is based on MVC structure:
.. image:: MVC.png
.. image:: MVC.png
When creating an extension following this structure, some parts have to be done:
:Model:
Optional part to define the specific data model for the extension
:Service:
Recommended part to produce the data to be displayed
:Controller:
Mandatory part to gather the data from the *Service* and display using the *View*.
The *Controller* contains an automatic routing mechanism to be selected by the *operation* parameter.
:View:
Mandatory part to display the data given by the *Controller*
:End point:
Mandatory part receiving the request and calling the *Controller*

View File

@@ -72,7 +72,7 @@ Then create landing page for your module ``my-module/index.php``
<?php
namespace MyCompany\iTop\SystemInformation;
namespace MyCompany\iTop\MyModule;
use MyCompany\iTop\MyModule\Controller\MyModuleController;
@@ -96,4 +96,29 @@ For more comfort during the development of your module, you can `install the too
if you go to your module page ``https://localhost/itop/pages/exec.php?exec_module=my-module&exec_page=index.php`` you should see:
.. image:: Step2.png
.. image:: Step2.png
You will notice that if you work with an iTop from an official package (not the sources from ``https://github.com/Combodo/iTop``, when you modify the twig template, the result does not change.
In this case, you'll have to add the following parameter to your iTop configuration:
.. code-block:: php
<?php
/**
*
* Configuration file, generated by the iTop configuration wizard
*
* The file is used in MetaModel::LoadConfig() which does all the necessary initialization job
*
*/
$MySettings = array(
// developer_mode.enabled: If true then unlocks dev env functionalities, see \utils::IsDevelopmentEnvironment
'developer_mode.enabled' => true,
// ...
);

View File

@@ -56,6 +56,8 @@ Now add the operation in the controller:
}
}
*Disclaimer: The code is for tutorial only, don't use it in production as no check is done on the entries*
The corresponding template must be created ``templates/SelectMonth.html.twig``
.. code-block:: twig

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

@@ -4,6 +4,26 @@
Twig Base Presentation
======================
This feature is intended to help extension creators to design forms in a *modern* way.
The **Twig Base** feature is based on MVC structure:
.. image:: MVC.png
.. image:: MVC.png
When creating an extension following this structure, some parts have to be done:
:Model:
Optional part to define the specific data model for the extension
:Service:
Recommended part to produce the data to be displayed
:Controller:
Mandatory part to gather the data from the *Service* and display using the *View*.
The *Controller* contains an automatic routing mechanism to be selected by the *operation* parameter.
:View:
Mandatory part to display the data given by the *Controller*
:End point:
Mandatory part receiving the request and calling the *Controller*

Binary file not shown.

View File

@@ -72,7 +72,7 @@ Then create landing page for your module ``my-module/index.php``
<?php
namespace MyCompany\iTop\SystemInformation;
namespace MyCompany\iTop\MyModule;
use MyCompany\iTop\MyModule\Controller\MyModuleController;
@@ -96,4 +96,29 @@ For more comfort during the development of your module, you can `install the too
if you go to your module page ``https://localhost/itop/pages/exec.php?exec_module=my-module&exec_page=index.php`` you should see:
.. image:: Step2.png
.. image:: Step2.png
You will notice that if you work with an iTop from an official package (not the sources from ``https://github.com/Combodo/iTop``, when you modify the twig template, the result does not change.
In this case, you'll have to add the following parameter to your iTop configuration:
.. code-block:: php
<?php
/**
*
* Configuration file, generated by the iTop configuration wizard
*
* The file is used in MetaModel::LoadConfig() which does all the necessary initialization job
*
*/
$MySettings = array(
// developer_mode.enabled: If true then unlocks dev env functionalities, see \utils::IsDevelopmentEnvironment
'developer_mode.enabled' => true,
// ...
);

View File

@@ -56,6 +56,8 @@ Now add the operation in the controller:
}
}
*Disclaimer: The code is for tutorial only, don't use it in production as no check is done on the entries*
The corresponding template must be created ``templates/SelectMonth.html.twig``
.. code-block:: twig