Fix preview and config not retaining values
This commit is contained in:
parent
e91f65f833
commit
b8f04f3d11
3 changed files with 37 additions and 1 deletions
14
app/Item.php
14
app/Item.php
|
@ -124,6 +124,14 @@ class Item extends Model
|
|||
}
|
||||
}
|
||||
|
||||
public static function nameFromClass($class)
|
||||
{
|
||||
$explode = explode('\\', $class);
|
||||
$name = end($explode);
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function scopeOfType($query, $type)
|
||||
{
|
||||
switch($type) {
|
||||
|
@ -148,6 +156,12 @@ class Item extends Model
|
|||
return (bool)($app instanceof \App\EnhancedApps);
|
||||
}
|
||||
|
||||
public static function isEnhanced($class)
|
||||
{
|
||||
$app = new $class;
|
||||
return (bool)($app instanceof \App\EnhancedApps);
|
||||
}
|
||||
|
||||
public function enabled()
|
||||
{
|
||||
if($this->enhanced()) {
|
||||
|
|
|
@ -81,13 +81,23 @@
|
|||
|
||||
|
||||
@if(isset($item) && $item->enhanced())
|
||||
|
||||
<div id="sapconfig" style="display: block;">
|
||||
@if(isset($item))
|
||||
@include('SupportedApps::'.$item->getconfig()->name.'.config')
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@elseif(old('class') && App\Item::isEnhanced(old('class')))
|
||||
|
||||
<div id="sapconfig" style="display: block;">
|
||||
@include('SupportedApps::'.App\Item::nameFromClass(old('class')).'.config')
|
||||
</div>
|
||||
|
||||
@else
|
||||
|
||||
<div id="sapconfig"></div>
|
||||
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
appload(appvalue);
|
||||
}
|
||||
});
|
||||
// initial load
|
||||
$('#tile-preview .title').html($('#appname').val());
|
||||
$('#tile-preview .item').css('backgroundColor', $('#appcolour').val());
|
||||
$('#tile-preview .app-icon').attr('src', $('#appimage img').attr('src'));
|
||||
|
||||
// Updates
|
||||
$('#appname').on('keyup change', function(e) {
|
||||
$('#tile-preview .title').html($(this).val());
|
||||
})
|
||||
|
@ -39,6 +45,9 @@
|
|||
$('.tags').select2();
|
||||
|
||||
function appload(appvalue) {
|
||||
if(appvalue == 'None') {
|
||||
$('#sapconfig').html('').hide();
|
||||
} else {
|
||||
$.post('{{ route('appload') }}', { app: appvalue }, function(data) {
|
||||
// Main details
|
||||
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
|
||||
|
@ -53,8 +62,11 @@
|
|||
$.get('/view/'+data.config, function(getdata) {
|
||||
$('#sapconfig').html(getdata).show();
|
||||
});
|
||||
} else {
|
||||
$('#sapconfig').html('').hide();
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue