Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2-widgets2-module
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
hrzg
yii2-widgets2-module
Commits
ebd4adfc
Commit
ebd4adfc
authored
Jun 24, 2016
by
Tobias Munk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated UI
parent
353ca2ff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
84 additions
and
3 deletions
+84
-3
WidgetAsset.php
src/assets/WidgetAsset.php
+20
-0
widgets.less
src/assets/web/widgets.less
+27
-0
WidgetContainer.php
src/widgets/WidgetContainer.php
+37
-3
No files found.
src/assets/WidgetAsset.php
0 → 100644
View file @
ebd4adfc
<?php
/**
* @link http://www.diemeisterei.de/
* @copyright Copyright (c) 2016 diemeisterei GmbH, Stuttgart
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
hrzg\widget\assets
;
use
yii\web\AssetBundle
;
class
WidgetAsset
extends
AssetBundle
{
public
$sourcePath
=
__DIR__
.
'/web'
;
public
$css
=
[
'widgets.less'
];
}
\ No newline at end of file
src/assets/web/widgets.less
0 → 100644
View file @
ebd4adfc
.hrzg-widget-widget-container {
min-height: 32px;
&:hover {
outline: 2px dashed #ccc;
}
.hrzg-widget-widget-controls {
opacity: 0.3;
position: absolute;
&:hover {
opacity: 1;
}
}
.hrzg-widget-container-controls {
opacity: 0.3;
&:hover {
opacity: 1;
}
}
.hrzg-widget-widget {
&:hover {
outline: 4px solid gray;
}
}
}
src/widgets/WidgetContainer.php
View file @
ebd4adfc
...
...
@@ -10,11 +10,13 @@
namespace
hrzg\widget\widgets
;
use
hrzg\widget\models\crud\WidgetContent
;
use
hrzg\widget\assets\WidgetAsset
;
use
rmrevin\yii\fontawesome\AssetBundle
;
use
rmrevin\yii\fontawesome\component\Icon
;
use
rmrevin\yii\fontawesome\FA
;
use
yii\base\Event
;
use
yii\base\Widget
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
class
WidgetContainer
extends
Widget
...
...
@@ -22,6 +24,9 @@ class WidgetContainer extends Widget
public
function
init
()
{
\Yii
::
$app
->
trigger
(
'registerMenuItems'
,
new
Event
([
'sender'
=>
$this
]));
if
(
\Yii
::
$app
->
user
->
can
(
'widgets'
))
{
WidgetAsset
::
register
(
\Yii
::
$app
->
view
);
}
}
public
function
run
()
...
...
@@ -47,7 +52,12 @@ class WidgetContainer extends Widget
private
function
renderWidgets
()
{
$html
=
''
;
$html
=
Html
::
beginTag
(
'div'
,[
'class'
=>
'hrzg-widget-widget-container'
]);
if
(
\Yii
::
$app
->
user
->
can
(
'widgets'
))
{
$html
.=
$this
->
generateContainerControls
();
}
foreach
(
$this
->
queryWidgets
()
as
$widget
)
{
$properties
=
Json
::
decode
(
$widget
->
default_properties_json
);
$class
=
\Yii
::
createObject
(
$widget
->
template
->
php_class
);
...
...
@@ -56,10 +66,14 @@ class WidgetContainer extends Widget
if
(
$properties
)
{
$class
->
setProperties
(
$properties
);
}
$html
.=
Html
::
beginTag
(
'div'
,[
'class'
=>
'hrzg-widget-widget'
]);
if
(
\Yii
::
$app
->
user
->
can
(
'widgets'
))
{
$html
.=
$this
->
generateWidgetControls
(
$widget
);
}
$html
.=
$class
->
run
();
$html
.=
Html
::
endTag
(
'div'
);
}
$html
.=
Html
::
endTag
(
'div'
);
return
$html
;
}
...
...
@@ -67,6 +81,26 @@ class WidgetContainer extends Widget
{
}
private
function
generateContainerControls
(){
$html
=
Html
::
beginTag
(
'div'
,[
'class'
=>
'hrzg-widget-container-controls pull-right'
]);
$html
.=
Html
::
a
(
'Add'
,
[
'/widgets/crud/widget/create'
,
'WidgetContent'
=>
[
'route'
=>
\Yii
::
$app
->
requestedRoute
,
'container_id'
=>
$this
->
id
,
'request_param'
=>
\Yii
::
$app
->
request
->
get
(
'id'
),
'access_domain'
=>
\Yii
::
$app
->
language
,
]],
[
'class'
=>
'btn btn-default'
]);
$html
.=
Html
::
endTag
(
'div'
);
return
$html
;
}
private
function
generateWidgetControls
(
$widget
){
$html
=
Html
::
beginTag
(
'div'
,[
'class'
=>
'hrzg-widget-widget-controls'
]);
$html
.=
Html
::
a
(
'Edit'
,
[
'/widgets/crud/widget/update'
,
'id'
=>
$widget
->
id
],
[
'class'
=>
'btn btn-default'
]);
$html
.=
Html
::
endTag
(
'div'
);
return
$html
;
}
public
function
getMenuItems
()
{
// todo, register FA-asset from asset bundle
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment