diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 16:47:48 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-01 16:52:05 +0200 |
commit | bf3dc999e7b25888460faff2251f75e4a79491c4 (patch) | |
tree | e529f9a322f7359141254ed6f05cc2c15ba845c3 /src/Wallabag | |
parent | c4bf7af96f52aaafd13049e74f27b368eec79bf8 (diff) | |
download | wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.gz wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.tar.zst wallabag-bf3dc999e7b25888460faff2251f75e4a79491c4.zip |
Add ability to edit a tagging rule
Diffstat (limited to 'src/Wallabag')
13 files changed, 47 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index 75a9af0b..28e33998 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -108,7 +108,21 @@ class ConfigController extends Controller | |||
108 | 108 | ||
109 | // handle tagging rule | 109 | // handle tagging rule |
110 | $taggingRule = new TaggingRule(); | 110 | $taggingRule = new TaggingRule(); |
111 | $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $this->generateUrl('config').'#set5']); | 111 | $action = $this->generateUrl('config').'#set5'; |
112 | |||
113 | if ($request->query->has('tagging-rule')) { | ||
114 | $taggingRule = $this->getDoctrine() | ||
115 | ->getRepository('WallabagCoreBundle:TaggingRule') | ||
116 | ->find($request->query->get('tagging-rule')); | ||
117 | |||
118 | if ($this->getUser()->getId() !== $taggingRule->getConfig()->getUser()->getId()) { | ||
119 | return $this->redirect($action); | ||
120 | } | ||
121 | |||
122 | $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5'; | ||
123 | } | ||
124 | |||
125 | $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]); | ||
112 | $newTaggingRule->handleRequest($request); | 126 | $newTaggingRule->handleRequest($request); |
113 | 127 | ||
114 | if ($newTaggingRule->isValid()) { | 128 | if ($newTaggingRule->isValid()) { |
@@ -222,6 +236,24 @@ class ConfigController extends Controller | |||
222 | } | 236 | } |
223 | 237 | ||
224 | /** | 238 | /** |
239 | * Edit a tagging rule. | ||
240 | * | ||
241 | * @param TaggingRule $rule | ||
242 | * | ||
243 | * @Route("/tagging-rule/edit/{id}", requirements={"id" = "\d+"}, name="edit_tagging_rule") | ||
244 | * | ||
245 | * @return RedirectResponse | ||
246 | */ | ||
247 | public function editTaggingRuleAction(TaggingRule $rule) | ||
248 | { | ||
249 | if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { | ||
250 | throw $this->createAccessDeniedException('You can not access this tagging rule.'); | ||
251 | } | ||
252 | |||
253 | return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5'); | ||
254 | } | ||
255 | |||
256 | /** | ||
225 | * Retrieve config for the current user. | 257 | * Retrieve config for the current user. |
226 | * If no config were found, create a new one. | 258 | * If no config were found, create a new one. |
227 | * | 259 | * |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 7ad5c100..98ccfb1d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | # if_label: 'if' | 94 | # if_label: 'if' |
95 | # then_tag_as_label: 'then tag as' | 95 | # then_tag_as_label: 'then tag as' |
96 | # delete_rule_label: 'delete' | 96 | # delete_rule_label: 'delete' |
97 | # edit_rule_label: 'edit' | ||
97 | # rule_label: 'Rule' | 98 | # rule_label: 'Rule' |
98 | # tags_label: 'Tags' | 99 | # tags_label: 'Tags' |
99 | # faq: | 100 | # faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 650e4761..1dcd7dbe 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'Wenn' | 94 | if_label: 'Wenn' |
95 | then_tag_as_label: 'dann tagge als' | 95 | then_tag_as_label: 'dann tagge als' |
96 | delete_rule_label: 'löschen' | 96 | delete_rule_label: 'löschen' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'Regel' | 98 | rule_label: 'Regel' |
98 | tags_label: 'Tags' | 99 | tags_label: 'Tags' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index d5842cc5..e75166bf 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'if' | 94 | if_label: 'if' |
95 | then_tag_as_label: 'then tag as' | 95 | then_tag_as_label: 'then tag as' |
96 | delete_rule_label: 'delete' | 96 | delete_rule_label: 'delete' |
97 | edit_rule_label: 'edit' | ||
97 | rule_label: 'Rule' | 98 | rule_label: 'Rule' |
98 | tags_label: 'Tags' | 99 | tags_label: 'Tags' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index bd691c1c..0884e9e6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'si' | 94 | if_label: 'si' |
95 | then_tag_as_label: 'Etiquete como' | 95 | then_tag_as_label: 'Etiquete como' |
96 | delete_rule_label: 'Borre' | 96 | delete_rule_label: 'Borre' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'Regla' | 98 | rule_label: 'Regla' |
98 | tags_label: 'Etiquetas' | 99 | tags_label: 'Etiquetas' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index a9989a83..1d30d5b2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'اگر' | 94 | if_label: 'اگر' |
95 | then_tag_as_label: 'این برچسب را بزن' | 95 | then_tag_as_label: 'این برچسب را بزن' |
96 | delete_rule_label: 'پاک کن' | 96 | delete_rule_label: 'پاک کن' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'قانون' | 98 | rule_label: 'قانون' |
98 | tags_label: 'برچسبها' | 99 | tags_label: 'برچسبها' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index b70ca64d..c3647731 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'si' | 94 | if_label: 'si' |
95 | then_tag_as_label: 'alors attribuer les tags' | 95 | then_tag_as_label: 'alors attribuer les tags' |
96 | delete_rule_label: 'supprimer' | 96 | delete_rule_label: 'supprimer' |
97 | edit_rule_label: 'éditer' | ||
97 | rule_label: 'Règle' | 98 | rule_label: 'Règle' |
98 | tags_label: 'Tags' | 99 | tags_label: 'Tags' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 118098fe..2c99e9a8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'se' | 94 | if_label: 'se' |
95 | then_tag_as_label: 'allora tagga come' | 95 | then_tag_as_label: 'allora tagga come' |
96 | delete_rule_label: 'elimina' | 96 | delete_rule_label: 'elimina' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'Regola' | 98 | rule_label: 'Regola' |
98 | tags_label: 'Tag' | 99 | tags_label: 'Tag' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 93467dac..ebebcbc0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'se' | 94 | if_label: 'se' |
95 | then_tag_as_label: 'alara atribuir las etiquetas' | 95 | then_tag_as_label: 'alara atribuir las etiquetas' |
96 | delete_rule_label: 'suprimir' | 96 | delete_rule_label: 'suprimir' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'Règla' | 98 | rule_label: 'Règla' |
98 | tags_label: 'Etiquetas' | 99 | tags_label: 'Etiquetas' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 27507a81..0a76b673 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | if_label: 'jeżeli' | 94 | if_label: 'jeżeli' |
95 | then_tag_as_label: 'wtedy otaguj jako' | 95 | then_tag_as_label: 'wtedy otaguj jako' |
96 | delete_rule_label: 'usuń' | 96 | delete_rule_label: 'usuń' |
97 | # edit_rule_label: 'edit' | ||
97 | rule_label: 'Reguła' | 98 | rule_label: 'Reguła' |
98 | tags_label: 'Tagi' | 99 | tags_label: 'Tagi' |
99 | faq: | 100 | faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 7c77ffb7..d107a96e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -94,6 +94,7 @@ config: | |||
94 | # if_label: 'if' | 94 | # if_label: 'if' |
95 | # then_tag_as_label: 'then tag as' | 95 | # then_tag_as_label: 'then tag as' |
96 | # delete_rule_label: 'delete' | 96 | # delete_rule_label: 'delete' |
97 | # edit_rule_label: 'edit' | ||
97 | # rule_label: 'Rule' | 98 | # rule_label: 'Rule' |
98 | # tags_label: 'Tags' | 99 | # tags_label: 'Tags' |
99 | # faq: | 100 | # faq: |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig index 6446cf2c..dd4f7b00 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Config/index.html.twig | |||
@@ -191,6 +191,7 @@ | |||
191 | « {{ tagging_rule.rule }} » | 191 | « {{ tagging_rule.rule }} » |
192 | {{ 'config.form_rules.then_tag_as_label'|trans }} | 192 | {{ 'config.form_rules.then_tag_as_label'|trans }} |
193 | « {{ tagging_rule.tags|join(', ') }} » | 193 | « {{ tagging_rule.tags|join(', ') }} » |
194 | <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}" class="tool mode_edit">✎</a> | ||
194 | <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> | 195 | <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> |
195 | </li> | 196 | </li> |
196 | {% endfor %} | 197 | {% endfor %} |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig index 5330c353..650a3ae2 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Config/index.html.twig | |||
@@ -218,6 +218,9 @@ | |||
218 | « {{ tagging_rule.rule }} » | 218 | « {{ tagging_rule.rule }} » |
219 | {{ 'config.form_rules.then_tag_as_label'|trans }} | 219 | {{ 'config.form_rules.then_tag_as_label'|trans }} |
220 | « {{ tagging_rule.tags|join(', ') }} » | 220 | « {{ tagging_rule.tags|join(', ') }} » |
221 | <a href="{{ path('edit_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.edit_rule_label'|trans }}"> | ||
222 | <i class="tool grey-text mode_edit material-icons">mode_edit</i> | ||
223 | </a> | ||
221 | <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}"> | 224 | <a href="{{ path('delete_tagging_rule', {id: tagging_rule.id}) }}" title="{{ 'config.form_rules.delete_rule_label'|trans }}"> |
222 | <i class="tool grey-text delete material-icons">delete</i> | 225 | <i class="tool grey-text delete material-icons">delete</i> |
223 | </a> | 226 | </a> |