workflow controller
This commit is contained in:
parent
6068889e68
commit
7c6654398d
18 changed files with 687 additions and 470 deletions
|
@ -6,6 +6,7 @@ use App\Models\Dataset;
|
|||
use App\Models\Project;
|
||||
use App\Models\License;
|
||||
use App\Models\Title;
|
||||
use App\Models\Description;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
@ -26,7 +27,7 @@ class DatasetController extends Controller
|
|||
$builder = Dataset::query();
|
||||
//$registers = array();
|
||||
|
||||
$filter = $request->input('search');
|
||||
$filter = $request->input('filter');
|
||||
|
||||
if (null !== ($request->input('state'))) {
|
||||
$state = $request->input('state');
|
||||
|
@ -52,7 +53,7 @@ class DatasetController extends Controller
|
|||
//$perPage = $request->get('perPage', 20);
|
||||
$documents = $builder
|
||||
->paginate(8);
|
||||
return view('settings.document.document', compact('documents'));
|
||||
return view('settings.document.document', compact('documents', 'state', 'filter'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -180,7 +181,7 @@ class DatasetController extends Controller
|
|||
$abstracts = $request->input('abstracts');
|
||||
if (is_array($abstracts) && count($abstracts) > 0) {
|
||||
foreach ($abstracts as $key => $formAbstract) {
|
||||
$abstract = Title::findOrFail($key);
|
||||
$abstract = Description::findOrFail($key);
|
||||
$abstract->value = $formAbstract['value'];
|
||||
$abstract->language = $formAbstract['language'];
|
||||
$abstract->save();
|
||||
|
|
60
app/Http/Controllers/Settings/WorkflowController.php
Normal file
60
app/Http/Controllers/Settings/WorkflowController.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
// use App\Http\Requests\ProjectRequest;
|
||||
// use App\Models\Project;
|
||||
// use Illuminate\Http\RedirectResponse;
|
||||
// use Illuminate\Http\Request;
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class WorkflowController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
//$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$builder = Dataset::query();
|
||||
$datasets = $builder
|
||||
//->where('server_state', 'inprogress')
|
||||
->whereIn('server_state', ['unpublished'])
|
||||
->get();
|
||||
return view('workflow.index', compact('datasets'));
|
||||
}
|
||||
|
||||
public function changestate($id, $targetState)
|
||||
{
|
||||
// $docId = $this->getRequest()->getParam('docId');
|
||||
// $targetState = $this->getRequest()->getParam('targetState');
|
||||
|
||||
//$document = $this->_documentsHelper->getDocumentForId($docId);
|
||||
$dataset = Dataset::findOrFail($id);
|
||||
|
||||
// Check if valid target state
|
||||
// if (!$this->_workflowHelper->isValidState($targetState)) {
|
||||
|
||||
// }
|
||||
try {
|
||||
//$this->_workflowHelper->changeState($document, $targetState);
|
||||
$dataset->setServerState($targetState);
|
||||
|
||||
// if ($targetState == 'published') {
|
||||
// $this->_sendNotification($document, $form);
|
||||
// }
|
||||
$dataset->save();
|
||||
session()->flash('flash_message', 'You have puplished 1 dataset!');
|
||||
return redirect()->route('settings.review.index');
|
||||
} catch (Exception $e) {
|
||||
//return $this->_redirectTo('index', array('failure' => $e->getMessage()), 'documents', 'admin');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class RedirectIfAuthenticated
|
|||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/');
|
||||
return redirect('/home');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
7
app/Library/Util/SolrIndexIndexer.php
Normal file
7
app/Library/Util/SolrIndexIndexer.php
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
class SolrIndexIndexer
|
||||
{
|
||||
protected $data;
|
||||
}
|
|
@ -165,7 +165,7 @@ trait DatasetExtension
|
|||
* @param string $name Name of the requested field.
|
||||
* @return Field The requested field instance. If no such instance can be found, null is returned.
|
||||
*/
|
||||
protected function getField($name)
|
||||
public function getField($name)
|
||||
{
|
||||
if (isset($this->fields[$name])) {
|
||||
return $this->fields[$name];
|
||||
|
|
|
@ -213,6 +213,12 @@ class Dataset extends Model
|
|||
->server_date_published;
|
||||
}
|
||||
|
||||
public function setServerState($targetType)
|
||||
{
|
||||
$this->attributes['server_state'] = $targetType;
|
||||
//$this->server_state = $targetType;
|
||||
}
|
||||
|
||||
public function hasProject()
|
||||
{
|
||||
return $this->project()->exists();
|
||||
|
|
90
app/Observers/DatasetObserver.php
Normal file
90
app/Observers/DatasetObserver.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
//php artisan make:observer DatasetObserver --model=Models\Dataset
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class DatasetObserver
|
||||
{
|
||||
/**
|
||||
* Handle the dataset "created" event.
|
||||
*
|
||||
* @param \App\Models\Dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
public function created(Dataset $dataset)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dataset "updated" event.
|
||||
*
|
||||
* @param \App\Models\Dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
public function updated(Dataset $dataset)
|
||||
{
|
||||
|
||||
|
||||
// only index Opus_Document instances
|
||||
if (false === ($dataset instanceof Dataset)) {
|
||||
return;
|
||||
}
|
||||
// if ($dataset->getServerState() !== 'published') {
|
||||
// if ($model->getServerState() !== 'temporary') {
|
||||
// $this->removeDocumentFromIndexById($model->getId());
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
|
||||
$this->addDatasetToIndex($dataset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dataset "deleted" event.
|
||||
*
|
||||
* @param \App\Models\Dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(Dataset $dataset)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dataset "restored" event.
|
||||
*
|
||||
* @param \App\Models\Dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
public function restored(Dataset $dataset)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the dataset "force deleted" event.
|
||||
*
|
||||
* @param \App\Models\Dataset $dataset
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(Dataset $dataset)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to add dataset to index.
|
||||
*
|
||||
* @param Opus_Document $document
|
||||
* @return void
|
||||
*/
|
||||
private function addDatasetToIndex(Dataset $dataset)
|
||||
{
|
||||
$datasetId = $dataset->id;
|
||||
Log::debug(__METHOD__ . ': ' . 'Adding index job for document ' . $datasetId . '.');
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Models\Dataset;
|
||||
use App\Observers\DatasetObserver;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
|
@ -12,7 +14,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
Dataset::observe(DatasetObserver::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,9 +28,9 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar'
|
||||
// 'App\Services\Registrar'
|
||||
);
|
||||
// $this->app->bind(
|
||||
// 'Illuminate\Contracts\Auth\Registrar'
|
||||
// // 'App\Services\Registrar'
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
|
30
app/Providers/AuthServiceProvider.php
Normal file
30
app/Providers/AuthServiceProvider.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* The policy mappings for the application.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $policies = [
|
||||
'App\Model' => 'App\Policies\ModelPolicy',
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any authentication / authorization services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
|
||||
//
|
||||
}
|
||||
}
|
|
@ -69,7 +69,7 @@ class RouteServiceProvider extends ServiceProvider
|
|||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue