Bläddra i källkod

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

Bastien Sevajol 11 år sedan
förälder
incheckning
8a82d890ff

+ 22 - 0
src/Muzich/CoreBundle/Entity/Playlist.php Visa fil

@@ -270,6 +270,12 @@ class Playlist
270 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 279
   public function setCopied(Playlist $copied)
274 280
   {
275 281
     $this->copied = $copied;
@@ -305,4 +311,20 @@ class Playlist
305 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 Visa fil

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

+ 5 - 1
src/Muzich/PlaylistBundle/Controller/ShowController.php Visa fil

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

+ 5 - 5
src/Muzich/PlaylistBundle/Resources/views/Show/prompt.html.twig Visa fil

@@ -5,7 +5,7 @@
5 5
 
6 6
 <div class="create_playlist">
7 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 9
     {% include 'MuzichPlaylistBundle:Show:form.html.twig' with {
10 10
       'display_public_widget' : true
11 11
     } %}
@@ -18,19 +18,19 @@
18 18
     <ul class="playlists_for_element">
19 19
       {% for playlist in playlists %}
20 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 24
           <a class="add_element_to_playlist"
25 25
             {% if playlist.owned(app.user) %}
26 26
               href="{{ path_token('playlists_add_element', {
27 27
                 'playlist_id' : playlist.id,
28
-                'element_id'  : element_id
28
+                'element_id'  : element.id
29 29
               }) }}"
30 30
             {% else %}
31 31
               href="{{ path_token('playlists_add_element_and_copy', {
32 32
                 'playlist_id' : playlist.id,
33
-                'element_id'  : element_id
33
+                'element_id'  : element.id
34 34
               }) }}"
35 35
             {% endif %}
36 36
           >