Browse Source

Evolution #164: Proposition de tag sur un élément

bastien 12 years ago
parent
commit
1bc5c07f27

+ 4 - 0
app/Resources/translations/users.fr.yml View File

@@ -25,6 +25,10 @@ events:
25 25
     no:                         Pas de nouveaux utilisateurs qui vous suivent
26 26
     one:                        %count% nouvel utilisateur vous suis
27 27
     yes:                        %count% nouveaux utilisateurs vous suivent
28
+  new_tags:
29
+    no:                         Pas de nouvelle proposition de tags
30
+    one:                        %count% nouveau partage avec proposition de tags
31
+    yes:                        %count% nouveaux partages avec proposition de tags
28 32
     
29 33
 reputation:
30 34
   bar:

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

@@ -67,6 +67,7 @@ filter:
67 67
   network_my:    Mon réseau
68 68
   new_comments:     Nvx commentaires
69 69
   new_favoriteds:   Nvx favoris
70
+  new_tags:         Propositions de tags
70 71
   
71 72
 element_add:
72 73
   url:

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

@@ -615,6 +615,7 @@ class CoreController extends Controller
615 615
     
616 616
     $es = $this->getElementSearcher();
617 617
     $es->setIds(null);
618
+    $es->setIdsDisplay(null);
618 619
     $this->setElementSearcherParams($es->getParams());
619 620
     
620 621
     $html = $this->render('MuzichCoreBundle:SearchElement:default.html.twig', array(

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

@@ -553,6 +553,15 @@ class ElementController extends Controller
553 553
       ));
554 554
     }
555 555
     
556
+    // On ne doit pas pouvoir proposer de tags sur son propre élément
557
+    if ($element->getOwner()->getId() == $this->getUserId())
558
+    {
559
+      return $this->jsonResponse(array(
560
+        'status' => 'error',
561
+        'errors' => array('NotAllowed')
562
+      ));
563
+    }
564
+    
556 565
     $values   = $this->getRequest()->request->get('element_tag_proposition_'.$element->getId());
557 566
     $tags_ids = json_decode($values['tags'], true);
558 567
     
@@ -597,6 +606,11 @@ class ElementController extends Controller
597 606
     
598 607
     $this->getDoctrine()->getEntityManager()->persist($element);
599 608
     $this->getDoctrine()->getEntityManager()->persist($proposition);
609
+    
610
+    // Notifs etc 
611
+    $event = new EventElement($this->container);
612
+    $event->tagsProposed($element);
613
+    
600 614
     $this->getDoctrine()->getEntityManager()->flush();
601 615
     
602 616
     return $this->jsonResponse(array(

+ 1 - 0
src/Muzich/CoreBundle/Entity/Event.php View File

@@ -21,6 +21,7 @@ class Event
21 21
   const TYPE_COMMENT_ADDED_ELEMENT = "com.adde.ele";
22 22
   const TYPE_FAV_ADDED_ELEMENT     = "fav.adde.ele";
23 23
   const TYPE_USER_FOLLOW           = "user.follow";
24
+  const TYPE_TAGS_PROPOSED         = "tags.prop.ad";
24 25
   
25 26
   /**
26 27
    * @ORM\Id

+ 3 - 0
src/Muzich/CoreBundle/Extension/MyTwigExtension.php View File

@@ -131,6 +131,9 @@ class MyTwigExtension extends \Twig_Extension {
131 131
       case 'TYPE_USER_FOLLOW':
132 132
         return Event::TYPE_USER_FOLLOW;
133 133
       break;
134
+      case 'TYPE_TAGS_PROPOSED':
135
+        return Event::TYPE_TAGS_PROPOSED;
136
+      break;
134 137
       default:
135 138
         throw new \Exception('Constante non géré dans MyTwigExtension::event_const');
136 139
       break;

+ 12 - 0
src/Muzich/CoreBundle/Propagator/EventElement.php View File

@@ -124,4 +124,16 @@ class EventElement extends EventPropagator
124 124
     );
125 125
   }
126 126
   
127
+  /**
128
+   * Des tags viennent d'être proposé a un élément
129
+   *
130
+   * @param Element $element 
131
+   */
132
+  public function tagsProposed(Element $element)
133
+  {
134
+    $uea = new UserEventAction($element->getOwner(), $this->container);
135
+    $event = $uea->proceed(Event::TYPE_TAGS_PROPOSED, $element->getId());
136
+    $this->container->get('doctrine')->getEntityManager()->persist($event);
137
+  }
138
+  
127 139
 }

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

@@ -17,18 +17,28 @@
17 17
   </div>
18 18
 
19 19
   <div class="more_filters">
20
+    
20 21
     <a href="{{ path('ajax_filter_remove_ids') }}" class="button active new_comments" 
21 22
        style="{% if ids_display != event_const('TYPE_COMMENT_ADDED_ELEMENT') %}display: none;{% endif %}"
22 23
     >
23 24
       {{ 'filter.new_comments'|trans({}, 'userui') }}
24 25
       <img src="{{ asset('bundles/muzichcore/img/1328276855_list-remove.png') }}" alt="remove" />
25 26
     </a>
27
+      
26 28
     <a href="{{ path('ajax_filter_remove_ids') }}" class="button active new_favorites" 
27 29
        style="{% if ids_display != event_const('TYPE_FAV_ADDED_ELEMENT') %}display: none;{% endif %}"
28 30
     >
29 31
       {{ 'filter.new_favoriteds'|trans({}, 'userui') }}
30 32
       <img src="{{ asset('bundles/muzichcore/img/1328276855_list-remove.png') }}" alt="remove" />
31 33
     </a>
34
+      
35
+    <a href="{{ path('ajax_filter_remove_ids') }}" class="button active new_tags" 
36
+       style="{% if ids_display != event_const('TYPE_TAGS_PROPOSED') %}display: none;{% endif %}"
37
+    >
38
+      {{ 'filter.new_tags'|trans({}, 'userui') }}
39
+      <img src="{{ asset('bundles/muzichcore/img/1328276855_list-remove.png') }}" alt="remove" />
40
+    </a>
41
+    
32 42
   </div>
33 43
   
34 44
   {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 

+ 18 - 0
src/Muzich/UserBundle/Resources/views/Info/bar.html.twig View File

@@ -59,6 +59,24 @@
59 59
         {% endif %}
60 60
           
61 61
     </div>
62
+    
63
+    <div class="tags">
64
+      
65
+        {% if events[event_const('TYPE_TAGS_PROPOSED')] is defined %}
66
+          <a 
67
+            href="{{ path('event_view_elements', {'event_id':events[event_const('TYPE_TAGS_PROPOSED')].id}) }}" 
68
+            title="{%if events[event_const('TYPE_TAGS_PROPOSED')].count == 1 %}{{ 'events.new_tags.one'|trans({'%count%':1}, 'users') }}{% else %}{{ 'events.new_tags.yes'|trans({'%count%':events[event_const('TYPE_TAGS_PROPOSED')].count}, 'users') }}{% endif %}"
69
+            class="view_follows_event"
70
+          >
71
+            <img src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags" />
72
+            <span class="new_follows">{{ events[event_const('TYPE_TAGS_PROPOSED')].count }}</span>
73
+          </a>
74
+        {% else %}
75
+          <img title="{{ 'events.new_tags.no'|trans({}, 'users') }}" src="{{ asset('bundles/muzichcore/img/1333484018_rss-tag.png') }}" alt="tags" />
76
+          <span class="new_follows">0</span>
77
+        {% endif %}
78
+          
79
+    </div>
62 80
   
63 81
   
64 82
   </div>

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

@@ -1168,6 +1168,18 @@ div#events div.follows span
1168 1168
   margin-left: 5px;
1169 1169
 }
1170 1170
 
1171
+div#events div.tags img
1172
+{
1173
+  margin-left: 3px;
1174
+  margin-bottom: -2px;
1175
+}
1176
+
1177
+div#events div.tags span
1178
+{
1179
+  font-weight: bold;
1180
+  margin-left: 5px;
1181
+}
1182
+
1171 1183
 /*
1172 1184
 * css mynetwork
1173 1185
 */

+ 1 - 1
web/bundles/muzichcore/js/muzich.js View File

@@ -1685,7 +1685,7 @@ $(document).ready(function(){
1685 1685
   
1686 1686
   
1687 1687
   // Enlever les ids du ElementSearch
1688
-  $('div.more_filters a.new_comments, div.more_filters a.new_favorites').live('click', function(){
1688
+  $('div.more_filters a.new_comments, div.more_filters a.new_favorites, div.more_filters a.tags').live('click', function(){
1689 1689
     
1690 1690
     $('img.elements_more_loader').show();
1691 1691
     $('ul.elements').html('');

+ 10 - 1
web/bundles/muzichhome/css/home.css View File

@@ -94,7 +94,16 @@ div.more_filters a.new_favorites
94 94
   background-position: 2px 3px;
95 95
 }
96 96
 
97
-div.more_filters a.new_comments img, div.more_filters a.new_favorites img
97
+div.more_filters a.new_tags
98
+{
99
+  margin-top: 5px;
100
+  padding-left: 20px;
101
+  background-image: url(/bundles/muzichcore/img/1333484018_rss-tag.png);
102
+  background-repeat: no-repeat;
103
+  background-position: 2px 3px;
104
+}
105
+
106
+div.more_filters a.new_comments img, div.more_filters a.new_favorites img, div.more_filters a.new_tags img
98 107
 {
99 108
   margin-bottom: -3px;
100 109
 }