Bläddra i källkod

[Frontend] Barre navigation commune frontend/producer

feature/souke
Guillaume Bourgeois 1 år sedan
förälder
incheckning
ba3f41d718
6 ändrade filer med 104 tillägg och 48 borttagningar
  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 Visa fil

@@ -65,6 +65,7 @@ class CommonAsset extends \common\components\MyAssetBundle
$this->addAsset('css','css/screen.css') ;
// 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/promise-polyfill/promise.min.js');
$this->addAsset('js','js/axios/axios.min.js');

+ 79
- 44
common/views/nav_user_top.php Visa fil

@@ -8,6 +8,11 @@ use yii\helpers\Html;

$userManager = UserManager::getInstance();

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

?>

<section class="nav-user-top">
@@ -26,10 +31,8 @@ $userManager = UserManager::getInstance();
$itemsProducersArray = [];
if (count($producersArray)) {
$itemsProducersArray[] = [
'options' => ['class' => 'dropdown-header'],
'label' => 'Mes favoris',
];

foreach($producersArray as $producerItem) {
$itemsProducersArray[] = [
'label' => Html::encode($producerItem->name),
@@ -37,6 +40,11 @@ $userManager = UserManager::getInstance();
];
}
}
else {
$itemsProducersArray[] = [
'label' => 'Aucun producteur dans vos favoris.',
];
}

$itemsProducersArray[] = [
'options' => ['class' => 'divider'],
@@ -47,54 +55,81 @@ $userManager = UserManager::getInstance();
'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' => [
[
'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>
</nav>

+ 3
- 1
frontend/views/layouts/main.php Visa fil

@@ -76,7 +76,9 @@ if ($userManager->isCurrentProducer()) {
<?php $this->beginBody() ?>
<div id="back"></div>

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

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

+ 11
- 0
frontend/web/js/frontend.js Visa fil

@@ -36,8 +36,19 @@ termes.
$(document).ready(function()
{
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()
{
if($('#form-signup').size())

+ 3
- 1
producer/views/layouts/main.php Visa fil

@@ -79,7 +79,9 @@ if (!Yii::$app->user->isGuest) {
<body class="<?= \Yii::$app->controller->id . '-' . \Yii::$app->controller->action->id ?>">
<?php $this->beginBody() ?>

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

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

+ 7
- 2
producer/web/js/producer.js Visa fil

@@ -85,8 +85,13 @@ function opendistrib_datepicker() {
}

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() {

Laddar…
Avbryt
Spara