From e41b547c99d11bca41eb9ddc60564ef867711acf Mon Sep 17 00:00:00 2001
From: xamgore <xamgore@ya.ru>
Date: Wed, 2 Sep 2015 16:58:29 +0300
Subject: [PATCH] Separate side bar menu for admin & dean

Look at office/ page
---
 .../{menu.json => sidePanel/admin.json}       | 16 ++++-----
 deploy/phpConfig/sidePanel/dean.json          | 34 +++++++++++++++++++
 gulpfile.js                                   |  2 +-
 .../classes/Controller/Environment/Office.php | 14 ++++++--
 .../application/views/office/base.twig        |  6 +++-
 5 files changed, 59 insertions(+), 13 deletions(-)
 rename deploy/phpConfig/{menu.json => sidePanel/admin.json} (63%)
 create mode 100644 deploy/phpConfig/sidePanel/dean.json

diff --git a/deploy/phpConfig/menu.json b/deploy/phpConfig/sidePanel/admin.json
similarity index 63%
rename from deploy/phpConfig/menu.json
rename to deploy/phpConfig/sidePanel/admin.json
index 68e3b7731..1454c3a7a 100644
--- a/deploy/phpConfig/menu.json
+++ b/deploy/phpConfig/sidePanel/admin.json
@@ -3,8 +3,8 @@
 		"Title": "Структура ЮФУ",
 		"Items": [
 			{ "Title": "Подразделения", "Anchor": "faculties" },
-			{ "Title": "Кафедры", "Anchor": "departments" },
-			{ "Title": "Направления подготовки", "Anchor": "specializations" }
+			{ "Title": "Кафедры", "Anchor": "departments", "Disabled": "true" },
+			{ "Title": "Направления подготовки", "Anchor": "specializations", "Disabled": "true" }
 		]
 	},
 	{
@@ -15,22 +15,22 @@
 			{ "Title": "Предметы", "Anchor": "subjects" },
 			{ "Title": "Дисциплины", "Anchor": "disciplines" },
 			{ "Title": "Семестры", "Anchor": "semesters" },
-			{ "Title": "Регламентные", "Anchor": "#" }
+			{ "Title": "Регламентные", "Anchor": "#", "Disabled": "true" }
 		]
 	},
 	{
 		"Title": "Отчеты",
 		"Items": [
-			{ "Title": "Аттестация", "Anchor": "attestation" },
-			{ "Title": "Ведомости", "Anchor": "sheets" }
+			{ "Title": "Ведомости", "Anchor": "sheets" },
+			{ "Title": "Сводная ведомость", "Anchor": "groups/bill" }
 		]
 	},
 	{
 		"Title": "Управление системой",
 		"Items": [
-			{ "Title": "История авторизаций", "Anchor": "#" },
-			{ "Title": "История выставления баллов", "Anchor": "#" },
-			{ "Title": "Поддержка", "Anchor": "#" }
+			{ "Title": "История авторизаций", "Anchor": "#", "Disabled": "true" },
+			{ "Title": "История выставления баллов", "Anchor": "#", "Disabled": "true" },
+			{ "Title": "Поддержка", "Anchor": "#", "Disabled": "true" }
 		]
 	}
 ]
diff --git a/deploy/phpConfig/sidePanel/dean.json b/deploy/phpConfig/sidePanel/dean.json
new file mode 100644
index 000000000..4c6f75c93
--- /dev/null
+++ b/deploy/phpConfig/sidePanel/dean.json
@@ -0,0 +1,34 @@
+[
+	{
+		"Title": "Структура ЮФУ",
+		"Items": [
+			{ "Title": "Кафедры", "Anchor": "departments", "Disabled": "true" },
+			{ "Title": "Направления подготовки", "Anchor": "specializations", "Disabled": "true" }
+		]
+	},
+	{
+		"Title": "Учебный процесс",
+		"Items": [
+			{ "Title": "Преподаватели", "Anchor": "teachers" },
+			{ "Title": "Студенты", "Anchor": "students" },
+			{ "Title": "Предметы", "Anchor": "subjects" },
+			{ "Title": "Дисциплины", "Anchor": "disciplines" },
+			{ "Title": "Регламентные", "Anchor": "#", "Disabled": "true" }
+		]
+	},
+	{
+		"Title": "Отчеты",
+		"Items": [
+			{ "Title": "Ведомости", "Anchor": "sheets" },
+			{ "Title": "Сводная ведомость", "Anchor": "attestation" }
+		]
+	},
+	{
+		"Title": "Управление системой",
+		"Items": [
+			{ "Title": "История авторизаций", "Anchor": "#", "Disabled": "true" },
+			{ "Title": "История выставления баллов", "Anchor": "#", "Disabled": "true" },
+			{ "Title": "Поддержка", "Anchor": "#", "Disabled": "true" }
+		]
+	}
+]
diff --git a/gulpfile.js b/gulpfile.js
index cb671a15d..0b07ef70a 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -57,7 +57,7 @@ var paths = new (function () {
         css: media + '/css/**/*.css',
         less: media + '/less/**/*.less',
         js: media + '/js/**/*.js',
-        config: src + '/deploy/phpConfig/*',
+        config: src + '/deploy/phpConfig/**/*',
         css_components: media + '/components/**/*.css',
         js_components: media + '/components/**/*.js'
     };
diff --git a/~dev_rating/application/classes/Controller/Environment/Office.php b/~dev_rating/application/classes/Controller/Environment/Office.php
index b3213ebe7..ed58820d8 100644
--- a/~dev_rating/application/classes/Controller/Environment/Office.php
+++ b/~dev_rating/application/classes/Controller/Environment/Office.php
@@ -14,10 +14,18 @@ class Controller_Environment_Office extends Controller_Environment_User
         $this->user->checkAccess(User::RIGHTS_DEAN | User::RIGHTS_ADMIN);
 
         // todo: move to twig
-        $sidePanelMenu = Model_System::loadConfig("menu.json");
-        $this->twig->bind_global("SidePanel", $sidePanelMenu);
+
+
+        $menu = [];
+        if ($this->user->isAdmin()) {
+            $menu = Model_System::loadConfig('sidePanel/admin.json');
+        } elseif ($this->user->isDean()) {
+            $menu = Model_System::loadConfig('sidePanel/dean.json');
+        }
+
+        $this->twig->set_global('SidePanel', $menu);
     }
-    
+
     public function action_index() {
         $this->twig->set_filename(self::OFFICE . 'base');
     }
diff --git a/~dev_rating/application/views/office/base.twig b/~dev_rating/application/views/office/base.twig
index a7603236c..536691f2f 100644
--- a/~dev_rating/application/views/office/base.twig
+++ b/~dev_rating/application/views/office/base.twig
@@ -33,7 +33,11 @@
                     <h3>{{ Category.Title }}</h3>
                     <ul>
                         {% for Item in Category.Items %}
-                            {{ HTML.anchor('office/'~Item.Anchor, "<li>"~Item.Title~"</li>")|raw }}
+                            {% if Item.Disabled %}
+                                <li style="font-size:.9em">{{ Item.Title }}</li>
+                            {% else %}
+                                {{ HTML.anchor('office/' ~ Item.Anchor, '<li>' ~ Item.Title|e ~ '</li>')|raw }}
+                            {% endif %}
                         {% endfor %}
                     </ul>
                 </div>
-- 
GitLab