Selaa lähdekoodia

[Frontend] Barre navigation commune frontend/producer

feature/souke
Guillaume Bourgeois 1 vuosi sitten
vanhempi
commit
ba3f41d718
6 muutettua tiedostoa jossa 104 lisäystä ja 48 poistoa
  1. +1
    -0
      common/assets/CommonAsset.php
  2. +79
    -44
      common/views/nav_user_top.php
  3. +3
    -1
      frontend/views/layouts/main.php
  4. +11
    -0
      frontend/web/js/frontend.js
  5. +3
    -1
      producer/views/layouts/main.php
  6. +7
    -2
      producer/web/js/producer.js

+ 1
- 0
common/assets/CommonAsset.php Näytä tiedosto

$this->addAsset('css','css/screen.css') ; $this->addAsset('css','css/screen.css') ;
// js // js
$this->addAsset('js','bootstrap/js/bootstrap.min.js') ;
$this->addAsset('js','js/jquery-ui-1.11.4.custom/jquery-ui.min.js'); $this->addAsset('js','js/jquery-ui-1.11.4.custom/jquery-ui.min.js');
$this->addAsset('js','js/promise-polyfill/promise.min.js'); $this->addAsset('js','js/promise-polyfill/promise.min.js');
$this->addAsset('js','js/axios/axios.min.js'); $this->addAsset('js','js/axios/axios.min.js');

+ 79
- 44
common/views/nav_user_top.php Näytä tiedosto



$userManager = UserManager::getInstance(); $userManager = UserManager::getInstance();


$producer = null;
if ($userManager->isCurrentProducer()) {
$producer = Producer::searchOne(['id' => \Yii::$app->user->identity->id_producer]);
}

?> ?>


<section class="nav-user-top"> <section class="nav-user-top">
$itemsProducersArray = []; $itemsProducersArray = [];
if (count($producersArray)) { if (count($producersArray)) {
$itemsProducersArray[] = [ $itemsProducersArray[] = [
'options' => ['class' => 'dropdown-header'],
'label' => 'Mes favoris', 'label' => 'Mes favoris',
]; ];

foreach($producersArray as $producerItem) { foreach($producersArray as $producerItem) {
$itemsProducersArray[] = [ $itemsProducersArray[] = [
'label' => Html::encode($producerItem->name), 'label' => Html::encode($producerItem->name),
]; ];
} }
} }
else {
$itemsProducersArray[] = [
'label' => 'Aucun producteur dans vos favoris.',
];
}


$itemsProducersArray[] = [ $itemsProducersArray[] = [
'options' => ['class' => 'divider'], 'options' => ['class' => 'divider'],
'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers']) 'url' => $this->getUrlManagerFrontend()->createAbsoluteUrl(['site/producers'])
]; ];


echo Nav::widget([
'encodeLabels' => false,
'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
// Items du menu
$itemAdministration = [
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>',
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']),
'visible' => $userManager->isCurrentProducer()
];
$itemProducerSpace = [
'label' => '<span class="glyphicon glyphicon-grain"></span> <span class="link-text">Espace producteur</span>',
'url' => $this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer ? $producer->slug : '']),
'visible' => $userManager->isCurrentProducer()
];
$itemProducers = [
'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Producteurs</span>',
'url' => '#',
'items' => $itemsProducersArray,
'visible' => !Yii::$app->user->isGuest
];
$itemUser = [
'label' => '<span class="glyphicon glyphicon-user"></span> <span class="link-text">' . ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '. </span>',
'options' => ['id' => 'label1'],
'url' => '#',
'items' => [ 'items' => [
[ [
'label' => '<span class="glyphicon glyphicon-cog"></span> <span class="link-text">Administration</span>',
'url' => $this->getUrlManagerBackend()->createAbsoluteUrl(['site/index']),
'visible' => $userManager->isCurrentProducer()
],
[
'label' => '<span class="glyphicon glyphicon-star"></span> <span class="link-text">Producteurs</span>',
'url' => '#',
'items' => $itemsProducersArray,
'visible' => !Yii::$app->user->isGuest
],
[
'label' => '<span class="glyphicon glyphicon-user"></span> <span class="link-text">' . ((!Yii::$app->user->isGuest) ? Html::encode(Yii::$app->user->identity->name . ' ' . strtoupper(substr(Yii::$app->user->identity->lastname, 0, 1))) : '') . '. </span>',
'options' => ['id' => 'label1'],
'url' => '#',
'items' => [
[
'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/index']),
],
[
'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil',
'url' => $this->getUrlManagerFrontend()->createUrl(['user/update']),
],
[
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/logout']),
]
],
'visible' => !Yii::$app->user->isGuest
'label' => '<span class="glyphicon glyphicon-chevron-left"></span> Retour à l\'accueil',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/index']),
], ],
[ [
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/login']),
'visible' => \Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'site/login'
'label' => '<span class="glyphicon glyphicon-user"></span> Mon profil',
'url' => $this->getUrlManagerFrontend()->createUrl(['user/update']),
], ],
[ [
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/signup']),
'visible' => \Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'site/signup'
],
]]);
'label' => '<span class="glyphicon glyphicon-off"></span> Déconnexion',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/logout']),
]
],
'visible' => !Yii::$app->user->isGuest
];
$itemConnexion = [
'label' => '<span class="glyphicon glyphicon-log-in"></span> Connexion',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/login']),
'visible' => \Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'site/login'
];
$itemSignup = [
'label' => '<span class="glyphicon glyphicon-user"></span> Inscription',
'url' => $this->getUrlManagerFrontend()->createUrl(['site/signup']),
'visible' => \Yii::$app->user->isGuest,
'active' => $this->getControllerAction() == 'site/signup'
];

if($context == 'frontend') {
$itemsMenu = [
$itemAdministration,
$itemProducerSpace,
$itemProducers,
$itemUser,
$itemConnexion,
$itemSignup
];
}
elseif($context == 'producer') {
$itemsMenu = [
$itemAdministration,
$itemProducers,
$itemUser,
$itemConnexion,
$itemSignup
];
}

echo Nav::widget([
'encodeLabels' => false,
'options' => ['class' => 'nav nav-pills navbar-nav navbar-right'],
'items' => $itemsMenu
]);
?> ?>
</div> </div>
</nav> </nav>

+ 3
- 1
frontend/views/layouts/main.php Näytä tiedosto

<?php $this->beginBody() ?> <?php $this->beginBody() ?>
<div id="back"></div> <div id="back"></div>


<?= $this->render('@common/views/nav_user_top'); ?>
<?= $this->render('@common/views/nav_user_top', [
'context' => 'frontend'
]); ?>


<header id="header"> <header id="header">
<nav class="navbar navbar-default"> <nav class="navbar navbar-default">

+ 11
- 0
frontend/web/js/frontend.js Näytä tiedosto

$(document).ready(function() $(document).ready(function()
{ {
opendistrib_signup() ; opendistrib_signup() ;
opendistrib_dropdown_tooltip();
}); });


function opendistrib_dropdown_tooltip() {
if($('.dropdown-toggle').length) {
$('.dropdown-toggle').dropdown() ;
}

if($('[data-toggle="tooltip"]').length) {
$('[data-toggle="tooltip"]').tooltip() ;
}
}

function opendistrib_signup() function opendistrib_signup()
{ {
if($('#form-signup').size()) if($('#form-signup').size())

+ 3
- 1
producer/views/layouts/main.php Näytä tiedosto

<body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>"> <body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>">
<?php $this->beginBody() ?> <?php $this->beginBody() ?>


<?= $this->render('@common/views/nav_user_top'); ?>
<?= $this->render('@common/views/nav_user_top', [
'context' => 'producer'
]); ?>


<div class="container"> <div class="container">
<div id="left" class="col-md-3"> <div id="left" class="col-md-3">

+ 7
- 2
producer/web/js/producer.js Näytä tiedosto

} }


function opendistrib_dropdown_tooltip() { function opendistrib_dropdown_tooltip() {
$('.dropdown-toggle').dropdown() ;
$('[data-toggle="tooltip"]').tooltip() ;
if($('.dropdown-toggle').length) {
$('.dropdown-toggle').dropdown() ;
}

if($('[data-toggle="tooltip"]').length) {
$('[data-toggle="tooltip"]').tooltip() ;
}
} }


function opendistrib_fix_width_sidebar() { function opendistrib_fix_width_sidebar() {

Loading…
Peruuta
Tallenna