mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-15 18:57:05 +00:00
Merge pull request #2324 from wallabag/edit-tagging-rule
Add ability to edit a tagging rule
This commit is contained in:
commit
6e5e27ab07
14 changed files with 106 additions and 17 deletions
|
@ -108,7 +108,21 @@ class ConfigController extends Controller
|
|||
|
||||
// handle tagging rule
|
||||
$taggingRule = new TaggingRule();
|
||||
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']);
|
||||
$action = $this->generateUrl('config').'#set5';
|
||||
|
||||
if ($request->query->has('tagging-rule')) {
|
||||
$taggingRule = $this->getDoctrine()
|
||||
->getRepository('WallabagCoreBundle:TaggingRule')
|
||||
->find($request->query->get('tagging-rule'));
|
||||
|
||||
if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) {
|
||||
return $this->redirect($action);
|
||||
}
|
||||
|
||||
$action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5';
|
||||
}
|
||||
|
||||
$newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
|
||||
$newTaggingRule->handleRequest($request);
|
||||
|
||||
if ($newTaggingRule->isValid()) {
|
||||
|
@ -205,9 +219,7 @@ class ConfigController extends Controller
|
|||
*/
|
||||
public function deleteTaggingRuleAction(TaggingRule $rule)
|
||||
{
|
||||
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this tagging rule.');
|
||||
}
|
||||
$this->validateRuleAction($rule);
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->remove($rule);
|
||||
|
@ -221,6 +233,34 @@ class ConfigController extends Controller
|
|||
return $this->redirect($this->generateUrl('config').'#set5');
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a tagging rule.
|
||||
*
|
||||
* @param TaggingRule $rule
|
||||
*
|
||||
* @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule")
|
||||
*
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function editTaggingRuleAction(TaggingRule $rule)
|
||||
{
|
||||
$this->validateRuleAction($rule);
|
||||
|
||||
return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5');
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a rule can be edited/deleted by the current user.
|
||||
*
|
||||
* @param TaggingRule $rule
|
||||
*/
|
||||
private function validateRuleAction(TaggingRule $rule)
|
||||
{
|
||||
if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) {
|
||||
throw $this->createAccessDeniedException('You can not access this tagging rule.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve config for the current user.
|
||||
* If no config were found, create a new one.
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
# if_label: 'if'
|
||||
# then_tag_as_label: 'then tag as'
|
||||
# delete_rule_label: 'delete'
|
||||
# edit_rule_label: 'edit'
|
||||
# rule_label: 'Rule'
|
||||
# tags_label: 'Tags'
|
||||
# faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'Wenn'
|
||||
then_tag_as_label: 'dann tagge als'
|
||||
delete_rule_label: 'löschen'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'Regel'
|
||||
tags_label: 'Tags'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'if'
|
||||
then_tag_as_label: 'then tag as'
|
||||
delete_rule_label: 'delete'
|
||||
edit_rule_label: 'edit'
|
||||
rule_label: 'Rule'
|
||||
tags_label: 'Tags'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'si'
|
||||
then_tag_as_label: 'Etiquete como'
|
||||
delete_rule_label: 'Borre'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'Regla'
|
||||
tags_label: 'Etiquetas'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'اگر'
|
||||
then_tag_as_label: 'این برچسب را بزن'
|
||||
delete_rule_label: 'پاک کن'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'قانون'
|
||||
tags_label: 'برچسبها'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'si'
|
||||
then_tag_as_label: 'alors attribuer les tags'
|
||||
delete_rule_label: 'supprimer'
|
||||
edit_rule_label: 'éditer'
|
||||
rule_label: 'Règle'
|
||||
tags_label: 'Tags'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'se'
|
||||
then_tag_as_label: 'allora tagga come'
|
||||
delete_rule_label: 'elimina'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'Regola'
|
||||
tags_label: 'Tag'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'se'
|
||||
then_tag_as_label: 'alara atribuir las etiquetas'
|
||||
delete_rule_label: 'suprimir'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'Règla'
|
||||
tags_label: 'Etiquetas'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
if_label: 'jeżeli'
|
||||
then_tag_as_label: 'wtedy otaguj jako'
|
||||
delete_rule_label: 'usuń'
|
||||
# edit_rule_label: 'edit'
|
||||
rule_label: 'Reguła'
|
||||
tags_label: 'Tagi'
|
||||
faq:
|
||||
|
|
|
@ -95,6 +95,7 @@ config:
|
|||
# if_label: 'if'
|
||||
# then_tag_as_label: 'then tag as'
|
||||
# delete_rule_label: 'delete'
|
||||
# edit_rule_label: 'edit'
|
||||
# rule_label: 'Rule'
|
||||
# tags_label: 'Tags'
|
||||
# faq:
|
||||
|
|
|
@ -191,6 +191,7 @@
|
|||
« {{ tagging_rule.rule }} »
|
||||
{{ 'config.form_rules.then_tag_as_label'|trans }}
|
||||
« {{ tagging_rule.tags|join(', ') }} »
|
||||
<a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="tool mode_edit">✎</a>
|
||||
<a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}" class="tool delete icon-trash icon"></a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
@ -218,6 +218,9 @@
|
|||
« {{ tagging_rule.rule }} »
|
||||
{{ 'config.form_rules.then_tag_as_label'|trans }}
|
||||
« {{ tagging_rule.tags|join(', ') }} »
|
||||
<a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}">
|
||||
<i class="tool grey-text mode_edit material-icons">mode_edit</i>
|
||||
</a>
|
||||
<a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}">
|
||||
<i class="tool grey-text delete material-icons">delete</i>
|
||||
</a>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue