Skip to content

Commit

Permalink
WIP Watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Nov 8, 2024
1 parent c911d05 commit b619bad
Show file tree
Hide file tree
Showing 14 changed files with 141,281 additions and 115 deletions.
20,360 changes: 20,346 additions & 14 deletions public/css/orchid.css

Large diffs are not rendered by default.

20,345 changes: 20,327 additions & 18 deletions public/css/orchid.rtl.css

Large diffs are not rendered by default.

190 changes: 189 additions & 1 deletion public/js/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35,738 changes: 35,733 additions & 5 deletions public/js/orchid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/js/orchid.js.map

Large diffs are not rendered by default.

64,497 changes: 64,495 additions & 2 deletions public/js/vendor.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions public/mix-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions resources/js/controllers/test_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import ApplicationController from "./application_controller";

export default class extends ApplicationController {

static values = {
watched: {
type: Array,
default: [],
},
url: {
type: String,
},
}

/**
*
*/
connect() {
this.watchedValue.forEach(name => {
document.querySelectorAll(`[name="${name}"]`)
.forEach((field) =>
field.addEventListener('change', () => this.refresh())
);
});
}

/**
*
*/
refresh() {
const data = new FormData(this.element.closest('form'));

let state = document.getElementById('screen-state').value;

// Added state to send
if (state.length > 0) {
data.append('_state', state)
}

this.loadStream(this.urlValue, data);
}
}
34 changes: 20 additions & 14 deletions resources/views/layouts/base.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@
@stack('modals-container')
</div>

<form id="post-form"
class="mb-md-4 h-100"
method="post"
enctype="multipart/form-data"
data-controller="form"
data-form-need-prevents-form-abandonment-value="{{ var_export($needPreventsAbandonment) }}"
data-form-failed-validation-message-value="{{ $formValidateMessage }}"
data-action="keypress->form#disableKey
<x-orchid-stream target="post-form" :rule="\request()->routeIs('platform.watch')">

<form id="post-form"
class="mb-md-4 h-100"
method="post"
enctype="multipart/form-data"
data-controller="form test"
data-test-watched-value="{{ $watched }}"
data-test-url-value="{{ route('platform.watch') }}"
data-form-need-prevents-form-abandonment-value="{{ var_export($needPreventsAbandonment) }}"
data-form-failed-validation-message-value="{{ $formValidateMessage }}"
data-action="keypress->form#disableKey
turbo:before-fetch-request@document->form#confirmCancel
beforeunload@window->form#confirmCancel
change->form#changed
form#submit"
novalidate
>
{!! $layouts !!}
@csrf
@include('platform::partials.confirm')
</form>
novalidate
>
{!! $layouts !!}
@csrf
@include('platform::partials.confirm')
</form>

</x-orchid-stream>

<div data-controller="filter">
<form id="filters" autocomplete="off"
Expand Down
3 changes: 3 additions & 0 deletions routes/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
Route::post('listener/{screen}/{layout}', [AsyncController::class, 'listener'])
->name('async.listener');

Route::post('watch', [AsyncController::class, 'watch'])
->name('watch');

// TODO: Remove group
Route::prefix('systems')->group(function () {
Route::post('files', [AttachmentController::class, 'upload'])
Expand Down
12 changes: 12 additions & 0 deletions src/Platform/Http/Controllers/AsyncController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ public function listener(Request $request, string $screen, string $layout)

return $screen->asyncParticalLayout($layout, $request);
}

/**
* @param \Illuminate\Http\Request $request
*
* @return mixed
*/
public function watch(Request $request)
{
$screen = Crypt::decrypt($request->input('_state'));

return app()->call([$screen, 'asyncParticalRefresh']);
}
}
1 change: 0 additions & 1 deletion src/Screen/Fields/Relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ public function displayAppend(string $append): self
/**
* Set the maximum number of items that may be selected.
*
*
* @return $this
*/
public function max(int $number)
Expand Down
Loading

0 comments on commit b619bad

Please sign in to comment.