How to use the table/constants.STATUS.DELETED function in table

To help you get started, we’ve selected a few table 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 vtex / react-jsonschema-table / src / reducers / items-reducer.js View on Github external
items.forEach((item, index) => {
        // Get the item from the list and sets the document attibute and changes the document Status to LOADED
        var initialItem = newState.source[index + rowStart]
        initialItem.document = item.document
        initialItem.status = STATUS.LOADED
      })

      return newState
    }

    case types.REMOVE_ITEM: {
      const { rowIndex, schema, lang } = action
      const newState = Object.assign({}, state)
      const documentId = state.source[rowIndex].document.id
      addStaging(newState, documentId, STATUS.DELETED, null, schema, lang)
      addToHistoryChanges(newState, documentId, STATUS.DELETED, null)
      return newState
    }

    case types.DELETE_CHECKED_ITEMS: {
      const newState = Object.assign({}, state)
      newState.checkedItems.slice().reverse().forEach((item, index, ref) => {
        if (newState.staging[item]) {
          delete newState.staging[item]
          const stagingIndex = newState.stagingItems.indexOf(item)
          newState.stagingItems.splice(stagingIndex, 1)
          newState.checkedItems.splice(ref.length - 1 - index, 1)
        } else {
          // To Do: delete document in API (not staged)
        }
      })
github vtex / react-jsonschema-table / src / reducers / items-reducer.js View on Github external
items.forEach((item, index) => {
        // Get the item from the list and sets the document attibute and changes the document Status to LOADED
        var initialItem = newState.source[index + rowStart]
        initialItem.document = item.document
        initialItem.status = STATUS.LOADED
      })

      return newState
    }

    case types.REMOVE_ITEM: {
      const { rowIndex, schema, lang } = action
      const newState = Object.assign({}, state)
      const documentId = state.source[rowIndex].document.id
      addStaging(newState, documentId, STATUS.DELETED, null, schema, lang)
      addToHistoryChanges(newState, documentId, STATUS.DELETED, null)
      return newState
    }

    case types.DELETE_CHECKED_ITEMS: {
      const newState = Object.assign({}, state)
      newState.checkedItems.slice().reverse().forEach((item, index, ref) => {
        if (newState.staging[item]) {
          delete newState.staging[item]
          const stagingIndex = newState.stagingItems.indexOf(item)
          newState.stagingItems.splice(stagingIndex, 1)
          newState.checkedItems.splice(ref.length - 1 - index, 1)
        } else {
          // To Do: delete document in API (not staged)
        }
      })
      return newState
github vtex / react-jsonschema-table / src / reducers / items-reducer.js View on Github external
const newItem = Object.assign(
            {},
            { document: newState.staging[documentId].document },
            {
              status: STATUS.LOADED,
            }
          )
          newState.source.push(newItem)
          delete newState.staging[documentId]
          newState.stagingItems = newState.stagingItems.filter(
            stagingId => stagingId !== documentId
          )
          continue
        }

        if (stagingItem.status === STATUS.DELETED) {
          newState.source = newState.source.filter(
            item => item.document.id !== documentId
          )
          delete newState.staging[documentId]
          newState.stagingItems = newState.stagingItems.filter(
            stagingId => stagingId !== documentId
          )
          continue
        }
      }
      return newState
    }

    case types.COPY_FROM_SELECTED_RANGE: {
      const { changes, schema, lang } = action
      const newState = Object.assign({}, state)