Browse Source

Ajout de deux bouton: aucun tags, mes tags

bastien 13 years ago
parent
commit
85c0807aaf

+ 2 - 0
app/Resources/translations/userui.fr.yml View File

@@ -33,6 +33,8 @@ tags:
33 33
 filter:
34 34
   network: "Résultats de "
35 35
   submit:  Filtrer
36
+  clear:   Aucun filtre
37
+  mytags:  Tous mes tags
36 38
   
37 39
 element_add:
38 40
   url:

+ 14 - 0
src/Muzich/CoreBundle/Controller/CoreController.php View File

@@ -263,4 +263,18 @@ class CoreController extends Controller
263 263
     
264 264
   }
265 265
   
266
+  public function filterClearAction()
267
+  {
268
+    $es = $this->getElementSearcher();
269
+    $es->update(array('tags' => array()));
270
+    $this->setElementSearcherParams($es->getParams());
271
+    return $this->redirect($this->container->get('request')->headers->get('referer'));
272
+  }
273
+  
274
+  public function filterMytagsAction()
275
+  {
276
+    $this->getElementSearcher(null, true);
277
+    return $this->redirect($this->container->get('request')->headers->get('referer'));
278
+  }
279
+  
266 280
 }

+ 8 - 0
src/Muzich/CoreBundle/Resources/config/routing.yml View File

@@ -20,6 +20,14 @@ search_tag_ig_by_name:
20 20
   pattern: /search/tagid/{string_search}
21 21
   defaults: { _controller: MuzichCoreBundle:Search:searchTagId, string_search: null }
22 22
 
23
+filter_clear:
24
+  pattern: /filter/clear
25
+  defaults: { _controller: MuzichCoreBundle:Core:filterClear }
26
+
27
+filter_mytags:
28
+  pattern: /filter/my-tags
29
+  defaults: { _controller: MuzichCoreBundle:Core:filterMytags }
30
+
23 31
 ####
24 32
 
25 33
 info_about:

+ 1 - 1
src/Muzich/CoreBundle/Resources/views/SearchElement/form.html.twig View File

@@ -6,7 +6,7 @@
6 6
     {{ form_label(search_form.network, 'filter.network'|trans({}, 'userui')) }}
7 7
     {{ form_widget(search_form.network) }}
8 8
   </div>
9
-
9
+  
10 10
   {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 'form_name': form_name } %}
11 11
   
12 12
   {{ form_row(search_form.tags) }}

+ 11 - 0
src/Muzich/CoreBundle/Resources/views/Tag/tagsPrompt.html.twig View File

@@ -2,6 +2,17 @@
2 2
 
3 3
 <div class="tags_prompt" id="tags_prompt_{{ form_name }}">
4 4
   <span class="help">{{ 'tags.help'|trans({}, 'userui') }}</span>
5
+  
6
+  {% if display_specials_buttons is defined %}
7
+    {% if display_specials_buttons == true %}
8
+      <br />
9
+      <input class="clear" type="button" value="{{ 'filter.clear'|trans({}, 'userui') }}" />
10
+      <input type="hidden" class="filter_clear_url" value="{{ path('filter_clear') }}" />
11
+      <input class="mytags" type="button" value="{{ 'filter.mytags'|trans({}, 'userui') }}" />
12
+      <input type="hidden" class="filter_mytags_url" value="{{ path('filter_mytags') }}" />
13
+    {% endif %}
14
+  {% endif %}
15
+  
5 16
    <input class="tags_prompt_list" id="tags_prompt_list_{{ form_name }}" name="tags" value=""> 
6 17
 </div>
7 18
 

+ 2 - 2
src/Muzich/CoreBundle/lib/Controller.php View File

@@ -43,11 +43,11 @@ class Controller extends BaseController
43 43
    * 
44 44
    * @return  ElementSearcher
45 45
    */
46
-  protected function getElementSearcher($count = null)
46
+  protected function getElementSearcher($count = null, $force_new = false)
47 47
   {
48 48
     $session = $this->get("session");
49 49
     // Si l'objet n'existe pas encore, a t-on déjà des paramètres de recherche
50
-    if (!$session->has('user.element_search.params'))
50
+    if (!$session->has('user.element_search.params') || $force_new)
51 51
     {
52 52
       // Il nous faut instancier notre premier objet recherche
53 53
       // Premièrement on récupère les tags favoris de l'utilisateur

+ 5 - 6
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

@@ -28,13 +28,12 @@
28 28
   <form action="{{ path('search_elements') }}" method="post" {{ form_enctype(search_form) }}>
29 29
 
30 30
     {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 
31
-      'form_name'      : search_form_name,
32
-      'search_tags'    : search_tags_id
31
+      'form_name'               : search_form_name,
32
+      'search_tags'             : search_tags_id,
33
+      'display_specials_buttons': true
33 34
     } %}
34
-
35
-    <span class="help">{{ 'tags_filter.help'|trans({}, 'userui') }}</span>
36
-    <br />
37
-    <input type="submit" value="{{ 'filter.submit'|trans({}, 'userui') }}"/>
35
+    
36
+    <input class="main" type="submit" value="{{ 'filter.submit'|trans({}, 'userui') }}"/>
38 37
   </form>
39 38
 
40 39
   {% include "MuzichCoreBundle:SearchElement:default.html.twig" %}

+ 10 - 0
web/bundles/muzichcore/css/main.css View File

@@ -436,4 +436,14 @@ span.sinfo
436 436
   
437 437
   font-size: 85%;
438 438
   text-align: center;
439
+}
440
+
441
+input.main
442
+{
443
+  font-weight: bold;
444
+}
445
+
446
+input.clear, input.mytags
447
+{
448
+  font-size: 80%;
439 449
 }

+ 27 - 16
web/bundles/muzichcore/js/muzich.js View File

@@ -115,20 +115,31 @@ if(typeof(String.prototype.trim) === "undefined")
115 115
 
116 116
 $(document).ready(function(){
117 117
   
118
- // Affichage un/des embed
119
- $('a.element_embed_open_link').click(function(){
120
-   $(this).parent('li.element').find('a.element_embed_open_link').hide();
121
-   $(this).parent('li.element').find('a.element_embed_close_link').show();
122
-   $(this).parent('li.element').find('div.element_embed').show();
123
-   return false;
118
+   // Affichage un/des embed
119
+   $('a.element_embed_open_link').click(function(){
120
+     $(this).parent('li.element').find('a.element_embed_open_link').hide();
121
+     $(this).parent('li.element').find('a.element_embed_close_link').show();
122
+     $(this).parent('li.element').find('div.element_embed').show();
123
+     return false;
124
+   });
125
+
126
+   // Fermeture du embed si demandé
127
+   $('a.element_embed_close_link').click(function(){
128
+     $(this).parent('li.element').find('a.element_embed_open_link').show();
129
+     $(this).parent('li.element').find('a.element_embed_close_link').hide();
130
+     $(this).parent('li.element').find('div.element_embed').hide();
131
+     return false;
132
+   });
133
+   
134
+   // Bouton de personalisation du filtre
135
+   // pour le moment ce ne sotn que des redirection vers des actions
136
+   $('.tags_prompt input.clear').click(function(){
137
+     $(location).attr('href', $('input.filter_clear_url').val());
138
+   });
139
+   $('.tags_prompt input.mytags').click(function(){
140
+     $(location).attr('href', $('input.filter_mytags_url').val());
141
+   });
142
+   
124 143
  });
125
-
126
- // Fermeture du embed si demandé
127
- $('a.element_embed_close_link').click(function(){
128
-   $(this).parent('li.element').find('a.element_embed_open_link').show();
129
-   $(this).parent('li.element').find('a.element_embed_close_link').hide();
130
-   $(this).parent('li.element').find('div.element_embed').hide();
131
-   return false;
132
- });
133
-
134
- });
144
+ 
145
+ 

+ 6 - 0
web/js/tags/jquery.tagBox.js View File

@@ -172,6 +172,12 @@
172 172
               }
173 173
               $('input#'+form_name+'_tags').val(array2json(input_values));
174 174
             }
175
+            
176
+            // Suppression tu tableau js
177
+            if (inArray(tagsAddeds[form_name], id))
178
+            {
179
+              delete tagsAddeds[form_name][id];
180
+            }
175 181
         },
176 182
         updateInput : function() {
177 183