Implements move, copy and delete item, and delete section functionality

This commit is contained in:
Alicia Sykes
2021-10-25 19:11:13 +01:00
parent f398a374e7
commit 31e172befb
10 changed files with 75 additions and 15 deletions

View File

@@ -30,7 +30,7 @@ export const sanitize = (string) => {
const makeItemId = (sectionStr, itemStr, index) => {
const charSum = sectionStr.split('').map((a) => a.charCodeAt(0)).reduce((x, y) => x + y);
const itemTitleStr = itemStr.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase();
return `${index}_${charSum}_${itemTitleStr}_${Math.random()}`;
return `${index}_${charSum}_${itemTitleStr}}`;
};
/* Given an array of sections, apply a unique ID to each item, and return modified array */

View File

@@ -9,7 +9,9 @@ const KEY_NAMES = [
'UPDATE_PAGE_INFO',
'UPDATE_APP_CONFIG',
'UPDATE_SECTION',
'REMOVE_SECTION',
'COPY_ITEM',
'REMOVE_ITEM',
];
// Convert array of key names into an object, and export