Browse Source

Evolution #789: Playlist: prompt: mettre en évidence les plsylists en fct des tags

Bastien Sevajol 11 years ago
parent
commit
8a82d890ff

+ 22 - 0
src/Muzich/CoreBundle/Entity/Playlist.php View File

270
     return $elements_manager->haveRefId($element_id);
270
     return $elements_manager->haveRefId($element_id);
271
   }
271
   }
272
   
272
   
273
+  public function haveTagId($tag_id)
274
+  {
275
+    $tags_manager = new TagCollectionManager(json_decode($this->tags, true));
276
+    return $tags_manager->haveRefId($tag_id);
277
+  }
278
+  
273
   public function setCopied(Playlist $copied)
279
   public function setCopied(Playlist $copied)
274
   {
280
   {
275
     $this->copied = $copied;
281
     $this->copied = $copied;
305
     return false;
311
     return false;
306
   }
312
   }
307
   
313
   
314
+  public function haveOneOfTags($tags)
315
+  {
316
+    if (count($tags))
317
+    {
318
+      foreach ($tags as $tag)
319
+      {
320
+        if ($this->haveTagId($tag->getId()))
321
+        {
322
+          return true;
323
+        }
324
+      }
325
+    }
326
+    
327
+    return false;
328
+  }
329
+  
308
 }
330
 }

+ 5 - 0
src/Muzich/CoreBundle/Resources/public/css/main.css View File

2333
   margin-right: -5px;
2333
   margin-right: -5px;
2334
 }
2334
 }
2335
 
2335
 
2336
+li.playlist.remarquable
2337
+{
2338
+  font-weight: bold;
2339
+}
2340
+
2336
 ul.form-errors
2341
 ul.form-errors
2337
 {
2342
 {
2338
   margin-left: 10px;
2343
   margin-left: 10px;

+ 5 - 1
src/Muzich/PlaylistBundle/Controller/ShowController.php View File

62
     if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_ADD_PROMPT)) !== false)
62
     if (($uncondition = $this->userHaveNonConditionToMakeAction(SecurityContext::ACTION_PLAYLIST_ADD_PROMPT)) !== false)
63
       return $this->jsonResponseError($uncondition);
63
       return $this->jsonResponseError($uncondition);
64
     
64
     
65
+    if (!($element = $this->getElementWithId($element_id)))
66
+      return $this->jsonNotFoundResponse();
67
+    
68
+    
65
     return $this->jsonSuccessResponse(
69
     return $this->jsonSuccessResponse(
66
       $this->render('MuzichPlaylistBundle:Show:prompt.html.twig', array(
70
       $this->render('MuzichPlaylistBundle:Show:prompt.html.twig', array(
67
         'form'       => $this->getPlaylistForm()->createView(),
71
         'form'       => $this->getPlaylistForm()->createView(),
68
-        'element_id' => $element_id,
72
+        'element'    => $element,
69
         'playlists'  => (!$this->isVisitor())?$this->getPlaylistManager()->getOwnedsOrPickedsPlaylists($this->getUser()):array()
73
         'playlists'  => (!$this->isVisitor())?$this->getPlaylistManager()->getOwnedsOrPickedsPlaylists($this->getUser()):array()
70
       ))->getContent()
74
       ))->getContent()
71
     );
75
     );

+ 5 - 5
src/Muzich/PlaylistBundle/Resources/views/Show/prompt.html.twig View File

5
 
5
 
6
 <div class="create_playlist">
6
 <div class="create_playlist">
7
   <h2 class="nomargintop">{{ 'playlist.create_and_add'|trans({}, 'elements') }}</h2>
7
   <h2 class="nomargintop">{{ 'playlist.create_and_add'|trans({}, 'elements') }}</h2>
8
-  <form action="{{ path('playlist_add_element_and_create', { 'element_id' : element_id }) }}" method="post">
8
+  <form action="{{ path('playlist_add_element_and_create', { 'element_id' : element.id }) }}" method="post">
9
     {% include 'MuzichPlaylistBundle:Show:form.html.twig' with {
9
     {% include 'MuzichPlaylistBundle:Show:form.html.twig' with {
10
       'display_public_widget' : true
10
       'display_public_widget' : true
11
     } %}
11
     } %}
18
     <ul class="playlists_for_element">
18
     <ul class="playlists_for_element">
19
       {% for playlist in playlists %}
19
       {% for playlist in playlists %}
20
         <li
20
         <li
21
-          class="playlist {% if playlist.haveElementId(element_id) %}in{% endif %}"
22
-          title="{% if playlist.haveElementId(element_id) %}{{ 'playlist.contained'|trans({}, 'elements') }}{% else %}{{ 'playlist.not_contained'|trans({}, 'elements') }}{% endif %}"
21
+          class="playlist{% if playlist.haveElementId(element.id) %} in{% endif %}{% if playlist.haveOneOfTags(element.tags) %} remarquable{% endif %}"
22
+          title="{% if playlist.haveElementId(element.id) %}{{ 'playlist.contained'|trans({}, 'elements') }}{% else %}{{ 'playlist.not_contained'|trans({}, 'elements') }}{% endif %}"
23
         >
23
         >
24
           <a class="add_element_to_playlist"
24
           <a class="add_element_to_playlist"
25
             {% if playlist.owned(app.user) %}
25
             {% if playlist.owned(app.user) %}
26
               href="{{ path_token('playlists_add_element', {
26
               href="{{ path_token('playlists_add_element', {
27
                 'playlist_id' : playlist.id,
27
                 'playlist_id' : playlist.id,
28
-                'element_id'  : element_id
28
+                'element_id'  : element.id
29
               }) }}"
29
               }) }}"
30
             {% else %}
30
             {% else %}
31
               href="{{ path_token('playlists_add_element_and_copy', {
31
               href="{{ path_token('playlists_add_element_and_copy', {
32
                 'playlist_id' : playlist.id,
32
                 'playlist_id' : playlist.id,
33
-                'element_id'  : element_id
33
+                'element_id'  : element.id
34
               }) }}"
34
               }) }}"
35
             {% endif %}
35
             {% endif %}
36
           >
36
           >