Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
 - Workflow
 - Teams
 - Actions
  • Loading branch information
georgemjohn committed Jul 29, 2023
1 parent 0b5ea2b commit 7ca252e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 8 deletions.
17 changes: 14 additions & 3 deletions src/Litepie/Actions/Traits/Actionable.php
Expand Up @@ -80,16 +80,28 @@ public function formatActionLog($properties)
if (in_array($key, $this->log_action['exclude'])) {
continue;
}
if (is_array($property)) {
foreach ($property as $row => $item) {
$formattedLog = [
'value' => $item,
'label' => trans($this->log_action['label'] . $row),
];

$formattedLog['text'] = $formattedLog['label'] . ': ' . $formattedLog['value'];

$formattedLogs[$row] = $formattedLog;
}
continue;
}
$formattedLog = [
'value' => $property,
'label' => trans($this->log_action['label'] . $key),
];

$formattedLog['text'] = $formattedLog['label'] . ': ' . $formattedLog['value'];

$formattedLogs[$key] = $formattedLog;
}

return $formattedLogs;
}

Expand All @@ -101,7 +113,7 @@ public function canDoActions($roles = [])
if (user()->hasRole(@$roles['user'])) {
return true;
}

if (@$roles['model']) {
foreach ($roles['model'] as $model) {
if ($this->$model) {
Expand All @@ -112,5 +124,4 @@ public function canDoActions($roles = [])

return false;
}

}
17 changes: 15 additions & 2 deletions src/Litepie/Team/TeamServiceProvider.php
Expand Up @@ -31,7 +31,6 @@ public function boot()

// Call pblish redources function
$this->publishResources();

}

/**
Expand All @@ -42,11 +41,24 @@ public function boot()
public function register()
{
$this->mergeConfig();
$this->registerFacade();

$this->app->register(\Litepie\Team\Providers\AuthServiceProvider::class);
$this->app->register(\Litepie\Team\Providers\RouteServiceProvider::class);
}

/**
* Register the vault facade without the user having to add it to the app.php file.
*
* @return void
*/
public function registerFacade()
{
$this->app->bind('litepie.team', function ($app) {
return $this->app->make(Teams::class);
});
}

/**
* Merges user's and team's configs.
*
Expand All @@ -55,7 +67,8 @@ public function register()
protected function mergeConfig()
{
$this->mergeConfigFrom(
__DIR__ . '/config/team.php', 'team'
__DIR__ . '/config/team.php',
'team'
);
}

Expand Down
9 changes: 6 additions & 3 deletions src/Litepie/Workflow/Workflow.php
@@ -1,7 +1,9 @@
<?php

namespace Litepie\Workflow;

use Symfony\Component\Workflow\Workflow as SymfonyWorkflow;
use Closure;

class Workflow extends SymfonyWorkflow
{
Expand All @@ -25,11 +27,10 @@ public function transition($transition, $workflow = null)
if ($t->getName() == $transition) {
return $t;
}

}
return null;
}

public function form($transition)
{
$meta = $this->getMetadataStore()
Expand All @@ -43,6 +44,9 @@ public function form($transition)
$item = collect($form)->map(function ($val) {
$val['label'] = trans($val['label']);
$val['placeholder'] = trans($val['placeholder']);
if (isset($val['options']) && is_callable($val['options']) && $val['options'] instanceof Closure) {
$val['options'] = call_user_func($val['options']);
}
return $val;
});
return $item;
Expand All @@ -60,5 +64,4 @@ public function previous($transition, $workflow = null)
}
return $previousTransitions;
}

}

0 comments on commit 7ca252e

Please sign in to comment.