Merge branch 'dev' into template_support
This commit is contained in:
@@ -19,8 +19,10 @@ class WidgetRegistrator
|
|||||||
* Method used for registering new widgets
|
* Method used for registering new widgets
|
||||||
*
|
*
|
||||||
* @param $classname
|
* @param $classname
|
||||||
|
* @param null $templateId
|
||||||
|
* @param null $moduleId
|
||||||
*/
|
*/
|
||||||
public function register($classname)
|
public function register($classname, $templateId = null, $moduleId = null)
|
||||||
{
|
{
|
||||||
$class = new $classname;
|
$class = new $classname;
|
||||||
if (!$class instanceof PublicWidget) {
|
if (!$class instanceof PublicWidget) {
|
||||||
@@ -36,6 +38,8 @@ class WidgetRegistrator
|
|||||||
WidgetType::create([
|
WidgetType::create([
|
||||||
'handler' => $classname,
|
'handler' => $classname,
|
||||||
'name' => $widgetName,
|
'name' => $widgetName,
|
||||||
|
'module_id' => $moduleId,
|
||||||
|
'template_id' => $templateId,
|
||||||
'description' => $widgetDescription
|
'description' => $widgetDescription
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,18 @@ class Settings
|
|||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortcut for obtaining settings saved as JSON
|
||||||
|
*
|
||||||
|
* @param $key
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public static function getJson($key)
|
||||||
|
{
|
||||||
|
return json_decode(self::get($key, '{}'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all settings
|
* Get all settings
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -24,3 +24,7 @@ function e($value)
|
|||||||
function setting($key, $default = null) {
|
function setting($key, $default = null) {
|
||||||
return \App\Helpers\Settings::get($key, $default);
|
return \App\Helpers\Settings::get($key, $default);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function asset_path($path) {
|
||||||
|
return env('SITE_URL').'/assets/'.$path;
|
||||||
|
}
|
||||||
@@ -17,7 +17,9 @@ class Widget extends Model
|
|||||||
'user_id',
|
'user_id',
|
||||||
'name',
|
'name',
|
||||||
'settings',
|
'settings',
|
||||||
'description'
|
'language',
|
||||||
|
'description',
|
||||||
|
'deletable'
|
||||||
];
|
];
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
@@ -31,7 +33,6 @@ class Widget extends Model
|
|||||||
*/
|
*/
|
||||||
public function createNew(WidgetType $widgetType, $data)
|
public function createNew(WidgetType $widgetType, $data)
|
||||||
{
|
{
|
||||||
|
|
||||||
// convert array or whatever into object
|
// convert array or whatever into object
|
||||||
if (!is_object($data)) {
|
if (!is_object($data)) {
|
||||||
$data = (object)$data;
|
$data = (object)$data;
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ class WidgetArea extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'name',
|
'name',
|
||||||
'code',
|
'code',
|
||||||
'description'
|
'description',
|
||||||
|
'deletable'
|
||||||
];
|
];
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ class WidgetType extends Model
|
|||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'handler',
|
'handler',
|
||||||
'name',
|
'name',
|
||||||
|
'template_id',
|
||||||
|
'module_id',
|
||||||
'description'
|
'description'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
|
||||||
|
class MakeUserIdNullableAtWidgets extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('widgets', function (Blueprint $table) {
|
||||||
|
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
|
||||||
|
$table->integer('user_id')
|
||||||
|
->nullable(true)
|
||||||
|
->default(null)
|
||||||
|
->comment('User ID who created this widget. NULL for widget created by template.')->change();
|
||||||
|
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')
|
||||||
|
->on('users')
|
||||||
|
->onDelete('cascade')
|
||||||
|
->onUpdate('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('widgets', function (Blueprint $table) {
|
||||||
|
$table->dropForeign(['user_id']);
|
||||||
|
});
|
||||||
|
|
||||||
|
Schema::table('widgets', function (Blueprint $table) {
|
||||||
|
$table->integer('user_id')
|
||||||
|
->nullable(false)
|
||||||
|
->comment('User ID who created this widget. ')->change();
|
||||||
|
|
||||||
|
$table->foreign('user_id')
|
||||||
|
->references('id')
|
||||||
|
->on('users')
|
||||||
|
->onDelete('no action')
|
||||||
|
->onUpdate('no action');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,61 +1,15 @@
|
|||||||
@extends('admin.layout')
|
@extends('admin.layoutWithNavigation')
|
||||||
|
|
||||||
@section('pageName', @trans('admin/widgets.overview'))
|
@section('pageName', @trans('admin/widgets.overview'))
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-lg-9 sameheight-container">
|
||||||
@if (session('success'))
|
|
||||||
<div class="callout success">
|
|
||||||
{{ session('success') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (session('error'))
|
|
||||||
<div class="callout alert">
|
|
||||||
{{ session('error') }}
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
<div class="column large-9 tile-overview" data-equalizer>
|
|
||||||
|
|
||||||
<h2>@lang('admin/widgets.overview')</h2>
|
<h2>@lang('admin/widgets.overview')</h2>
|
||||||
|
|
||||||
@forelse($widgets as $widget)
|
@include('admin.widgets.widgetsToAssociate', ['tileClass' => 'col-lg-3 col-md-4 col-sm-6 col-xs-12'])
|
||||||
<div class="column large-4">
|
|
||||||
<div class="item" data-equalizer-watch>
|
|
||||||
<h4>{{str_limit($widget->name, 20)}}</h4>
|
|
||||||
<p>
|
|
||||||
{{trans(call_user_func([$widget->widget_type_handler, 'getName']))}}
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
{{str_limit($widget->description, 150)}}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<div class="controls row text-center">
|
|
||||||
<a href="{{route('widgets.edit', ['id' => $widget->id])}}" class="button column large-6 primary"><i class="fa fa-edit"></i></a>
|
|
||||||
|
|
||||||
@if (in_array($widget->id, $associatedWidgetIds))
|
|
||||||
<a href="{{route('widgets.deleteAssociation', ['widgetId' => $widget->id, 'widgetArea' => $widgetArea->id])}}"
|
|
||||||
class="button column confirm large-6 alert">
|
|
||||||
<i class="fa fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
@else
|
|
||||||
<a href="{{route('widgets.makeAssociation', ['widgetId' => $widget->id, 'widgetArea' => $widgetArea->id])}}"
|
|
||||||
class="button column large-6 success"><i class="fa fa-plus"></i></a>
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<div class="col-lg-3">
|
||||||
</div>
|
|
||||||
@empty
|
|
||||||
<em>@lang('admin/widgets.noEntries')</em>
|
|
||||||
@endforelse
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
{!! $widgets->render() !!}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column large-3">
|
|
||||||
<h2>{{$widgetArea->name}}</h2>
|
<h2>{{$widgetArea->name}}</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -63,11 +17,11 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>@lang('admin/widgets.createdAt'): {{$widgetArea->created_at}}</li>
|
<li>@lang('admin/widgets.createdAt'): @date($widgetArea->created_at)</li>
|
||||||
<li>@lang('admin/widgets.updatedAt'): {{$widgetArea->updated_at}}</li>
|
<li>@lang('admin/widgets.updatedAt'): @date($widgetArea->updated_at)</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a href="{{route('widgetareas.edit', ['id' => $widgetArea->id])}}">@lang('admin/widgetAreas.editButton')</a>
|
<a href="{{route('widgetareas.edit', ['id' => $widgetArea->id])}}" class="btn btn-secondary col-sm-12">@lang('admin/widgetAreas.editButton')</a>
|
||||||
|
|
||||||
@if (!empty($associatedWidgetIds))
|
@if (!empty($associatedWidgetIds))
|
||||||
<h3>@lang('admin/widgets.preview')</h3>
|
<h3>@lang('admin/widgets.preview')</h3>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="{{$tileClass}}">
|
<div class="{{$tileClass}}">
|
||||||
<div class=" card @if (in_array($widget->id, $associatedWidgetIds)) card-info @else card-success @endif">
|
<div class=" card @if (in_array($widget->id, $associatedWidgetIds)) card-info @else card-success @endif">
|
||||||
|
|
||||||
<div class="card-header">
|
<div class="card-header sameheight-item ">
|
||||||
<div class="header-block">
|
<div class="header-block">
|
||||||
<p class="title" title="{{$widget->name}}"
|
<p class="title" title="{{$widget->name}}"
|
||||||
data-toggle="tooltip"> {{str_limit($widget->name, 15)}}</p>
|
data-toggle="tooltip"> {{str_limit($widget->name, 15)}}</p>
|
||||||
|
|||||||
Reference in New Issue
Block a user