Skip to content

Commit 1ccc0da

Browse files
authored
Merge pull request #1476 from KodeStar/2.x
Load in configs values if class has been lost
2 parents e42f78b + 41aa255 commit 1ccc0da

4 files changed

Lines changed: 24 additions & 3 deletions

File tree

app/Http/Controllers/ItemController.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ public function index(Request $request): View
194194
public function create(): View
195195
{
196196
//
197+
$data['item'] = new \App\Item();
197198
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
198199
$data['tags']->prepend(__('app.dashboard'), 0);
199200
$data['current_tags'] = '0';
@@ -422,6 +423,7 @@ public function appload(Request $request): ?string
422423
{
423424
$output = [];
424425
$appid = $request->input('app');
426+
$itemId = $request->input('item_id');
425427

426428
if ($appid === 'null') {
427429
return null;
@@ -436,8 +438,10 @@ public function appload(Request $request): ?string
436438
$appdetails = Application::getApp($appid);
437439

438440
if ((bool)$app->enhanced === true) {
441+
$item = $itemId ? Item::find($itemId) : Item::where('appid', $appid)->first();
439442
// if(!isset($app->config)) { // class based config
440443
$output['custom'] = className($appdetails->name) . '.config';
444+
$output['appvalue'] = $item->description;
441445
// }
442446
}
443447

config/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
return [
77

8-
'version' => '2.7.1',
8+
'version' => '2.7.2',
99

1010
'appsource' => env('APP_SOURCE', 'https://appslist.heimdall.site/'),
1111

resources/views/items/form.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<section class="module-container">
22
@if($enable_auth_admin_controls)
33
<header>
4+
{{ html()->hidden('app_id', $item->id) }}
45
<div class="section-title">{{ __('app.apps.preview') }}</div>
56
<div class="module-actions">
67
<div class="toggleinput">
@@ -120,7 +121,7 @@
120121
@if(isset($item) && $item->enhanced())
121122

122123
<div id="sapconfig" style="display: block;">
123-
@if(isset($item))
124+
@if(isset($item) && $item->class)
124125
@include('SupportedApps::'.App\Item::nameFromClass($item->class).'.config')
125126
@endif
126127
</div>

resources/views/items/scripts.blade.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,14 @@
171171
})
172172
173173
function appload(appvalue) {
174+
const itemId = $('input[name="item_id"]').val();
174175
if(appvalue == 'null') {
175176
$('#sapconfig').html('').hide();
176177
$('#tile-preview .app-icon').attr('src', '/img/heimdall-icon-small.png');
177178
$('#appimage').html("<img src='/img/heimdall-icon-small.png' />");
178179
$('#sapconfig').html('').hide();
179180
} else {
180-
$.post('{{ route('appload') }}', { app: appvalue }, function(data) {
181+
$.post('{{ route('appload') }}', { app: appvalue, item_id: itemId }, function(data) {
181182
// Main details
182183
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.iconview+"' />");
183184
$('input[name=colour]').val(data.colour);
@@ -194,6 +195,21 @@ function appload(appvalue) {
194195
if(data.custom != null) {
195196
$.get(base+'view/'+data.custom, function(getdata) {
196197
$('#sapconfig').html(getdata).show();
198+
// Populate fields in the loaded form with description data
199+
if (data.description) {
200+
const description = JSON.parse(data.appvalue);
201+
Object.keys(description).forEach(function(key) {
202+
const value = description[key];
203+
const field = $(`#sapconfig [name="config[${key}]"]`);
204+
if (field.length) {
205+
if (field.is(':checkbox')) {
206+
field.prop('checked', value);
207+
} else {
208+
field.val(value);
209+
}
210+
}
211+
});
212+
}
197213
});
198214
} else {
199215
$('#sapconfig').html('').hide();

0 commit comments

Comments
 (0)