How to use the strapi-helper-plugin.Manager function in strapi-helper-plugin

To help you get started, we’ve selected a few strapi-helper-plugin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / App / reducer.js View on Github external
.updateIn(['modifiedSchema', 'models', ...action.keys.split('.'), 'fields'], list => {
          // Don't do any check if removing the last item of the array
          if (action.index === list.size - 1) {
            return list.delete(action.index);
          }
          const path = action.keys.split('.');
          const modelName = path.length > 2 ? path[2] : path[0];
          const layout = state.getIn(['modifiedSchema', 'layout', modelName, 'attributes']);
          const manager = new Manager(state, list, action.keys, action.index, layout);
          const attrToRemoveInfos = manager.attrToRemoveInfos; // Retrieve the removed item infos
          const arrayOfLastLineElements = manager.arrayOfEndLineElements;
          const isRemovingAFullWidthNode = attrToRemoveInfos.bootstrapCol === 12;
          let newList;

          if (isRemovingAFullWidthNode) { // If removing we need to add the corresponding missing col in the prev line
            const currentNodeLine = findIndex(arrayOfLastLineElements, ['index', attrToRemoveInfos.index]); // Used only to know if removing a full size element on the first line

            if (currentNodeLine === 0) {
              newList = list
                .delete(action.index);
            } else {
              const previousNodeLine = currentNodeLine - 1;
              const firstElementOnLine = previousNodeLine === 0 ? 0 : arrayOfLastLineElements[previousNodeLine - 1].index + 1;
              const lastElementOnLine = arrayOfLastLineElements[previousNodeLine].index + 1;
              const previousLineRangeIndexes = firstElementOnLine === lastElementOnLine ? [firstElementOnLine] : range(firstElementOnLine, lastElementOnLine);
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / App / reducer.js View on Github external
.updateIn(['modifiedSchema', 'models', ...action.keys.split('.'), 'fields'], list => {
          const draggedItemName = state.get('draggedItemName');
          const draggedItemIndex = list.indexOf(draggedItemName);
          const path = action.keys.split('.');
          const modelName = path.length > 2 ? path[2] : path[0];
          const layout = state.getIn(['modifiedSchema', 'layout', modelName, 'attributes']);
          const manager = new Manager(state, list, action.keys, draggedItemIndex, layout);
          const arrayOfLastLineElements = manager.arrayOfEndLineElements;
          const itemInfos = manager.getAttrInfos(draggedItemIndex);
          const isFullSize = itemInfos.bootstrapCol === 12;
          const dropLineBounds = { left: manager.getBound(false, action.hoverIndex), right: manager.getBound(true, action.hoverIndex) };
          const hasMoved = state.get('hasMoved'); // Used only for non full-width elements

          if (isFullSize && draggedItemIndex !== -1) {
            const upwards = action.dragIndex > action.hoverIndex;
            const indexToDrop = upwards ? get(dropLineBounds, 'left.index', 0) : get(dropLineBounds, 'right.index', list.size -1);
            updateHoverIndex = false;
            shouldUpdateListOnDrop = false;

            return list
              .delete(draggedItemIndex)
              .insert(indexToDrop, draggedItemName);
          }
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / App / reducer.js View on Github external
.updateIn(['modifiedSchema', 'models', ...action.keys.split('.'), 'fields'], list => {
          const manager = new Manager(state, list, action.keys, 0, layout);
          const newList = manager.getLayout();
          updatedList = reorderList(manager, newList);

          return newList;
        })
        .update('grid', () => {
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / App / helpers.js View on Github external
const createManager = (obj, array, keys, dropIndex, layout) =>
  new Manager(stateUpdater(obj, array, keys), array, keys, dropIndex, layout);
github strapi / strapi / packages / strapi-plugin-content-manager / admin / src / containers / App / reducer.js View on Github external
.update('grid', () => {
          const fields = updatedList;
          const lines = getLines(new Manager(state, fields, action.keys, 0, layout), fields);

          return List(lines);
        });
    }