mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-17 06:18:44 +02:00
poc form SDK (change dependencies implementation)
This commit is contained in:
10
js/DI/app.js
10
js/DI/app.js
@@ -27,15 +27,19 @@ const App = function(){
|
||||
$(aSelectors.darkModeButton).toggleClass('active', true);
|
||||
}
|
||||
|
||||
const tooltips = document.querySelectorAll("[data-bs-toggle='tooltip']");
|
||||
handleTooltips(document);
|
||||
}
|
||||
|
||||
function handleTooltips(oElement){
|
||||
const tooltips = oElement.querySelectorAll("[data-bs-toggle='tooltip']");
|
||||
tooltips.forEach((el) => {
|
||||
new bootstrap.Tooltip(el);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
init
|
||||
init,
|
||||
handleTooltips
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ const Collection = function(oForm, objectFormUrl, objectSaveUrl){
|
||||
oModalBody[0].querySelectorAll('form').forEach((formEl) => {
|
||||
oForm.handleElement(formEl);
|
||||
handleElement(formEl);
|
||||
oApp.handleTooltips(formEl);
|
||||
});
|
||||
})
|
||||
.catch(function (error) {
|
||||
|
||||
@@ -9,7 +9,6 @@ use Exception;
|
||||
use MetaModel;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -168,7 +167,7 @@ class ObjectController extends AbstractController
|
||||
|
||||
// return object form
|
||||
return new JsonResponse([
|
||||
'template' => $this->renderView('DI/form.html.twig', [
|
||||
'template' => $this->renderView('DI/form/form.html.twig', [
|
||||
'id' => $id,
|
||||
'class' => $class,
|
||||
'form' => $oForm->createView(),
|
||||
@@ -229,6 +228,7 @@ class ObjectController extends AbstractController
|
||||
|
||||
// return object form
|
||||
return new JsonResponse([
|
||||
'succeeded' => true,
|
||||
'template' => $this->renderView('DI/form.html.twig', [
|
||||
'id' => $id,
|
||||
'class' => $class,
|
||||
@@ -239,11 +239,7 @@ class ObjectController extends AbstractController
|
||||
|
||||
// return object form
|
||||
return new JsonResponse([
|
||||
'template' => $this->renderView('DI/form.html.twig', [
|
||||
'id' => $id,
|
||||
'class' => $class,
|
||||
'form' => $oForm->createView(),
|
||||
])
|
||||
'succeeded' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -282,7 +278,7 @@ class ObjectController extends AbstractController
|
||||
]);
|
||||
|
||||
// return object form
|
||||
return $this->renderForm('DI/form.html.twig', [
|
||||
return $this->renderForm('DI/form/form.html.twig', [
|
||||
'form' => $oForm,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
{% block body %}
|
||||
|
||||
<div>
|
||||
{% form_theme form 'DI/form/configuration_theme.html.twig' %}
|
||||
{% form_theme form 'DI/form/theme/configuration_theme.html.twig' %}
|
||||
{{ form(form) }}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
{{ form(form) }}
|
||||
1
templates/DI/form/form.html.twig
Normal file
1
templates/DI/form/form.html.twig
Normal file
@@ -0,0 +1 @@
|
||||
{{ form(form) }}
|
||||
@@ -1,15 +1,28 @@
|
||||
|
||||
{# navbar #}
|
||||
<nav class="navbar navbar-expand-lg fixed-top bg-body-tertiary">
|
||||
|
||||
{# container #}
|
||||
<div class="container-fluid">
|
||||
|
||||
{# brand #}
|
||||
<a class="navbar-brand" href="#"><img class="app_icon" src="{{ asset_image('DI/flask-solid.svg') }}" width="24px"> Forms SDK</a>
|
||||
|
||||
{# toggler #}
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
{# menu #}
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
|
||||
{# home #}
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="{{ path('home') }}">Home</a>
|
||||
</li>
|
||||
|
||||
{# edit object... #}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
Edit Object
|
||||
@@ -21,6 +34,8 @@
|
||||
<li><a class="dropdown-item" href="{{ path('object_edit', {'class': 'UserRequest', 'id': 1}) }}">UserRequest</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{# new object... #}
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
New Object
|
||||
@@ -32,26 +47,36 @@
|
||||
<li><a class="dropdown-item" href="{{ path('object_edit', {'class': 'UserRequest', 'id': 0}) }}">UserRequest</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
{# edit configuration #}
|
||||
<li class="nav-item">
|
||||
<a href="{{ path('configuration_edit') }}" class="nav-link">Edit Configuration</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
{# theme dark/light #}
|
||||
<div>
|
||||
<button id="dark_mode" type="button" class="btn" role="button" data-bs-toggle="button" aria-pressed="false"><i class="fa-solid fa-moon text-warning"></i></button>
|
||||
</div>
|
||||
{% if aAction is defined %}
|
||||
<form class="actions d-flex">
|
||||
{% for button in aAction|sort((a, b) => a.rank <=> b.rank ) %}
|
||||
{% if button.type == 'link' %}
|
||||
<a href="{{ button.href }}" class="btn {% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn {% if button.disabled is defined and button.disabled %} disabled {% endif %}"><i class="{{ button.icon }}"></i>{% if button.label is defined %} {{ button.label }}{% endif %}</a>
|
||||
{% elseif button.type == 'reset' %}
|
||||
<button type="reset" class="{% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn" form="{{ button.form }}">{{ button.label }}</button>
|
||||
{% elseif button.type == 'submit' %}
|
||||
<button type="submit" class="{% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn" form="{{ button.form }}">{{ button.label }}</button>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
|
||||
{# actions #}
|
||||
{% if aPageAction is defined %}
|
||||
<form class="actions d-flex">
|
||||
{% for button in aPageAction|sort((a, b) => a.rank <=> b.rank ) %}
|
||||
{% if button.type == 'link' %}
|
||||
<a href="{{ button.href }}" class="btn {% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn {% if button.disabled is defined and button.disabled == true %} disabled {% endif %}"><i class="{{ button.icon }}"></i>{% if button.label is defined %} {{ button.label }}{% endif %}</a>
|
||||
{% elseif button.type == 'reset' %}
|
||||
<button type="reset" class="{% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn" form="{{ button.form }}">{{ button.label }}</button>
|
||||
{% elseif button.type == 'submit' %}
|
||||
<button type="submit" class="{% if button.primary is defined and button.primary %}btn-primary{% else %}btn-secondary{% endif %} btn" form="{{ button.form }}">{{ button.label }}</button>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</nav>
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "DI/base.html.twig" %}
|
||||
|
||||
{% set aAction = {
|
||||
{% set aPageAction = {
|
||||
reset: {
|
||||
rank: 2,
|
||||
type: 'reset',
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
{% if id != 0 %}
|
||||
|
||||
{% set aAction = aAction|merge({
|
||||
{% set aPageAction = aPageAction|merge({
|
||||
previous: {
|
||||
rank: 0,
|
||||
type: 'link',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% extends "DI/base.html.twig" %}
|
||||
|
||||
{% set aAction = {
|
||||
{# page actions #}
|
||||
{% set aPageAction = {
|
||||
previous: {
|
||||
rank: 0,
|
||||
type: 'link',
|
||||
@@ -11,9 +12,8 @@
|
||||
next: {
|
||||
rank: 1,
|
||||
type: 'link',
|
||||
disabled: id <= 1,
|
||||
href: path('object_view', {'class': class, 'id': id + 1}),
|
||||
icon: 'fa-solid fa-arrow-left'
|
||||
icon: 'fa-solid fa-arrow-right'
|
||||
},
|
||||
edit: {
|
||||
rank: 2,
|
||||
@@ -33,7 +33,7 @@
|
||||
{% block body %}
|
||||
|
||||
<div>
|
||||
<div class="text-center"><h3>{{ object.GetName() }}</h3></div>
|
||||
<div class="text-center h3">{{ object.GetName() }}</div>
|
||||
{% for key,value in object.GetValues() %}
|
||||
<div class="d-flex offset-4 col-4">
|
||||
<div class="flex-grow-1 fw-bold">{{ key|replace({'_' : ' '}) }}</div>
|
||||
|
||||
Reference in New Issue
Block a user