Browse Source

Evolution #774: Savoir si piste déjà présente dans playlist

Sevajol Bastien 11 years ago
parent
commit
33ff3120b7

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

135
   create_submit:         Ajouter
135
   create_submit:         Ajouter
136
   public_label:          Rendre cette liste publique
136
   public_label:          Rendre cette liste publique
137
   public_word:           (publique)
137
   public_word:           (publique)
138
+  contained:             La musique est déjà présente dans cette liste
139
+  not_contained:             La musique n'est pas présente dans cette liste

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

264
     return $elements_manager->have($element);
264
     return $elements_manager->have($element);
265
   }
265
   }
266
   
266
   
267
+  public function haveElementId($element_id)
268
+  {
269
+    $elements_manager = new ElementCollectionManager(json_decode($this->elements, true));
270
+    return $elements_manager->haveRefId($element_id);
271
+  }
272
+  
267
   public function setCopied(Playlist $copied)
273
   public function setCopied(Playlist $copied)
268
   {
274
   {
269
     $this->copied = $copied;
275
     $this->copied = $copied;

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

2386
   margin-top: 2px;
2386
   margin-top: 2px;
2387
 }
2387
 }
2388
 
2388
 
2389
+ul.playlists_for_element
2390
+{
2391
+  margin-left: 28px;
2392
+  margin-top: 8px;
2393
+}
2394
+
2395
+ul.playlists_for_element li
2396
+{
2397
+  list-style-image: url(/img/notin.png);
2398
+}
2399
+
2400
+ul.playlists_for_element li.in
2401
+{
2402
+  list-style-image: url(/img/in.png);
2403
+}
2404
+
2389
 /*
2405
 /*
2390
 *
2406
 *
2391
 *
2407
 *

+ 13 - 0
src/Muzich/CoreBundle/lib/Collection/CollectionManager.php View File

55
     return false;
55
     return false;
56
   }
56
   }
57
   
57
   
58
+  public function haveRefId($ref_id)
59
+  {
60
+    foreach ($this->content as $content_line)
61
+    {
62
+      if ($ref_id == $content_line[lcfirst($this->object_reference_attribute)])
63
+      {
64
+        return true;
65
+      }
66
+    }
67
+    
68
+    return false;
69
+  }
70
+  
58
   public function remove($object)
71
   public function remove($object)
59
   {
72
   {
60
     $new_content = array();
73
     $new_content = array();

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

15
     <h2>{{ 'playlist.add_to'|trans({}, 'elements') }}</h2>
15
     <h2>{{ 'playlist.add_to'|trans({}, 'elements') }}</h2>
16
     <ul class="playlists_for_element">
16
     <ul class="playlists_for_element">
17
       {% for playlist in playlists %}
17
       {% for playlist in playlists %}
18
-        <li class="playlist">
18
+        <li
19
+          class="playlist {% if playlist.haveElementId(element_id) %}in{% endif %}"
20
+          title="{% if playlist.haveElementId(element_id) %}{{ 'playlist.contained'|trans({}, 'elements') }}{% else %}{{ 'playlist.not_contained'|trans({}, 'elements') }}{% endif %}"
21
+        >
19
           <a class="add_element_to_playlist"
22
           <a class="add_element_to_playlist"
20
             {% if playlist.owned(app.user) %}
23
             {% if playlist.owned(app.user) %}
21
               href="{{ path_token('playlists_add_element', {
24
               href="{{ path_token('playlists_add_element', {

BIN
web/img/in.png View File


BIN
web/img/notin.png View File