.. *******************************************************************************
* MetaFactory.io R2
* Technical Documentation
*
* File name : H2DragAndDrop.rst
* Created by : Ralph Oudejans
* Last update : 02-03-2021
* Updated by : Niels de Nies
*
* MetaFactory BV Amsterdam
*******************************************************************************
.. include:: /inline-images.txt
Drag & Drop
===========
.. admonition:: Internal use
|Internal M| This topic is intended for MetaFactory developers only
.. rubric:: Steps to implement the feature
Drag & Drop of an item in a list involves a dragable object (e.g. 'Subtask') and a reference to a parent object (e.g. 'Task').
In order to implement this feature take the following steps:
#. Add metadata to the draggable object to mark it orderable within a certain reference (e.g. reference 'task' )
.. code-block:: xml
:caption: model.xml
:name: model.xml01
:linenos:
:emphasize-lines: 4
|Exclam M| In the metadata you need to specify the `name` of a `reference`, **not** the name of an object.
#. Add an attribute `sortOrder` to the draggable object (here object `Subtask`)
.. code-block:: xml
:caption: model.xml
:name: model.xml02
:linenos:
:emphasize-lines: 6,7,8,9,10,11
#. Add metadata to the reference to create a finder (e.g. `findByTask`)
.. code-block:: xml
:caption: model.xml
:name: model.xml03
:linenos:
:emphasize-lines: 16
#. Generate the application
#. Create a `changeSet` in the Liquibase alters changelog to add the column to the table of the draggable object.
Set a default value of 0 as the sort_order is required and must not be null.
On the entity the default value becomes Integer.MAX_VALUE, however this is not supported by SQL. 0 is fine to start with.
.. code-block:: xml
:caption: [projectdir]\\[backenddir]\\src\\main\\resources\\config\\liquibase\\liquibase-alters-changeLog.xml
:name: liquibase-alters-changeLog.xml
:linenos:
:emphasize-lines: 3,4,5,6,7,8,9
<<<<<<< HEAD
=======
>>>>>>> 64e54eae0b2fb05be64238bd915b09495d6b5888
|Glasses M| Read more about :ref:`Liquibase change sets `
#. Run the application.
.. Demonstration
.. -------------
.. Demonstration of the feature can be found here.
.. .. todo::
.. Insert a link to the page in the Showcase application that demonstrates the Drag & Drop feature.