From e6b356ff21e51985a20adb5230cc8f4374efc825 Mon Sep 17 00:00:00 2001 From: taoyu65 Date: Wed, 9 Aug 2017 14:50:29 -0700 Subject: [PATCH] fix bug: new user without menus will not show page --- src/Models/User.php | 9 +++++---- src/Umi/TableRelation/TRDeleteInterlock.php | 8 ++++---- src/Umi/TableRelation/UmiTableRelation.php | 2 +- src/Umi/umiMenusBuilder.php | 6 ++++-- src/resources/views/field/fieldBrowserRead.blade.php | 6 ------ 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Models/User.php b/src/Models/User.php index 4e17d9f..a9def5c 100644 --- a/src/Models/User.php +++ b/src/Models/User.php @@ -32,12 +32,13 @@ public function menusJson() { $minute = Config::get('umi.cache_minutes'); $json = Cache::remember('menuJson', $minute, function () { - return self::find(Auth::user()->id) + return $re = self::find(Auth::user()->id) ->MenuJson() - ->firstOrFail() - ->json; + ->first(); + //->firstOrFail() + //->json; }); - return $json; + return $json ? $json->json : $json; } public function userNameList() diff --git a/src/Umi/TableRelation/TRDeleteInterlock.php b/src/Umi/TableRelation/TRDeleteInterlock.php index 7b0e225..30f5641 100644 --- a/src/Umi/TableRelation/TRDeleteInterlock.php +++ b/src/Umi/TableRelation/TRDeleteInterlock.php @@ -13,10 +13,10 @@ public function showConfirmation($activeTableName, $activeField, $currentFieldVa public function executeExtraOperation($activeTableName, $activeField, $currentFieldValue, $targetValue, $responseTableName, $responseField, $checkOperation = '=') { -// $count = DB::table($responseTableName) -// ->where($responseField, $checkOperation, $currentFieldValue) -// ->delete(); - return 0;//$count;//todo - waiting for final test + $count = DB::table($responseTableName) + ->where($responseField, $checkOperation, $currentFieldValue) + ->delete(); + return $count; } private function errMessage($activeTableName, $activeField, $currentFieldValue, $targetValue, $responseTableName, $responseField, $checkOperation) diff --git a/src/Umi/TableRelation/UmiTableRelation.php b/src/Umi/TableRelation/UmiTableRelation.php index a5e3728..3cf28a6 100644 --- a/src/Umi/TableRelation/UmiTableRelation.php +++ b/src/Umi/TableRelation/UmiTableRelation.php @@ -11,7 +11,7 @@ class UmiTableRelation public $message; public function showConfirmation($activeFieldValues) - {//todo - need to see authority for all the relation operation. + { $tableId = YM::currentTableId(); $TRO = new TableRelationOperation(); $rules = $TRO->getRulesForConfirmation($tableId); diff --git a/src/Umi/umiMenusBuilder.php b/src/Umi/umiMenusBuilder.php index 041bb95..d9a5461 100644 --- a/src/Umi/umiMenusBuilder.php +++ b/src/Umi/umiMenusBuilder.php @@ -118,7 +118,8 @@ public function Menus($json = '') $json = $json === '' ? $this->menusJson() : $json; if (!is_string($json) || !is_array(json_decode($json))) - throw new Exception('loading Menus was failed'); + //throw new Exception('loading Menus was failed'); + return 'No menus or Loading menus was failed, Please set a user menus permission first!'; $html = '';//$this->dashboard(); try { @@ -324,7 +325,8 @@ public function showDragDropTreeByJson($jsonArr) #show user's menu, reading from user's json, can be customized private function createUserTree($jsonArr) { - $html = '
    '; + $emptyContainer = count($jsonArr) > 0 ? '' : 'dd-empty'; + $html = "
      "; foreach ($jsonArr as $item) { $record = $this->menus->getOneMenu($item->id); diff --git a/src/resources/views/field/fieldBrowserRead.blade.php b/src/resources/views/field/fieldBrowserRead.blade.php index d176b5c..878b266 100644 --- a/src/resources/views/field/fieldBrowserRead.blade.php +++ b/src/resources/views/field/fieldBrowserRead.blade.php @@ -314,12 +314,6 @@ function recordDelete(tableName, tableId) { }); } - //更新记录 - //update record - function recordEdit(tableName, tableId) { - //todo - edit need to be completed - } - //加载数据当选择表名的时候 //load data when select table name function loadTable(url) {