- added stats to dashboard;
- improved form builder;
This commit is contained in:
@@ -2,6 +2,7 @@ import React, { useRef } from 'react'
|
||||
import { useDrag } from 'react-dnd'
|
||||
import { ItemTypes } from '../ItemTypes';
|
||||
import uniqid from '../../../../helpers/uniqid';
|
||||
import { storeSet } from '../../../../store';
|
||||
|
||||
|
||||
const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
|
||||
@@ -10,12 +11,20 @@ const BuilderElementItem = ({ dbId, name, label, description = '' }) => {
|
||||
const [{ isDragging }, drag] = useDrag(() => ({
|
||||
type: ItemTypes.FIELD,
|
||||
item: () => {
|
||||
return { name, dbId, id: uniqid(), index: -1 }
|
||||
const newId = uniqid();
|
||||
storeSet.main.draggingElementId(newId);
|
||||
return { name, dbId, id: newId, index: -1 }
|
||||
},
|
||||
end: (item, monitor) => {
|
||||
const dropResult = monitor.getDropResult()
|
||||
if (item && dropResult) {
|
||||
return item;
|
||||
|
||||
if (monitor.didDrop()) {
|
||||
if (item && dropResult) {
|
||||
return item;
|
||||
}
|
||||
} else {
|
||||
storeSet.main.removeElement(item.id);
|
||||
storeSet.main.draggingElementId(0);
|
||||
}
|
||||
},
|
||||
collect: (monitor) => ({
|
||||
|
||||
Reference in New Issue
Block a user