Procházet zdrojové kódy

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

Sevajol Bastien před 11 roky
rodič
revize
33ff3120b7

+ 2 - 0
app/Resources/translations/elements.fr.yml Zobrazit soubor

@@ -135,3 +135,5 @@ playlist:
135 135
   create_submit:         Ajouter
136 136
   public_label:          Rendre cette liste publique
137 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 Zobrazit soubor

@@ -264,6 +264,12 @@ class Playlist
264 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 273
   public function setCopied(Playlist $copied)
268 274
   {
269 275
     $this->copied = $copied;

+ 16 - 0
src/Muzich/CoreBundle/Resources/public/css/main.css Zobrazit soubor

@@ -2386,6 +2386,22 @@ a.button_arrow span
2386 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 Zobrazit soubor

@@ -55,6 +55,19 @@ abstract class CollectionManager
55 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 71
   public function remove($object)
59 72
   {
60 73
     $new_content = array();

+ 4 - 1
src/Muzich/PlaylistBundle/Resources/views/Show/prompt.html.twig Zobrazit soubor

@@ -15,7 +15,10 @@
15 15
     <h2>{{ 'playlist.add_to'|trans({}, 'elements') }}</h2>
16 16
     <ul class="playlists_for_element">
17 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 22
           <a class="add_element_to_playlist"
20 23
             {% if playlist.owned(app.user) %}
21 24
               href="{{ path_token('playlists_add_element', {

binární
web/img/in.png Zobrazit soubor


binární
web/img/notin.png Zobrazit soubor