From c392faebe4b8659073634813a66c3765efdff6ef Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Fri, 27 Dec 2024 18:39:32 +0530 Subject: [PATCH 1/6] Creating View Trash option --- index.html | 9 +++ js/activity.js | 171 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 180 insertions(+) diff --git a/index.html b/index.html index aea8f6d80a..4f28df23b1 100644 --- a/index.html +++ b/index.html @@ -780,6 +780,15 @@ > space    +
  • + + visibility + +
    +
  • +
  • { + const blockIndex = this.blocks.trashStacks.indexOf(blockId); + if (blockIndex === -1) return; // Block not found in trash + + this.blocks.trashStacks.splice(blockIndex, 1); // Remove from trash + + for (const name in this.palettes.dict) { + this.palettes.dict[name].hideMenu(true); + } + + this.blocks.activeBlock = null; + this.refreshCanvas(); + + const dx = 0; + const dy = -this.cellSize * 3; // Reposition + + // Restore drag group + this.blocks.findDragGroup(blockId); + for (let b = 0; b < this.blocks.dragGroup.length; b++) { + const blk = this.blocks.dragGroup[b]; + this.blocks.blockList[blk].trash = false; + this.blocks.moveBlockRelative(blk, dx, dy); + this.blocks.blockList[blk].show(); + } + + this.blocks.raiseStackToTop(blockId); + const restoredBlock = this.blocks.blockList[blockId]; + + if (restoredBlock.name === 'start' || restoredBlock.name === 'drum') { + const turtle = restoredBlock.value; + this.turtles.turtleList[turtle].inTrash = false; + this.turtles.turtleList[turtle].container.visible = true; + } else if (restoredBlock.name === 'action') { + const actionArg = this.blocks.blockList[restoredBlock.connections[1]]; + if (actionArg !== null) { + let label; + const oldName = actionArg.value; + restoredBlock.trash = true; + const uniqueName = this.blocks.findUniqueActionName(oldName); + restoredBlock.trash = false; + + if (uniqueName !== actionArg) { + actionArg.value = uniqueName; + label = uniqueName.length > 8 ? uniqueName.substr(0, 7) + '...' : uniqueName; + actionArg.text.text = label; + + if (actionArg.label !== null) { + actionArg.label.value = uniqueName; + } + actionArg.container.updateCache(); + for (let b = 0; b < this.blocks.dragGroup.length; b++) { + const me = this.blocks.blockList[this.blocks.dragGroup[b]]; + if ( + ["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].includes( + me.name + ) && + me.privateData === oldName + ) { + me.privateData = uniqueName; + me.value = uniqueName; + label = uniqueName.length > 8 ? uniqueName.substr(0, 7) + '...' : uniqueName; + me.text.text = label; + me.overrideName = label; + me.regenerateArtwork(); + me.container.updateCache(); + } + } + } + } + } + + this.refreshCanvas(); + }; + + // Add event listener for trash icon click + document.getElementById('trashContainer').addEventListener('click', () => { + this._renderTrashView(); + }); + + // function to hide trashView from canvas + function handleClickOutsideTrashView(trashView) { + let firstClick = true; + document.addEventListener('click', (event) => { + if (firstClick) { + firstClick = false; + return; + } + if (!trashView.contains(event.target) && event.target !== trashView) { + trashView.style.display = 'none'; + } + }); + } + + this._renderTrashView = () => { + const trashList = document.getElementById('trashList'); + const trashView = document.createElement('div'); + trashView.id = 'trashView'; + trashView.classList.add('trash-view'); + + trashView.style.position = 'relative'; + trashView.style.backgroundColor = 'rgba(255, 255, 255, 1)'; + trashView.style.maxWidth = '396px'; + trashView.style.maxHeight = '200px'; + trashView.style.overflowY = 'auto'; + trashView.style.fontSize = '16px'; + trashView.style.color = 'black'; + trashView.style.border = '2px solid #87cefa'; + trashView.style.listStyleType = 'none'; + trashView.style.margin = '10px'; + trashView.style.padding = '10px'; + trashView.style.textAlign = 'left'; + trashView.innerHTML = ''; + + // Iterate over trash stack and render each item + this.blocks.trashStacks.forEach((blockId) => { + const block = this.blocks.blockList[blockId]; + // Create container for each block + const listItem = document.createElement('div'); + listItem.classList.add('trash-item'); + listItem.style.padding = '2px 12px'; + listItem.style.margin = '1px 0'; + listItem.style.borderRadius = '4px'; + listItem.style.transition = 'background-color 0.3s'; + + const svgData = block.artwork; + const encodedData = 'data:image/svg+xml;utf8,' + encodeURIComponent(svgData); + + const img = document.createElement('img'); + img.src = encodedData; + img.alt = 'Block Icon'; + img.style.width = '30px'; + img.style.height = '30px'; + img.style.marginRight = '10px'; + img.style.verticalAlign = 'middle'; + + const textNode = document.createTextNode(block.name); + + // Append image and name to the list item + listItem.appendChild(img); + listItem.appendChild(textNode); + listItem.dataset.blockId = blockId; + + listItem.addEventListener('mouseover', () => { + listItem.style.backgroundColor = '#d9d9d9'; + }); + listItem.addEventListener('mouseout', () => { + listItem.style.backgroundColor = ''; + }); + // Restore item on click + listItem.addEventListener('click', () => { + this._restoreTrashById(blockId); + activity.textMsg( + _("Item restored from the trash"), + 3000 + ); + trashView.style.display = 'none'; + }); + handleClickOutsideTrashView(trashView); + + trashView.appendChild(listItem); + }); + + // Append or replace the view in the container + const existingView = document.getElementById('trashView'); + if (existingView) { + trashList.replaceChild(trashView, existingView); + } else { + trashList.appendChild(trashView); + } + }; + this.handleKeyDown = (event) => { if (event.ctrlKey && event.key === "z") { From 47d7edbbbb30ca9e3b6436a7b68e8f9138a85b19 Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Tue, 31 Dec 2024 00:54:33 +0530 Subject: [PATCH 2/6] creating view trash option --- index.html | 9 +-- js/activity.js | 213 +++++++++++++++---------------------------------- 2 files changed, 66 insertions(+), 156 deletions(-) diff --git a/index.html b/index.html index 4f28df23b1..ff5c876b22 100644 --- a/index.html +++ b/index.html @@ -780,14 +780,6 @@ > space   
  • -
  • - - visibility - -
    -
  • restore_from_trash +
  • { - for (const name in this.palettes.dict) { - this.palettes.dict[name].hideMenu(true); - } - - this.blocks.activeBlock = null; - this.refreshCanvas(); - - const dx = 0; - const dy = -this.cellSize * 3; // Reposition - - if (this.blocks.trashStacks.length === 0) { + const restoreTrashShortcut = (activity) => { + if (!activity.blocks || !activity.blocks.trashStacks || activity.blocks.trashStacks.length === 0) { + activity.textMsg( + _("Nothing in the trash to restore."), + 3000 + ); return; } + const lastId = this.blocks.trashStacks[this.blocks.trashStacks.length - 1]; + if (lastId) this._restoreTrashById(lastId); + activity.textMsg( + _("Item restored from the trash."), + 3000 + ); - const thisBlock = this.blocks.trashStacks.pop(); - - // Restore drag group in trash - this.blocks.findDragGroup(thisBlock); - for (let b = 0; b < this.blocks.dragGroup.length; b++) { - const blk = this.blocks.dragGroup[b]; - this.blocks.blockList[blk].trash = false; - this.blocks.moveBlockRelative(blk, dx, dy); - this.blocks.blockList[blk].show(); - } - - this.blocks.raiseStackToTop(thisBlock); - - if ( - this.blocks.blockList[thisBlock].name === "start" || - this.blocks.blockList[thisBlock].name === "drum" - ) { - const turtle = this.blocks.blockList[thisBlock].value; - this.turtles.turtleList[turtle].inTrash = false; - this.turtles.turtleList[turtle].container.visible = true; - } else if (this.blocks.blockList[thisBlock].name === "action") { - // We need to add a palette entry for this action. - // But first we need to ensure we have a unqiue name, - // as the name could have been taken in the interim. - const actionArg = this.blocks.blockList[ - this.blocks.blockList[thisBlock].connections[1] - ]; - if (actionArg !== null) { - let label; - const oldName = actionArg.value; - // Mark the action block as still being in the - // trash so that its name won't be considered when - // looking for a unique name. - this.blocks.blockList[thisBlock].trash = true; - const uniqueName = this.blocks.findUniqueActionName(oldName); - this.blocks.blockList[thisBlock].trash = false; - - if (uniqueName !== actionArg) { - actionArg.value = uniqueName; - - label = actionArg.value.toString(); - if (label.length > 8) { - label = label.substr(0, 7) + "..."; - } - actionArg.text.text = label; - - if (actionArg.label !== null) { - actionArg.label.value = uniqueName; - } - - actionArg.container.updateCache(); - - // Check the drag group to ensure any do blocks are updated (in case of recursion). - for (let b = 0; b < this.blocks.dragGroup.length; b++) { - const me = this.blocks.blockList[this.blocks.dragGroup[b]]; - if ( - ["nameddo", "nameddoArg", "namedcalc", "namedcalcArg"].includes( - me.name - ) && - me.privateData === oldName - ) { - me.privateData = uniqueName; - me.value = uniqueName; - - label = me.value.toString(); - if (label.length > 8) { - label = label.substr(0, 7) + "..."; - } - me.text.text = label; - me.overrideName = label; - me.regenerateArtwork(); - me.container.updateCache(); - } - } - } - } + if (docById("helpfulWheelDiv").style.display !== "none") { + docById("helpfulWheelDiv").style.display = "none"; + activity.__tick(); } - - this.refreshCanvas(); - }; + + } this._restoreTrashById = (blockId) => { const blockIndex = this.blocks.trashStacks.indexOf(blockId); @@ -3503,12 +3424,16 @@ class Activity { } } } + activity.textMsg( + _("Item restored from the trash."), + 3000 + ); this.refreshCanvas(); }; // Add event listener for trash icon click - document.getElementById('trashContainer').addEventListener('click', () => { + document.getElementById('restoreIcon').addEventListener('click', () => { this._renderTrashView(); }); @@ -3527,67 +3452,71 @@ class Activity { } this._renderTrashView = () => { + if (!activity.blocks || !activity.blocks.trashStacks || activity.blocks.trashStacks.length === 0) { + return; + } const trashList = document.getElementById('trashList'); const trashView = document.createElement('div'); trashView.id = 'trashView'; trashView.classList.add('trash-view'); - - trashView.style.position = 'relative'; - trashView.style.backgroundColor = 'rgba(255, 255, 255, 1)'; - trashView.style.maxWidth = '396px'; - trashView.style.maxHeight = '200px'; - trashView.style.overflowY = 'auto'; - trashView.style.fontSize = '16px'; - trashView.style.color = 'black'; - trashView.style.border = '2px solid #87cefa'; - trashView.style.listStyleType = 'none'; - trashView.style.margin = '10px'; - trashView.style.padding = '10px'; - trashView.style.textAlign = 'left'; + + trashView.style = `position: relative; background-color: white; max-width: 396px; max-height: 200px; + overflow-y: auto; font-size: 16px; color: black; border: 2px solid #87cefa; + list-style-type: none; margin: 10px; padding: 10px; text-align: left;`; trashView.innerHTML = ''; - // Iterate over trash stack and render each item + // Sticky buttons + const buttonContainer = document.createElement('div'); + buttonContainer.style = 'position: sticky; top: 0; height: 40px; display: flex; gap: 10px; background: white; padding: 5px 0;'; + + const restoreLastBtn = document.createElement('button'); + restoreLastBtn.textContent = 'Restore Last'; + restoreLastBtn.style = 'display: flex; align-items: center; justify-content: center; width: 100px; height: 40px;'; + restoreLastBtn.addEventListener('click', () => { + const lastId = this.blocks.trashStacks[this.blocks.trashStacks.length - 1]; + if (lastId) this._restoreTrashById(lastId); + trashView.style.display = 'none'; + }); + + const restoreAllBtn = document.createElement('button'); + restoreAllBtn.textContent = 'Restore All'; + restoreAllBtn.style = 'display: flex; align-items: center; justify-content: center; width: 100px; height: 40px;'; + restoreAllBtn.addEventListener('click', () => { + while (this.blocks.trashStacks.length > 0) { + this._restoreTrashById(this.blocks.trashStacks[0]); + } + trashView.style.display = 'none'; + }); + + buttonContainer.appendChild(restoreLastBtn); + buttonContainer.appendChild(restoreAllBtn); + trashView.appendChild(buttonContainer); + + // Render trash items this.blocks.trashStacks.forEach((blockId) => { const block = this.blocks.blockList[blockId]; - // Create container for each block const listItem = document.createElement('div'); listItem.classList.add('trash-item'); - listItem.style.padding = '2px 12px'; - listItem.style.margin = '1px 0'; - listItem.style.borderRadius = '4px'; - listItem.style.transition = 'background-color 0.3s'; - + listItem.style = 'padding: 2px 12px; margin: 1px 0; border-radius: 4px; transition: background-color 0.3s;'; + const svgData = block.artwork; const encodedData = 'data:image/svg+xml;utf8,' + encodeURIComponent(svgData); const img = document.createElement('img'); img.src = encodedData; img.alt = 'Block Icon'; - img.style.width = '30px'; - img.style.height = '30px'; - img.style.marginRight = '10px'; - img.style.verticalAlign = 'middle'; - + img.style = 'width: 30px; height: 30px; margin-right: 10px; vertical-align: middle;'; + const textNode = document.createTextNode(block.name); - // Append image and name to the list item listItem.appendChild(img); listItem.appendChild(textNode); listItem.dataset.blockId = blockId; - - listItem.addEventListener('mouseover', () => { - listItem.style.backgroundColor = '#d9d9d9'; - }); - listItem.addEventListener('mouseout', () => { - listItem.style.backgroundColor = ''; - }); - // Restore item on click + + listItem.addEventListener('mouseover', () => listItem.style.backgroundColor = '#d9d9d9'); + listItem.addEventListener('mouseout', () => listItem.style.backgroundColor = ''); listItem.addEventListener('click', () => { this._restoreTrashById(blockId); - activity.textMsg( - _("Item restored from the trash"), - 3000 - ); trashView.style.display = 'none'; }); handleClickOutsideTrashView(trashView); @@ -3595,7 +3524,6 @@ class Activity { trashView.appendChild(listItem); }); - // Append or replace the view in the container const existingView = document.getElementById('trashView'); if (existingView) { trashList.replaceChild(trashView, existingView); @@ -3604,17 +3532,6 @@ class Activity { } }; - this.handleKeyDown = (event) => { - - if (event.ctrlKey && event.key === "z") { - this._restoreTrash(activity); - activity.__tick(); - event.preventDefault(); - } - }; - - // Attach keydown event listener to document - document.addEventListener("keydown", this.handleKeyDown); /* * Open aux menu @@ -5985,7 +5902,7 @@ class Activity { this.helpfulWheelItems.push({label: "Increase block size", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(BIGGERBUTTON)), display: true, fn: doLargerBlocks}); if (!this.helpfulWheelItems.find(ele => ele.label === "Restore")) - this.helpfulWheelItems.push({label: "Restore", icon: "imgsrc:header-icons/restore-from-trash.svg", display: true, fn: restoreTrash}); + this.helpfulWheelItems.push({label: "Restore", icon: "imgsrc:header-icons/restore-from-trash.svg", display: true, fn: restoreTrashShortcut}); if (!this.helpfulWheelItems.find(ele => ele.label === "Turtle Wrap Off")) this.helpfulWheelItems.push({label: "Turtle Wrap Off", icon: "imgsrc:header-icons/wrap-text.svg", display: true, fn: this.toolbar.changeWrap}); From 8ffce6cb4d66923495f671651332e3bfc8a062fc Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Tue, 31 Dec 2024 09:41:23 +0530 Subject: [PATCH 3/6] creating view trash option --- js/activity.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/activity.js b/js/activity.js index ceac999527..c54cd71fd1 100644 --- a/js/activity.js +++ b/js/activity.js @@ -3462,12 +3462,13 @@ class Activity { trashView.style = `position: relative; background-color: white; max-width: 396px; max-height: 200px; overflow-y: auto; font-size: 16px; color: black; border: 2px solid #87cefa; - list-style-type: none; margin: 10px; padding: 10px; text-align: left;`; + list-style-type: none; margin: 0; padding: 0; text-align: left;`; trashView.innerHTML = ''; // Sticky buttons const buttonContainer = document.createElement('div'); - buttonContainer.style = 'position: sticky; top: 0; height: 40px; display: flex; gap: 10px; background: white; padding: 5px 0;'; + buttonContainer.style = `position: sticky; top: 0; z-index: 10; display: flex; gap: 10px; background: white; + margin: 0; padding: 5px; border-bottom: 1px solid #d9d9d9;`; const restoreLastBtn = document.createElement('button'); restoreLastBtn.textContent = 'Restore Last'; From 9d125e73380bba63d9e27ee404e7fb9106e1b8ef Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Wed, 1 Jan 2025 02:26:35 +0530 Subject: [PATCH 4/6] Creating view trash list and more restore options --- css/activities.css | 58 ++++++++++++++++++++++++++++++++++++++++++++++ js/activity.js | 34 +++++++++++---------------- 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/css/activities.css b/css/activities.css index 1c09e1fec1..7cbc4a7dfc 100644 --- a/css/activities.css +++ b/css/activities.css @@ -90,6 +90,64 @@ font-size: large; } +.trash-view { + position: relative; + background-color: white; + max-width: 396px; + max-height: 200px; + overflow-y: auto; + font-size: 16px; + color: black; + border: 2px solid #87cefa; + list-style-type: none; + margin: 0; + padding: 0; + text-align: left; +} + +.button-container { + position: sticky; + top: 0; + z-index: 10; + display: flex; + gap: 10px; + background: white; + margin: 0; + padding: 5px; + border-bottom: 1px solid #d9d9d9; +} + +.restore-button { + display: flex; + align-items: center; + justify-content: center; + width: 100px; + height: 40px; + cursor: pointer; +} + +.trash-item { + padding: 2px 12px; + margin: 1px 0; + border-radius: 4px; + transition: background-color 0.3s; +} + +.trash-item.hover { + background-color: #d9d9d9; +} + +.trash-item-icon { + width: 30px; + height: 30px; + margin-right: 10px; + vertical-align: middle; +} + +.hidden { + display: none; +} + .ui-menu { position: relative; background-color: rgba(255, 255, 255, 1); diff --git a/js/activity.js b/js/activity.js index c54cd71fd1..42f5ddae20 100644 --- a/js/activity.js +++ b/js/activity.js @@ -3320,7 +3320,7 @@ class Activity { const restoreTrash = (activity) => { if (!activity.blocks || !activity.blocks.trashStacks || activity.blocks.trashStacks.length === 0) { activity.textMsg( - _("Nothing in the trash to restore."), + _("Trash can is empty."), 3000 ); return; @@ -3332,10 +3332,10 @@ class Activity { } }; - const restoreTrashShortcut = (activity) => { + const restoreTrashPop = (activity) => { if (!activity.blocks || !activity.blocks.trashStacks || activity.blocks.trashStacks.length === 0) { activity.textMsg( - _("Nothing in the trash to restore."), + _("Trash can is empty."), 3000 ); return; @@ -3460,33 +3460,27 @@ class Activity { trashView.id = 'trashView'; trashView.classList.add('trash-view'); - trashView.style = `position: relative; background-color: white; max-width: 396px; max-height: 200px; - overflow-y: auto; font-size: 16px; color: black; border: 2px solid #87cefa; - list-style-type: none; margin: 0; padding: 0; text-align: left;`; - trashView.innerHTML = ''; - // Sticky buttons const buttonContainer = document.createElement('div'); - buttonContainer.style = `position: sticky; top: 0; z-index: 10; display: flex; gap: 10px; background: white; - margin: 0; padding: 5px; border-bottom: 1px solid #d9d9d9;`; + buttonContainer.classList.add('button-container'); const restoreLastBtn = document.createElement('button'); restoreLastBtn.textContent = 'Restore Last'; - restoreLastBtn.style = 'display: flex; align-items: center; justify-content: center; width: 100px; height: 40px;'; + restoreLastBtn.classList.add('restore-button'); restoreLastBtn.addEventListener('click', () => { const lastId = this.blocks.trashStacks[this.blocks.trashStacks.length - 1]; if (lastId) this._restoreTrashById(lastId); - trashView.style.display = 'none'; + trashView.classList.add('hidden'); }); const restoreAllBtn = document.createElement('button'); restoreAllBtn.textContent = 'Restore All'; - restoreAllBtn.style = 'display: flex; align-items: center; justify-content: center; width: 100px; height: 40px;'; + restoreAllBtn.classList.add('restore-button'); restoreAllBtn.addEventListener('click', () => { while (this.blocks.trashStacks.length > 0) { this._restoreTrashById(this.blocks.trashStacks[0]); } - trashView.style.display = 'none'; + trashView.classList.add('hidden'); }); buttonContainer.appendChild(restoreLastBtn); @@ -3498,7 +3492,6 @@ class Activity { const block = this.blocks.blockList[blockId]; const listItem = document.createElement('div'); listItem.classList.add('trash-item'); - listItem.style = 'padding: 2px 12px; margin: 1px 0; border-radius: 4px; transition: background-color 0.3s;'; const svgData = block.artwork; const encodedData = 'data:image/svg+xml;utf8,' + encodeURIComponent(svgData); @@ -3506,7 +3499,7 @@ class Activity { const img = document.createElement('img'); img.src = encodedData; img.alt = 'Block Icon'; - img.style = 'width: 30px; height: 30px; margin-right: 10px; vertical-align: middle;'; + img.classList.add('trash-item-icon'); const textNode = document.createTextNode(block.name); @@ -3514,11 +3507,11 @@ class Activity { listItem.appendChild(textNode); listItem.dataset.blockId = blockId; - listItem.addEventListener('mouseover', () => listItem.style.backgroundColor = '#d9d9d9'); - listItem.addEventListener('mouseout', () => listItem.style.backgroundColor = ''); + listItem.addEventListener('mouseover', () => listItem.classList.add('hover')); + listItem.addEventListener('mouseout', () => listItem.classList.remove('hover')); listItem.addEventListener('click', () => { this._restoreTrashById(blockId); - trashView.style.display = 'none'; + trashView.classList.add('hidden'); }); handleClickOutsideTrashView(trashView); @@ -3533,7 +3526,6 @@ class Activity { } }; - /* * Open aux menu */ @@ -5903,7 +5895,7 @@ class Activity { this.helpfulWheelItems.push({label: "Increase block size", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(BIGGERBUTTON)), display: true, fn: doLargerBlocks}); if (!this.helpfulWheelItems.find(ele => ele.label === "Restore")) - this.helpfulWheelItems.push({label: "Restore", icon: "imgsrc:header-icons/restore-from-trash.svg", display: true, fn: restoreTrashShortcut}); + this.helpfulWheelItems.push({label: "Restore", icon: "imgsrc:header-icons/restore-from-trash.svg", display: true, fn: restoreTrashPop}); if (!this.helpfulWheelItems.find(ele => ele.label === "Turtle Wrap Off")) this.helpfulWheelItems.push({label: "Turtle Wrap Off", icon: "imgsrc:header-icons/wrap-text.svg", display: true, fn: this.toolbar.changeWrap}); From b1f1453b8c15c4720856e5f6d26e4fe29d971a94 Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Wed, 1 Jan 2025 02:34:00 +0530 Subject: [PATCH 5/6] Creating view trash list and more restore options --- js/activity.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/activity.js b/js/activity.js index 42f5ddae20..d248682a95 100644 --- a/js/activity.js +++ b/js/activity.js @@ -3366,7 +3366,7 @@ class Activity { this.blocks.activeBlock = null; this.refreshCanvas(); - + const dx = 0; const dy = -this.cellSize * 3; // Reposition @@ -3394,12 +3394,12 @@ class Activity { restoredBlock.trash = true; const uniqueName = this.blocks.findUniqueActionName(oldName); restoredBlock.trash = false; - + if (uniqueName !== actionArg) { actionArg.value = uniqueName; label = uniqueName.length > 8 ? uniqueName.substr(0, 7) + '...' : uniqueName; actionArg.text.text = label; - + if (actionArg.label !== null) { actionArg.label.value = uniqueName; } From 8c0b5a3fb9cc3ed02e4ca35eea53fdbf7a8f0223 Mon Sep 17 00:00:00 2001 From: subhas-pramanik-09 Date: Wed, 1 Jan 2025 18:42:53 +0530 Subject: [PATCH 6/6] Creating view trash and more restore options --- css/activities.css | 8 +++++--- js/activity.js | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/css/activities.css b/css/activities.css index 7cbc4a7dfc..9d91f05d57 100644 --- a/css/activities.css +++ b/css/activities.css @@ -111,7 +111,7 @@ z-index: 10; display: flex; gap: 10px; - background: white; + background: #2196F3; margin: 0; padding: 5px; border-bottom: 1px solid #d9d9d9; @@ -121,9 +121,11 @@ display: flex; align-items: center; justify-content: center; - width: 100px; - height: 40px; + width: 90px; + height: 35px; cursor: pointer; + background-color: white; + border-radius: 8px; } .trash-item { diff --git a/js/activity.js b/js/activity.js index d248682a95..f8f2bb64e5 100644 --- a/js/activity.js +++ b/js/activity.js @@ -3465,7 +3465,7 @@ class Activity { buttonContainer.classList.add('button-container'); const restoreLastBtn = document.createElement('button'); - restoreLastBtn.textContent = 'Restore Last'; + restoreLastBtn.textContent = "Restore last"; restoreLastBtn.classList.add('restore-button'); restoreLastBtn.addEventListener('click', () => { const lastId = this.blocks.trashStacks[this.blocks.trashStacks.length - 1]; @@ -3474,7 +3474,7 @@ class Activity { }); const restoreAllBtn = document.createElement('button'); - restoreAllBtn.textContent = 'Restore All'; + restoreAllBtn.textContent = "Restore all"; restoreAllBtn.classList.add('restore-button'); restoreAllBtn.addEventListener('click', () => { while (this.blocks.trashStacks.length > 0) {