feat: Inject password from db during testing when editing enhanced apps

This commit is contained in:
Attila Kerekes 2022-11-19 20:21:10 +01:00 committed by Attila Jozsef Kerekes
parent 9a80064a50
commit 8bad474808
No known key found for this signature in database
GPG key ID: E1121565A016ADFD
6 changed files with 33 additions and 2824 deletions

View file

@ -407,6 +407,15 @@ class ItemController extends Controller
$single = Application::single($data['type']);
$app = $single->class;
// If password is not resubmitted fill it from the database when in edit mode
if ($data['password'] === null && array_key_exists('id', $data)) {
$item = Item::find($data['id']);
if ($item) {
$itemConfig = $item->getConfig();
$data['password'] = $itemConfig->password;
}
}
$app_details = new $app();
$app_details->config = (object) $data;
$app_details->test();

2068
public/css/app.css vendored

File diff suppressed because one or more lines are too long

756
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
{
"/css/app.css": "/css/app.css?id=ad45b1705b7f7906db0b",
"/js/app.js": "/js/app.js?id=19a3a77634861ef418d7"
"/css/app.css": "/css/app.css?id=fb9e13c65ffee8ba7340",
"/js/app.js": "/js/app.js?id=7f1d4778de811d7fc901"
}

View file

@ -2,6 +2,18 @@ $.when( $.ready ).then(function() {
var base = (document.querySelector('base') || {}).href;
var itemID = $('form[data-item-id]').data('item-id');
var fakePassword = '*****';
// If in edit mode and password field is present, fill it with stars
if (itemID) {
var passwordField = $('input[name="config[password]"]').first();
if (passwordField.length > 0) {
passwordField.attr('value', fakePassword);
}
}
if($('.message-container').length) {
setTimeout(
function()
@ -224,6 +236,12 @@ $.when( $.ready ).then(function() {
data[config] = $(this).val();
});
data['id'] = $('form[data-item-id]').data('item-id');
if (data.password && data.password === fakePassword) {
data.password = '';
}
$.post(base+'test_config', { data: data }, function(data) {
alert(data);
});

View file

@ -2,7 +2,7 @@
@section('content')
{!! Form::model($item, ['method' => 'PATCH', 'id' => 'itemform', 'files' => true, 'route' => ['items.update', $item->id]]) !!}
{!! Form::model($item, ['data-item-id' =>$item->id, 'method' => 'PATCH', 'id' => 'itemform', 'files' => true, 'route' => ['items.update', $item->id]]) !!}
@include('items.form')
{!! Form::close() !!}