Implement tagging rules reset

Adding tagging rule reset to templates

Adding messages to tagging rule reset

Adding translation for Traditional and Simplified Chinese
This commit is contained in:
Kevin Jiang 2024-07-07 01:04:28 +12:00 committed by Sicong Jiang
parent f78353910f
commit c65850050d
6 changed files with 34 additions and 2 deletions

View File

@ -561,11 +561,11 @@ class ConfigController extends AbstractController
/**
* Remove all annotations OR tags OR entries for the current user.
*
* @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries"}, name="config_reset", methods={"POST"})
* @Route("/reset/{type}", requirements={"id" = "annotations|tags|entries|tagging_rules"}, name="config_reset", methods={"POST"})
*
* @return RedirectResponse
*/
public function resetAction(Request $request, string $type, AnnotationRepository $annotationRepository, EntryRepository $entryRepository)
public function resetAction(Request $request, string $type, AnnotationRepository $annotationRepository, EntryRepository $entryRepository, TaggingRuleRepository $taggingRuleRepository)
{
if (!$this->isCsrfTokenValid('reset-area', $request->request->get('token'))) {
throw $this->createAccessDeniedException('Bad CSRF token.');
@ -575,6 +575,9 @@ class ConfigController extends AbstractController
case 'annotations':
$annotationRepository->removeAllByUserId($this->getUser()->getId());
break;
case 'tagging_rules':
$taggingRuleRepository->removeAllTaggingRules($this->getConfig()->getId());
break;
case 'tags':
$this->removeAllTagsByUserId($this->getUser()->getId());
break;

View File

@ -12,4 +12,18 @@ class TaggingRuleRepository extends ServiceEntityRepository
{
parent::__construct($registry, TaggingRule::class);
}
/**
* Remove all tagging rule for a config.
* Used when a user wants to reset.
*
* @param int $configId
*/
public function removeAllTaggingRules($configId)
{
$this->getEntityManager()
->createQuery('DELETE FROM Wallabag\Entity\TaggingRule tr WHERE tr.config = :configId')
->setParameter(':configId', $configId)
->execute();
}
}

View File

@ -640,6 +640,15 @@
<div class="row">
<h5>{{ 'config.reset.title'|trans }}</h5>
<p>{{ 'config.reset.description'|trans }}</p>
{% if app.user.config.taggingRules is not empty %}
<p>
<form action="{{ path('config_reset', {type: 'tagging_rules'}) }}" method="post" onsubmit="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" name="reset-tagging-rules">
<input type="hidden" name="token" value="{{ csrf_token('reset-area') }}" />
<button class="waves-effect waves-light btn red" type="submit">{{ 'config.reset.tagging_rules'|trans }}</button>
</form>
</p>
{% endif %}
<p>
<form action="{{ path('config_reset', {type: 'annotations'}) }}" method="post" onsubmit="return confirm('{{ 'config.reset.confirm'|trans|escape('js') }}')" name="reset-annotations">
<input type="hidden" name="token" value="{{ csrf_token('reset-area') }}" />

View File

@ -138,6 +138,7 @@ config:
description: By hitting buttons below you'll have ability to remove some information from your account. Be aware that these actions are IRREVERSIBLE.
annotations: Remove ALL annotations
tags: Remove ALL tags
tagging_rules: Remove ALL tagging rules
entries: Remove ALL entries
archived: Remove ALL archived entries
confirm: Are you really sure? (THIS CAN'T BE UNDONE)
@ -676,6 +677,7 @@ flashes:
feed_token_revoked: 'Feed token revoked'
annotations_reset: Annotations reset
tags_reset: Tags reset
tagging_rules_reset: Tagging rules reset
entries_reset: Entries reset
archived_reset: Archived entries deleted
otp_enabled: Two-factor authentication enabled

View File

@ -140,6 +140,7 @@ config:
title: '重置区(危险区域)'
description: '一旦你点击这个按钮,你就可以移除你账号中的某些信息。请注意这些操作是不可撤销的。'
annotations: "删除所有标注"
tagging_rules: "删除所有标签规则"
tags: "删除所有标签"
entries: "删除所有项目"
archived: "删除所有已存档项目"
@ -678,6 +679,7 @@ flashes:
feed_token_revoked: '订阅源令牌已作废'
annotations_reset: 标注已重置
tags_reset: 标签已重置
tagging_rules_reset: 标签规则已重置
entries_reset: 项目列表已重置
archived_reset: 所有存档项目已删除
otp_enabled: 两步验证已启用

View File

@ -139,6 +139,7 @@ config:
page_title: 雙重驗證
reset:
tags: 移除所有標籤
tagging_rules: 移除所有標籤規則
title: 重設區域(危險地帶)
entries: 移除所有條目
archived: 移除所有已封存條目
@ -671,6 +672,7 @@ flashes:
entries_reset: 已重設條目
archived_reset: 完成刪除已封存條目
tags_reset: 已重設標籤
tagging_rules_reset: 已重設標籤規則
annotations_reset: 已重設註釋
tagging_rules_updated: 已更新標籤規則
tagging_rules_deleted: 已刪除標籤規則