英文:
Soft Delete in Angular and Nest with Restore and Permanent Delete Functionality
问题
你们能帮我摆脱这种情况吗,提供一些如何克服这个问题的想法。我有两个部分,一个是成分,一个是已删除项目。在成分部分,如果我点击特定成分的删除按钮,它将被存储在已删除部分。在已删除部分中,对于一个成分,有两个按钮,一个是还原按钮 - 如果我在这里点击,它将还原成分并移回成分部分,另一个是永久删除按钮 - 如果我在这里点击,成分将被永久删除。
英文:
Can you guy's help me out of this situation by giving idea how can I overcome this. I have two sections, one for ingredients and one for deleted items. Inside ingredient section if I clicks on delete button of a particular ingredient then it will be stored in deleted section. Inside deleted section for an ingredient it has two button one is restore- if I clicks here then it will restore the ingredient and move to ingredients section and another one is permanent delete button- if I clicks here then ingredients will be deleted permanently.
答案1
得分: 1
以下是如何实现此功能的一些想法:
-
使用两个数组来存储食材和已删除的项目:您可以使用两个单独的数组来存储食材和已删除的项目。当用户点击删除按钮以删除食材时,您可以将该食材从食材数组中移除并将其添加到已删除项目数组中。当用户点击还原按钮以还原已删除项目时,您可以将该项目从已删除项目数组中移除并将其重新添加到食材数组中。当用户点击永久删除按钮以永久删除已删除项目时,您可以将该项目从已删除项目数组中永久移除。
-
使用一个带有“已删除”标志的单一数组:您可以使用一个单一数组来存储所有项目,包括食材和已删除的项目。数组中的每个项目都可以有一个“已删除”标志,对于食材,该标志设置为false,对于已删除的项目,该标志设置为true。当用户点击删除按钮以删除食材时,您可以将该食材的“已删除”标志设置为true。当用户点击还原按钮以还原已删除项目时,您可以将该项目的“已删除”标志设置为false。当用户点击永久删除按钮以永久删除已删除项目时,您可以从数组中永久移除该项目。
-
使用数据库来存储食材和已删除的项目:您可以使用数据库来存储食材和已删除的项目。当用户点击删除按钮以删除食材时,您可以更新数据库以标记该食材为已删除。当用户点击还原按钮以还原已删除项目时,您可以更新数据库以标记该项目为未删除。当用户点击永久删除按钮以永久删除已删除项目时,您可以从数据库中永久移除该项目。
英文:
Here are a few ideas for how you can implement this functionality:
-
Use two arrays to store the ingredients and deleted items: You can
use two separate arrays to store the ingredients and deleted items.
When a user clicks the delete button for an ingredient, you can
remove the ingredient from the ingredients array and add it to the
deleted items array. When a user clicks the restore button for a
deleted item, you can remove the item from the deleted items array
and add it back to the ingredients array. When a user clicks the
permanent delete button for a deleted item, you can remove the item
from the deleted items array permanently. -
Use a single array with a
"deleted" flag: You can use a single array to store all the items,
including both ingredients and deleted items. Each item in the array
can have a "deleted" flag that is set to false for ingredients and
true for deleted items. When a user clicks the delete button for an
ingredient, you can set the "deleted" flag to true for that
ingredient. When a user clicks the restore button for a deleted
item, you can set the "deleted" flag to false for that item. When a
user clicks the permanent delete button for a deleted item, you can
remove the item from the array permanently. -
Use a database to store
the ingredients and deleted items: You can use a database to store
the ingredients and deleted items. When a user clicks the delete
button for an ingredient, you can update the database to mark that
ingredient as deleted. When a user clicks the restore button for a
deleted item, you can update the database to mark that item as not
deleted. When a user clicks the permanent delete button for a
deleted item, you can remove the item from the database permanently.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论