diff --git a/controllers/BaseController.php b/controllers/BaseController.php index 0de7c51f..d4a6d4f3 100644 --- a/controllers/BaseController.php +++ b/controllers/BaseController.php @@ -2,6 +2,7 @@ namespace Grocy\Controllers; +use Grocy\Controllers\Users\User; use \Grocy\Services\DatabaseService; use \Grocy\Services\ApplicationService; use \Grocy\Services\LocalizationService; @@ -66,6 +67,8 @@ class BaseController } $this->View->set('featureFlags', $constants); + $this->View->set('permissions', User::PermissionList()); + return $this->View->render($response, $page, $data); } diff --git a/public/css/grocy.css b/public/css/grocy.css index 295aea0b..e259138f 100644 --- a/public/css/grocy.css +++ b/public/css/grocy.css @@ -581,3 +581,7 @@ canvas.drawingBuffer { } } +.not-allowed { + pointer-events: none; + opacity: 0.5; +} \ No newline at end of file diff --git a/public/js/grocy.js b/public/js/grocy.js index 275cd6fe..ed73d677 100644 --- a/public/js/grocy.js +++ b/public/js/grocy.js @@ -662,3 +662,11 @@ $.extend(true, $.fn.dataTable.defaults, { }); } }); + +$(Grocy.Permissions).each(function (index, item) +{ + if(item.has_permission == 0) + { + $('.permission-'+item.permission_name).addClass('disabled').addClass('not-allowed'); + } +}); diff --git a/views/batteries.blade.php b/views/batteries.blade.php index 9926c37d..8d2a1239 100644 --- a/views/batteries.blade.php +++ b/views/batteries.blade.php @@ -20,7 +20,7 @@
- + {{ $__t('Add') }}
@@ -57,10 +57,10 @@ @foreach($batteries as $battery) - + - + diff --git a/views/batteriesjournal.blade.php b/views/batteriesjournal.blade.php index a4d3e479..bce9d714 100644 --- a/views/batteriesjournal.blade.php +++ b/views/batteriesjournal.blade.php @@ -50,7 +50,7 @@ @foreach($chargeCycles as $chargeCycleEntry) - + diff --git a/views/batteriesoverview.blade.php b/views/batteriesoverview.blade.php index 5da87a25..91aa97d2 100644 --- a/views/batteriesoverview.blade.php +++ b/views/batteriesoverview.blade.php @@ -69,7 +69,7 @@ @foreach($current as $currentBatteryEntry) - @@ -85,7 +85,7 @@ {{ $__t('Journal for this battery') }} - + {{ $__t('Edit battery') }}
diff --git a/views/choresjournal.blade.php b/views/choresjournal.blade.php index 70243079..8c10f939 100644 --- a/views/choresjournal.blade.php +++ b/views/choresjournal.blade.php @@ -53,7 +53,7 @@ @foreach($choresLog as $choreLogEntry) - + diff --git a/views/choresoverview.blade.php b/views/choresoverview.blade.php index d83a80c9..77e7ba1b 100644 --- a/views/choresoverview.blade.php +++ b/views/choresoverview.blade.php @@ -95,7 +95,7 @@ @foreach($currentChores as $curentChoreEntry) - @@ -111,7 +111,7 @@ {{ $__t('Journal for this chore') }} - + {{ $__t('Edit chore') }} diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 3872148f..87ae27a9 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -59,6 +59,8 @@ Grocy.GettextPo = {!! $GettextPo !!}; Grocy.FeatureFlags = {!! json_encode($featureFlags) !!}; + Grocy.Permissions = {!! json_encode($permissions) !!}; + @if (GROCY_AUTHENTICATED) Grocy.UserSettings = {!! json_encode($userSettings) !!}; Grocy.UserId = {{ GROCY_USER_ID }}; @@ -163,27 +165,27 @@ @if(GROCY_FEATURE_FLAG_STOCK) - - @if(GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) - @endif - @endif @if(GROCY_FEATURE_FLAG_CHORES) - @endif @if(GROCY_FEATURE_FLAG_BATTERIES) -