Browse Source

Evolution #357: Maj interface d'ajout

Sevajol Bastien 12 years ago
parent
commit
f4c9256f6a

+ 1 - 0
app/Resources/translations/navigationui.fr.yml View File

23
   add_element:          Ajouter un élément
23
   add_element:          Ajouter un élément
24
   add_element_box:
24
   add_element_box:
25
     close:              Fermer
25
     close:              Fermer
26
+  check_url:            Ajouter
26
   
27
   
27
 group:
28
 group:
28
   add_element:          Ajouter un élément dans ce groupe
29
   add_element:          Ajouter un élément dans ce groupe

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

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

+ 23 - 0
src/Muzich/CoreBundle/Controller/ElementController.php View File

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 View File

903
     return false;
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 View File

155
   pattern: /what/are/you
155
   pattern: /what/are/you
156
   defaults: { _controller: MuzichCoreBundle:Info:teapot }
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 View File

4
 
4
 
5
 <span class="help">{{ 'element_add.url.help'|trans({}, 'userui') }}</span>
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
   {{ form_errors(form.url) }}
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
 </div>
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
 </div>
36
 </div>
30
 
37
 
31
 {{ form_row(form._token) }}
38
 {{ form_row(form._token) }}

+ 1 - 0
src/Muzich/CoreBundle/Resources/views/layout.html.twig View File

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

+ 18 - 4
src/Muzich/HomeBundle/Resources/views/Home/index.html.twig View File

4
 
4
 
5
 {% block content %}
5
 {% block content %}
6
 
6
 
7
+  {#
7
   <div id="element_add_box" style="display: none;">
8
   <div id="element_add_box" style="display: none;">
8
     
9
     
9
     <a href="#" id="element_add_close_link" class="button">
10
     <a href="#" id="element_add_close_link" class="button">
21
       <img class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
22
       <img class="tag_loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
22
     </form>
23
     </form>
23
   </div>
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
   <div id="added_element_to_group" style="display: none;">
43
   <div id="added_element_to_group" style="display: none;">
26
     <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
44
     <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading" />
35
     </p>
53
     </p>
36
   </div>
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
   <form name="{{ search_form_name }}" action="{{ path('search_elements') }}" method="post" {{ form_enctype(search_form) }}>
56
   <form name="{{ search_form_name }}" action="{{ path('search_elements') }}" method="post" {{ form_enctype(search_form) }}>
43
 
57
 
44
     {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 
58
     {% include "MuzichCoreBundle:SearchElement:form.html.twig" with { 

+ 28 - 2
web/bundles/muzichcore/js/muzich.js View File

1147
   }
1147
   }
1148
 
1148
 
1149
   // Ajout d'un element #ajouter
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
   $('form[name="add"] input[type="submit"]').live('click', function(){
1178
   $('form[name="add"] input[type="submit"]').live('click', function(){
1151
     $('form[name="add"]').find('img.tag_loader').show();
1179
     $('form[name="add"]').find('img.tag_loader').show();
1152
   });
1180
   });
1162
     return false;
1190
     return false;
1163
   });
1191
   });
1164
   
1192
   
1165
-  // Check périodique 
1166
-  // TODO.
1167
 
1193
 
1168
  /////////////////////
1194
  /////////////////////
1169
  var tags_ids_for_filter = new Array();
1195
  var tags_ids_for_filter = new Array();