Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
})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 newStateconst 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)