craftable icon indicating copy to clipboard operation
craftable copied to clipboard

There is an issue in pagination

Open ahmedelattar73 opened this issue 3 years ago • 3 comments

If editing the row it redirect back to the first page not to the page i came from.

ahmedelattar73 avatar Mar 23 '21 06:03 ahmedelattar73

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 21 '21 07:06 stale[bot]

Fixed in https://github.com/BRACKETS-by-TRIAD/craftable-frontend/pull/40

palypster avatar Jul 15 '21 12:07 palypster

I'm sorry but even on a brand new project the issue remains. I didn'tunderstood how to apply the fix mentioned above, meanwhile I applied a handmade workaround.

Inside the \app\Http\Controllers\Controller model I've created this method because I've reused it inside every model dedicated controller

public function rememberPrefs(Request $request) {

        if ($request->ajax()) {
            $request->session()->put('prefs', $request->input());
        }
        
        if ($request->session()->get('model') == get_class($this) && is_array($request->session()->get('prefs'))) {
            foreach ($request->session()->get('prefs') as $k => $v) {
                $request->$k = $v;
            }
        }

        $request->session()->put('model', get_class($this));

}

Inside the index method of model controller (example: \app\Http\Controllers\Admin\PostsController) I've invoked the method before the check if the request has the ajax (before if ($request->ajax()) {... )

$this->rememberPrefs($request);

Inside the store and update method I've created a variable to catch the url parameters just before the check of the ajax request check (before if ($request->ajax()) {... )

$q = http_build_query((array) $request->session()->get('prefs'));

and inside the ajax request check I've echoed the parameters in the redirect value

if ($request->ajax()) {
            return [
                'redirect' => url('admin/posts?' . $q),
                'message' => trans('brackets/admin-ui::admin.operation.succeeded'),
            ];
        }

As I mentioned in another post I'm a newbie so maybe it could be a weird solution but for now it works (even if it don't keep the search field) Because Craftable helped me a lot I try to redistribute this help. Hope this will help.

diegodeluca avatar Sep 22 '21 09:09 diegodeluca