From 2422e679f855f4055805afbac74461653df9ce08 Mon Sep 17 00:00:00 2001
From: Roman Derlemenko <romanderlemenko@gmail.com>
Date: Sun, 25 Apr 2021 12:04:58 +0300
Subject: [PATCH] [WIP][TASK] NL-3241 Add manual sorting

---
 Classes/Domain/Model/MenuItemContent.php      | 19 -------------------
 Classes/Domain/Model/MenuItemLink.php         | 19 -------------------
 Classes/Domain/Model/MenuItemPage.php         | 19 -------------------
 .../tx_nlmenubuilder_domain_model_menu.php    | 12 +++++++++---
 ext_tables.sql                                |  1 +
 5 files changed, 10 insertions(+), 60 deletions(-)
 delete mode 100644 Classes/Domain/Model/MenuItemContent.php
 delete mode 100644 Classes/Domain/Model/MenuItemLink.php
 delete mode 100644 Classes/Domain/Model/MenuItemPage.php

diff --git a/Classes/Domain/Model/MenuItemContent.php b/Classes/Domain/Model/MenuItemContent.php
deleted file mode 100644
index 06f0c2e..0000000
--- a/Classes/Domain/Model/MenuItemContent.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace NL\NlMenubuilder\Domain\Model;
-
-/**
- * MenuItem
- */
-class MenuItemContent extends MenuItem
-{
-    public const TYPE = 2;
-
-    /**
-     * Type of the menu item
-     *
-     * @var int
-     * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
-     */
-    protected $type = self::TYPE;
-}
diff --git a/Classes/Domain/Model/MenuItemLink.php b/Classes/Domain/Model/MenuItemLink.php
deleted file mode 100644
index 0051416..0000000
--- a/Classes/Domain/Model/MenuItemLink.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace NL\NlMenubuilder\Domain\Model;
-
-/**
- * MenuItem
- */
-class MenuItemLink extends MenuItem
-{
-    public const TYPE = 1;
-
-    /**
-     * Type of the menu item
-     *
-     * @var int
-     * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
-     */
-    protected $type = self::TYPE;
-}
diff --git a/Classes/Domain/Model/MenuItemPage.php b/Classes/Domain/Model/MenuItemPage.php
deleted file mode 100644
index b3618ae..0000000
--- a/Classes/Domain/Model/MenuItemPage.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace NL\NlMenubuilder\Domain\Model;
-
-/**
- * MenuItem
- */
-class MenuItemPage extends MenuItem
-{
-    public const TYPE = 0;
-
-    /**
-     * Type of the menu item
-     *
-     * @var int
-     * @TYPO3\CMS\Extbase\Annotation\Validate("NotEmpty")
-     */
-    protected $type = self::TYPE;
-}
diff --git a/Configuration/TCA/tx_nlmenubuilder_domain_model_menu.php b/Configuration/TCA/tx_nlmenubuilder_domain_model_menu.php
index 6c4245e..18be5c4 100644
--- a/Configuration/TCA/tx_nlmenubuilder_domain_model_menu.php
+++ b/Configuration/TCA/tx_nlmenubuilder_domain_model_menu.php
@@ -140,21 +140,27 @@ return [
 
         ],
         'menu_item' => [
-            'exclude' => false,
+            'exclude' => true,
             'label' => 'LLL:EXT:nl_menubuilder/Resources/Private/Language/locallang_db.xlf:tx_nlmenubuilder_domain_model_menu.menu_item',
             'config' => [
                 'type' => 'inline',
+                'allowed' => 'menuitem',
                 'foreign_table' => 'tx_nlmenubuilder_domain_model_menuitem',
+                'foreign_sortby' => 'sorting',
                 'foreign_field' => 'menu',
                 'minitems' => 0,
                 'maxitems' => 99,
                 'appearance' => [
                     'collapseAll' => true,
                     'expandSingle' => true,
-                    'levelLinksPosition' => 'top',
+                    'levelLinksPosition' => 'bottom',
+                    'useSortable' => true,
                     'showSynchronizationLink' => 1,
                     'showPossibleLocalizationRecords' => 1,
-                    'showAllLocalizationLink' => 1
+                    'showAllLocalizationLink' => 1,
+                    'enabledControls' => [
+                        'info' => false,
+                    ]
                 ],
             ],
 
diff --git a/ext_tables.sql b/ext_tables.sql
index bdbd919..58dd4a3 100644
--- a/ext_tables.sql
+++ b/ext_tables.sql
@@ -27,6 +27,7 @@ CREATE TABLE tx_nlmenubuilder_domain_model_menuitem (
 
 	menu int(11) unsigned DEFAULT '0' NOT NULL,
 
+    sorting int(11) NOT NULL DEFAULT '0',
 	type int(11) DEFAULT '0' NOT NULL,
 	title varchar(255) DEFAULT '' NOT NULL,
 	subtitle varchar(255) DEFAULT '' NOT NULL,
-- 
GitLab