Skip to content
Snippets Groups Projects
Commit 061545f2 authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Intégration jquery UI + jequery nestedSortable. Modification des blocs des...

Intégration jquery UI + jequery nestedSortable. Modification des blocs des entrées pour pouvoir les déplacer
parent 135e3bb0
No related branches found
No related tags found
No related merge requests found
...@@ -337,4 +337,9 @@ table.label-table > tbody > tr > td { ...@@ -337,4 +337,9 @@ table.label-table > tbody > tr > td {
display: inline; display: inline;
vertical-align: baseline; vertical-align: baseline;
color: inherit; color: inherit;
}
ol {
list-style-type: none;
padding-left: 0;
} }
\ No newline at end of file
This diff is collapsed.
...@@ -115,7 +115,7 @@ class WiktionaryManager ...@@ -115,7 +115,7 @@ class WiktionaryManager
$posData = $pos[$word]; $posData = $pos[$word];
$item = []; $item = [];
$item['Id'] = $pos['id']; $item['id'] = $pos['id'];
$item['PartOfSpeech'] = $posData['pos']; $item['PartOfSpeech'] = $posData['pos'];
$morphologicalLabels[] = $posData['pos']; $morphologicalLabels[] = $posData['pos'];
......
...@@ -17,12 +17,14 @@ ...@@ -17,12 +17,14 @@
{% block javascripts %} {% block javascripts %}
{{ encore_entry_script_tags('app') }} {{ encore_entry_script_tags('app') }}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.1/dist/js/bootstrap.bundle.min.js" integrity="sha384-u1OknCvxWvY5kfmNBILK2hRnQC3Pr17a+RTT6rIHI7NnikvbZlHgTPOOmMi466C8" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script></head> <script src="https://code.jquery.com/jquery-3.7.0.min.js" integrity="sha256-2Pmvv0kuTBOenSvLm6bvfBSSHrUJ+3A7x6P5Ebd07/g=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
{% include "js_translations.html.twig" %} {% include "js_translations.html.twig" %}
<script src="{{ asset('assets/js/jquery.mjs.nestedSortable.js') }}"></script>
<script src="{{ asset('assets/js/app.js') }}"></script> <script src="{{ asset('assets/js/app.js') }}"></script>
{% endblock %} {% endblock %}
</head>
<body {% if app.environment|upper == 'DEV' %}class="bg-dark-gray"{% endif %}> <body {% if app.environment|upper == 'DEV' %}class="bg-dark-gray"{% endif %}>
{% block nav %} {% block nav %}
......
...@@ -8,77 +8,114 @@ ...@@ -8,77 +8,114 @@
{% endif %} {% endif %}
</h1> </h1>
<h4> <div>
{{ "Pronunciations"|trans }}
{{ _self.actions(entry, '[Items][0][Sense]', ['add'], "Ajouter une prononciation", 'Pronunciations') }}
</h4>
<div class="ms-1 ps-4 mb-2">
{% for key, pronunciation in entry_manager.pronunciations(entry) %}
{### PRONUNCIATION ######### SET KEY ##########}
<span class="links-container">
{% set pronunciationKey = '[Items][0][Sense][Pronunciations]['~key~']' %}
{% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %}
{{ pronunciation.api }}
{{ _self.actions(entry, pronunciationKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, pronunciationKey, ['edit', 'delete'], '', 'Pronunciations') }}
<br>
{{ _self.comments(entry, pronunciation, pronunciationKey) }}
</span>
{% endfor %}
</div>
{% set attr = entry.attributes %}
{% for key, item in attr.Items %}
{### POS ######### SET KEY ##########}
{% set itemKey = '[Items]['~key~']' %}
<h4> <h4>
{{ item.PartOfSpeech|trans }} {{ "Pronunciations"|trans }}
{{ _self.actions(entry, itemKey~'[Sense]', ['add'], "Ajouter une définition à cette nature", 'Definitions') }} {{ _self.actions(entry, '[Items][0][Sense]', ['add'], "Ajouter une prononciation", 'Pronunciations') }}
{{ _self.actions(entry, itemKey, ['delete'], '', 'Definitions') }}
</h4> </h4>
</div>
<div class="ms-1 ps-4 mb-2">
<ol class="sortable">
{% for key, pronunciation in entry_manager.pronunciations(entry) %}
{### PRONUNCIATION ######### SET KEY ##########}
<li id="{{ pronunciation.id }}">
<div class="links-container">
{% set pronunciationKey = '[Items][0][Sense][Pronunciations]['~key~']' %}
{% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %}
{{ pronunciation.api }}
{{ _self.actions(entry, pronunciationKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, pronunciationKey, ['edit', 'delete'], '', 'Pronunciations') }}
<br>
{{ _self.comments(entry, pronunciation, pronunciationKey) }}
</div>
</li>
{% endfor %}
</ol>
</div>
<div class="ms-1 ps-4 left-border-blue bg-light-grey">
{% for key, definition in item.Sense.Definitions %}
{### DEFINITIONS ######### SET KEY ##########}
{% set definitionKey = itemKey~'[Sense][Definitions]['~key~']' %}
<div class="mb-3"> <ol class="sortable">
{% set attr = entry.attributes %}
{% for key, item in attr.Items %}
{### POS ######### SET KEY ##########}
{% set itemKey = '[Items]['~key~']' %}
<p class="fw-bold"> <li id="{{ item.id }}">
{{ loop.index }}. {{ definition.Def }}
{{ _self.actions(entry, definitionKey, ['add'], "Ajouter un exemple à cette définition", 'Examples') }}
{{ _self.actions(entry, definitionKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, definitionKey, ['edit', 'delete'], '', 'Definitions') }}
</p>
{{ _self.comments(entry, definition, definitionKey) }} <div>
<h4>
{{ item.PartOfSpeech|trans }}
{{ _self.actions(entry, itemKey~'[Sense]', ['add'], "Ajouter une définition à cette nature", 'Definitions') }}
{{ _self.actions(entry, itemKey, ['delete'], '', 'Definitions') }}
</h4>
</div>
<div class="ms-3"> <ol class="ms-1 ps-4 left-border-blue bg-light-grey">
{% for key, example in definition.Examples|default([]) %}
{### EXEMPLES ######### SET KEY ##########} {% for key, definition in item.Sense.Definitions %}
{% set exampleKey = definitionKey~'[Examples]['~key~']' %} {### DEFINITIONS ######### SET KEY ##########}
{% set definitionKey = itemKey~'[Sense][Definitions]['~key~']' %}
<li id="{{ definition.id }}" class="mb-3">
<div>
<p class="fw-bold">
{{ loop.index }}. {{ definition.Def }}
{{ _self.actions(entry, definitionKey, ['add'], "Ajouter un exemple à cette définition", 'Examples') }}
{{ _self.actions(entry, definitionKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, definitionKey, ['edit', 'delete'], '', 'Definitions') }}
</p>
{{ _self.comments(entry, definition, definitionKey) }}
</div>
<ol class="ms-3">
{% for key, example in definition.Examples|default([]) %}
{### EXEMPLES ######### SET KEY ##########}
{% set exampleKey = definitionKey~'[Examples]['~key~']' %}
<li id="{{ example.id }}">
<div>
<p class="fst-italic">
{{ example.example }}
{{ _self.actions(entry, exampleKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, exampleKey, ['edit', 'delete'], "", 'Examples') }}
</p>
{{ _self.comments(entry, example, exampleKey) }}
</div>
</li>
{% endfor %}
</ol>
</li>
{% endfor %}
</ol>
</li>
{% endfor %}
</ol>
<p class="fst-italic"> <button id="serialize">Serialize</button>
{{ example.example }} </div>
{{ _self.actions(entry, exampleKey, ['comment'], "", 'Comments') }}
{{ _self.actions(entry, exampleKey, ['edit', 'delete'], "", 'Examples') }}
</p>
{{ _self.comments(entry, example, exampleKey) }} <script>
{% endfor %} $(document).ready(function(){
</div>
</div> $('.sortable').nestedSortable({
{% endfor %} handle: 'div',
</div> items: 'li',
toleranceElement: '> div',
disableParentChange: true
});
{% endfor %} $("#serialize").click(function(e) {
e.preventDefault();console.log($('ol.sortable').nestedSortable('serialize'));
// $("#output").text($('ol.sortable').nestedSortable('serialize'));
});
</div> });
</script>
{% macro comments(entry, parent, parentKey) %} {% macro comments(entry, parent, parentKey) %}
{% for key, comment in parent.Comments|default([]) %} {% for key, comment in parent.Comments|default([]) %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment