modified: SRC/app/Http/Controllers/ReferentController.php

modified:   SRC/app/Http/routes.php
	modified:   SRC/public/js/ListeOeuvre.js
	modified:   SRC/resources/views/referent.blade.php
This commit is contained in:
Malibu 2015-02-23 19:35:01 +01:00
parent 695adc5d3a
commit 8a0f8a5b3c
4 changed files with 49 additions and 16 deletions

View File

@ -12,6 +12,7 @@ use App\Models\Matiere;
use App\Models\Technique; use App\Models\Technique;
use App\Models\Oeuvre; use App\Models\Oeuvre;
use Response; use Response;
use Illuminate\Pagination\Paginator as Paginator;
class ReferentController extends Controller { class ReferentController extends Controller {
@ -44,9 +45,6 @@ class ReferentController extends Controller {
$dataSearch['matiere'] = Matiere::orderBy('nom')->get(); $dataSearch['matiere'] = Matiere::orderBy('nom')->get();
$dataSearch['technique'] = Technique::orderBy('nom')->get(); $dataSearch['technique'] = Technique::orderBy('nom')->get();
//$ListeOeuvre = ListeOeuvre::find(2);
//$ListeOeuvre->oeuvres()->attach([22, 23, 24, 25, 26]);
$listeoeuvres = ListeOeuvre::currentUser()->get(); $listeoeuvres = ListeOeuvre::currentUser()->get();
return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'listeoeuvres' => $listeoeuvres, 'data' => $dataSearch]); return view('referent', ['nameRoute' => 'Référent', 'me' => $me, 'listeoeuvres' => $listeoeuvres, 'data' => $dataSearch]);
} }
@ -137,7 +135,7 @@ class ReferentController extends Controller {
->matiereFilter($matieres) ->matiereFilter($matieres)
->debutFilter($debut) ->debutFilter($debut)
->finFilter($fin) ->finFilter($fin)
->get(); ->paginate(15);
return Response::json($res->toArray()); return Response::json($res->toArray());
} }

View File

@ -40,7 +40,7 @@ Route::group(['middleware' => 'auth'], function ()
Route::post('addListeOeuvre', 'ReferentController@addListeOeuvre'); Route::post('addListeOeuvre', 'ReferentController@addListeOeuvre');
Route::get('showListOeuvres/{id}', 'ReferentController@showListeOeuvres'); Route::get('showListOeuvres/{id}', 'ReferentController@showListeOeuvres');
Route::post('setListOeuvres', 'ReferentController@setListOeuvres'); Route::post('setListOeuvres', 'ReferentController@setListOeuvres');
Route::post('search', 'ReferentController@search'); Route::post('search/', 'ReferentController@search');
}); });
Route::group(['middleware' => 'admin'], function () Route::group(['middleware' => 'admin'], function ()

View File

@ -57,9 +57,22 @@ $('#enregistrer').click(function() {
// Afficher résultat de recherche d'oeuvre // Afficher résultat de recherche d'oeuvre
$('#search_button').click(function() { $('#search_button, #previous, #next').click(function(event) {
$('#oeuvreRes').empty();
event.preventDefault();
if (this.id == $('#next').attr('id')) {
str = $("#next").attr('href');
console.log(/([0-9]+)/.exec(str));
url = "/search?page="+/([0-9]+)/.exec(str)[0];
}else if (this.id == $('#previous').attr('id')) {
str = $("#previous").attr('href');
url = "/search?page="+/([0-9]+)/.exec(str)[0];
}else {
url = "/search"; url = "/search";
}
$('#oeuvreRes').empty();
dataSend = { dataSend = {
_token : $('#_tokenRes').val(), _token : $('#_tokenRes').val(),
auteur: $('#auteur').val(), auteur: $('#auteur').val(),
@ -76,12 +89,27 @@ $('#search_button').click(function() {
console.log(data); console.log(data);
if (data.length == 0 ) if (data.length == 0 )
$("#oeuvreRes").append("Aucune Oeuvre Trouvé.."); $("#oeuvreRes").append("Aucune Oeuvre Trouvé..");
data.forEach( function(el) { data.data.forEach( function(el) {
$("#oeuvreRes").append('<div class="col-xs-4 col-md-3">' $("#oeuvreRes").append('<div class="col-xs-4 col-md-3">'
+'<a href="#" class="thumbnail">' +'<a href="#" class="thumbnail">'
+'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>' +'<img src="http://www.augustins.org/documents/10180/156407/' + el.urlPhoto + '"/>'
+'</a></div>'); +'</a></div>');
}) });
if(data.prev_page_url == null) {
$("#previous").parent().addClass('disabled');
}else {
$("#previous").attr('href', data.prev_page_url);
$("#previous").parent().removeClass('disabled');
}
if(data.next_page_url == null) {
$("#next").parent().addClass('disabled');
}else {
$("#next").attr('href', data.next_page_url);
$("#next").parent().removeClass('disabled');
}
}, "json" ) }, "json" )
.fail(function() { .fail(function() {

View File

@ -198,7 +198,14 @@
</div> </div>
</div> </div>
<button style="float: right" class="btn btn-primary" id="enregistrer">Enregistrer</button>
<nav>
<ul class="pager">
<li class="previous disabled"><a id="previous" href=""><span aria-hidden="true">&larr;</span> Précédent</a></li>
<li class="next disabled"><a id="next" href="">Suivant <span aria-hidden="true">&rarr;</span></a></li>
</ul>
</nav>
<button style="float: right" class="btn btn-primary" id="ajouter">Ajouter à ma liste d'oeuvre</button>
</div> </div>
@endsection @endsection