Skip to content

Commit f1c54fc

Browse files
committed
wip
1 parent 6ba682c commit f1c54fc

File tree

8 files changed

+6
-1438
lines changed

8 files changed

+6
-1438
lines changed

src/app/Http/Controllers/Operations/CreateOperation.php

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,22 +37,13 @@ protected function setupCreateDefaults()
3737
$this->crud->allowAccess('create');
3838

3939
LifecycleHook::hookInto('create:before_setup', function () {
40+
$this->crud->loadDefaultOperationSettingsFromConfig();
4041
$this->crud->setupDefaultSaveActions();
4142
});
4243

4344
LifecycleHook::hookInto('list:before_setup', function () {
4445
$this->crud->addButton('top', 'create', 'view', 'crud::buttons.create');
4546
});
46-
47-
LifecycleHook::hookInto('list:after_setup', function () {
48-
// Check if modal form is enabled and replace the button if needed
49-
$useModalForm = $this->crud->get('create.createButtonWithModalForm') ?? config('backpack.operations.create.createButtonWithModalForm', false);
50-
51-
if ($useModalForm) {
52-
$this->crud->removeButton('create');
53-
$this->crud->addButton('top', 'create', 'view', 'crud::buttons.create_in_modal', 'beginning');
54-
}
55-
});
5647
}
5748

5849
/**
@@ -64,20 +55,13 @@ public function create()
6455
{
6556
$this->crud->hasAccessOrFail('create');
6657

67-
// Apply cached form setup if this is an AJAX request from a modal
68-
if (request()->ajax() && request()->has('_modal_form_id')) {
69-
\Backpack\CRUD\app\Library\Support\DataformCache::applySetupClosure($this->crud);
70-
}
71-
7258
// prepare the fields you need to show
7359
$this->data['crud'] = $this->crud;
7460
$this->data['saveAction'] = $this->crud->getSaveAction();
7561
$this->data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.add').' '.$this->crud->entity_name;
7662

7763
// return the ajax response for modal forms, or the normal view for normal requests
78-
return request()->ajax() && request()->has('_modal_form_id') ?
79-
view('crud::components.dataform.ajax_response', $this->data) :
80-
view($this->crud->getCreateView(), $this->data);
64+
return view($this->crud->getCreateView(), $this->data);
8165
}
8266

8367
/**

src/app/Http/Controllers/Operations/UpdateOperation.php

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@ protected function setupUpdateDefaults()
5353
LifecycleHook::hookInto(['list:before_setup', 'show:before_setup'], function () {
5454
$this->crud->addButton('line', 'update', 'view', 'crud::buttons.update', 'end');
5555
});
56-
57-
LifecycleHook::hookInto(['list:after_setup', 'show:after_setup'], function () {
58-
// Check if modal form is enabled and replace the button if needed
59-
$useModalForm = $this->crud->get('update.updateButtonWithModalForm') ?? config('backpack.operations.update.updateButtonWithModalForm', false);
60-
61-
if ($useModalForm) {
62-
$this->crud->removeButton('update');
63-
$this->crud->addButton('line', 'update', 'view', 'crud::buttons.update_in_modal', 'end');
64-
}
65-
});
6656
}
6757

6858
/**
@@ -78,38 +68,21 @@ public function edit($id)
7868
// get entry ID from Request (makes sure its the last ID for nested resources)
7969
$id = $this->crud->getCurrentEntryId() ?? $id;
8070

81-
// Apply cached form setup if this is an AJAX request from a modal
82-
if (request()->ajax() && request()->has('_modal_form_id')) {
83-
\Backpack\CRUD\app\Library\Support\DataformCache::applySetupClosure($this->crud);
84-
}
85-
8671
// register any Model Events defined on fields
8772
$this->crud->registerFieldEvents();
8873

8974
// get the info for that entry
9075
$this->data['entry'] = $this->crud->getEntryWithLocale($id);
91-
92-
// Attempt to apply cached modal setup first (this will restore
93-
// fields and entry if the request included _modal_form_id). If
94-
// no cached setup applied, fall back to the regular update fields.
95-
$appliedFromCache = false;
96-
if (request()->ajax() && request()->has('_modal_form_id')) {
97-
$appliedFromCache = \Backpack\CRUD\app\Library\Support\DataformCache::applySetupClosure($this->crud);
98-
}
99-
100-
if (! $appliedFromCache) {
101-
$this->crud->setOperationSetting('fields', $this->crud->getUpdateFields());
102-
}
103-
76+
77+
$this->crud->setOperationSetting('fields', $this->crud->getUpdateFields());
78+
10479
$this->data['crud'] = $this->crud;
10580
$this->data['saveAction'] = $this->crud->getSaveAction();
10681
$this->data['title'] = $this->crud->getTitle() ?? trans('backpack::crud.edit').' '.$this->crud->entity_name;
10782
$this->data['id'] = $id;
10883

10984
// load the view from /resources/views/vendor/backpack/crud/ if it exists, otherwise load the one in the package
110-
return request()->ajax() && request()->has('_modal_form_id') ?
111-
view('crud::components.dataform.ajax_response', $this->data) :
112-
view($this->crud->getEditView(), $this->data);
85+
return view($this->crud->getEditView(), $this->data);
11386
}
11487

11588
/**

src/app/View/Components/DataformModal.php

Lines changed: 0 additions & 100 deletions
This file was deleted.

src/resources/views/crud/buttons/create_in_modal.blade.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/resources/views/crud/buttons/update_in_modal.blade.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/resources/views/crud/components/dataform/ajax_response.blade.php

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)