Selaa lähdekoodia

Evolution #357: Maj interface d'ajout

Sevajol Bastien 12 vuotta sitten
vanhempi
commit
f4c9256f6a

+ 1 - 0
app/Resources/translations/navigationui.fr.yml Näytä tiedosto

@@ -23,6 +23,7 @@ home:
23 23
   add_element:          Ajouter un élément
24 24
   add_element_box:
25 25
     close:              Fermer
26
+  check_url:            Ajouter
26 27
   
27 28
 group:
28 29
   add_element:          Ajouter un élément dans ce groupe

+ 2 - 2
app/Resources/translations/userui.fr.yml Näytä tiedosto

@@ -79,14 +79,14 @@ filter:
79 79
   
80 80
 element_add:
81 81
   url:
82
-    name:     Lien
82
+    name:     http://
83 83
     help:     |
84 84
               Copier ici le lien internet (http://) pointant sur la ressource 
85 85
               que vous souhaitez partager.
86 86
   need_tags:
87 87
     name:     Demander de l'aide pour tagger votre partage
88 88
   name:
89
-    name:     Nom
89
+    name:     Titre de la piste - Artiste
90 90
     
91 91
   added_to_group:
92 92
     sentence:       |

+ 23 - 0
src/Muzich/CoreBundle/Controller/ElementController.php Näytä tiedosto

@@ -871,4 +871,27 @@ class ElementController extends Controller
871 871
     ));
872 872
   }
873 873
   
874
+  
875
+  public function getDatasApiAction(Request $request)
876
+  {
877
+    if (($response = $this->mustBeConnected(true)))
878
+    {
879
+      return $response;
880
+    }
881
+    
882
+    // On construit l'élèment qui va nous permettre de travailler avec l'api
883
+    $element = new Element();
884
+    $element->setUrl($request->get('url'));
885
+    
886
+    $factory = new ElementManager($element, $this->getEntityManager(), $this->container);
887
+    $factory->proceedFill($this->getUser());
888
+    
889
+    return $this->jsonResponse(array(
890
+      'status' => 'success',
891
+      'name'   => $element->getProposedName(),
892
+      'tags'   => $element->getProposedTags(),
893
+      'thumb'  => $element->getThumbnailUrl() 
894
+    ));
895
+  }
896
+  
874 897
 }

+ 21 - 0
src/Muzich/CoreBundle/Entity/Element.php Näytä tiedosto

@@ -903,4 +903,25 @@ class Element
903 903
     return false;
904 904
   }
905 905
   
906
+  public function getProposedName()
907
+  {
908
+    if (($title = $this->getData(self::DATA_TITLE)))
909
+    {
910
+      if (($artist = $this->getData(self::DATA_ARTIST)))
911
+      {
912
+        $artist = ' - '.$artist;
913
+      }
914
+      return $title.$artist;
915
+    }
916
+    return null;
917
+  }
918
+  
919
+  public function getProposedTags()
920
+  {
921
+    if (count($tags = $this->getData(self::DATA_TAGS)))
922
+    {
923
+      return $tags;
924
+    }
925
+  }
926
+  
906 927
 }

+ 7 - 1
src/Muzich/CoreBundle/Resources/config/routing.yml Näytä tiedosto

@@ -155,4 +155,10 @@ teapot:
155 155
   pattern: /what/are/you
156 156
   defaults: { _controller: MuzichCoreBundle:Info:teapot }
157 157
   
158
-  
158
+#
159
+
160
+element_retrieve_api_datas:
161
+  pattern: /ajax/element/get/datas/api
162
+  defaults: { _controller: MuzichCoreBundle:Element:getDatasApi }
163
+  requirements:
164
+    method:  POST

+ 23 - 16
src/Muzich/CoreBundle/Resources/views/Element/form.add.html.twig Näytä tiedosto

@@ -4,28 +4,35 @@
4 4
 
5 5
 <span class="help">{{ 'element_add.url.help'|trans({}, 'userui') }}</span>
6 6
 
7
-<div class="field">
7
+<div class="field fom_add_url">
8 8
   {{ form_errors(form.url) }}
9
-  {{ form_label(form.url, 'element_add.url.name'|trans({}, 'userui')) }}
10
-  {{ form_widget(form.url) }}
9
+  {{ form_widget(form.url, { 'attr': {
10
+    'placeholder': 'element_add.url.name'|trans({}, 'userui')},
11
+    'type': 'URL'
12
+  }) }}
13
+    
14
+  <a href="#" id="form_add_check_url" class="button">
15
+    {{ 'home.check_url'|trans({}, 'navigationui') }}
16
+  </a>
11 17
 </div>
12 18
 
13
-<div class="field">
14
-  {{ form_errors(form.name) }}
15
-  {{ form_label(form.name, 'element_add.name.name'|trans({}, 'userui')) }}
16
-  {{ form_widget(form.name) }}
17
-</div>
19
+<div class="form_add_second_part" style="display: none;">
20
+  <div class="field fom_add_name">
21
+    {{ form_errors(form.name) }}
22
+    {{ form_widget(form.name, { 'attr': {'placeholder': 'element_add.name.name'|trans({}, 'userui')} }) }}
23
+  </div>
18 24
 
19
-  {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 
20
-    'form_name'     : form_name
21
-  } %}
25
+    {% include "MuzichCoreBundle:Tag:tagsPrompt.html.twig" with { 
26
+      'form_name'     : form_name
27
+    } %}
22 28
 
23
-  {{ form_widget(form.tags, { 'attr': {'class': 'tagBox_tags_ids'} }) }}
29
+    {{ form_widget(form.tags, { 'attr': {'class': 'tagBox_tags_ids'} }) }}
24 30
 
25
-<div class="field">
26
-  {{ form_errors(form.need_tags) }}
27
-  {{ form_widget(form.need_tags) }}
28
-  {{ form_label(form.need_tags, 'element_add.need_tags.name'|trans({}, 'userui')) }}
31
+  <div class="field">
32
+    {{ form_errors(form.need_tags) }}
33
+    {{ form_widget(form.need_tags) }}
34
+    {{ form_label(form.need_tags, 'element_add.need_tags.name'|trans({}, 'userui')) }}
35
+  </div>
29 36
 </div>
30 37
 
31 38
 {{ form_row(form._token) }}

+ 1 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig Näytä tiedosto

@@ -63,6 +63,7 @@
63 63
     url_element_new_count = "{{ path('element_new_count') }}";
64 64
     url_element_new_get = "{{ path('element_new_get') }}";
65 65
     url_global_search = "{{ path('global_search') }}";
66
+    url_datas_api = "{{ path('element_retrieve_api_datas') }}";
66 67
     
67 68
     url_img_ajax_loader = "{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}";
68 69
   </script>

+ 18 - 4
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig Näytä tiedosto

@@ -4,6 +4,7 @@
4 4
 
5 5
 {% block content %}
6 6
 
7
+  {#
7 8
   <div id="element_add_box" style="display: none;">
8 9
     
9 10
     <a href="#" id="element_add_close_link" class="button">
@@ -21,6 +22,23 @@
21 22
       <img class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
22 23
     </form>
23 24
   </div>
25
+  #}
26
+
27
+  <div id="element_add_box">    
28
+    
29
+    <img class="tag_loader" style="display: none;" 
30
+      src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" 
31
+    />
32
+
33
+    <form novalidate name="{{ add_form_name }}" action="{{ path('element_add') }}" method="post" {{ form_enctype(add_form) }}>
34
+
35
+      {% include "MuzichCoreBundle:Element:form.add.html.twig" with { 
36
+        'form'          : add_form, 
37
+        'form_name'     : add_form_name
38
+      } %}
39
+
40
+    </form>
41
+  </div>
24 42
 
25 43
   <div id="added_element_to_group" style="display: none;">
26 44
     <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
@@ -35,10 +53,6 @@
35 53
     </p>
36 54
   </div>
37 55
 
38
-  <a href="#" id="element_add_link" class="button">
39
-    {{ 'home.add_element'|trans({}, 'navigationui') }} &gt;&gt;
40
-  </a>
41
-
42 56
   <form name="{{ search_form_name }}" action="{{ path('search_elements') }}" method="post" {{ form_enctype(search_form) }}>
43 57
 
44 58
     {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 

+ 28 - 2
web/bundles/muzichcore/js/muzich.js Näytä tiedosto

@@ -1147,6 +1147,34 @@ $(document).ready(function(){
1147 1147
   }
1148 1148
 
1149 1149
   // Ajout d'un element #ajouter
1150
+  
1151
+  // Click sur "ajouter" (l'url)
1152
+  $('a#form_add_check_url').click(function(){
1153
+    
1154
+    $.ajax({
1155
+      type: 'POST',
1156
+      url: url_datas_api,
1157
+      data: {'url':$('input#element_add_url').val()},
1158
+      success: function(response){
1159
+        
1160
+        console.debug(response);
1161
+        
1162
+        if (response.status == 'mustbeconnected')
1163
+        {
1164
+          $(location).attr('href', url_index);
1165
+        }
1166
+
1167
+        if (response.status == 'success')
1168
+        {
1169
+
1170
+        }
1171
+      },
1172
+      dataType: 'json'
1173
+    });
1174
+    
1175
+  });
1176
+  
1177
+  
1150 1178
   $('form[name="add"] input[type="submit"]').live('click', function(){
1151 1179
     $('form[name="add"]').find('img.tag_loader').show();
1152 1180
   });
@@ -1162,8 +1190,6 @@ $(document).ready(function(){
1162 1190
     return false;
1163 1191
   });
1164 1192
   
1165
-  // Check périodique 
1166
-  // TODO.
1167 1193
 
1168 1194
  /////////////////////
1169 1195
  var tags_ids_for_filter = new Array();