Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to the records data set are not updating when in component #8

Open
awizemann opened this issue May 25, 2021 · 0 comments
Open

Comments

@awizemann
Copy link

awizemann commented May 25, 2021

I have implemented your status board library and have it working as documented. It is exactly what I needed to help maintain a large set of tasks and what status they are in. The problem I have is that I have a list of "filters" that change the records that are being mapped in the records() function, and they are not updating. I have a simple log call in the records function that I am using to even test if there is activity when I am changing the filter. I can confirm that the change is happening as the other list views and pagination is changing.

Here is my records function:

public function records(): Collection
    {
    
        ray("records called");
        return $this->tasks
        ->map(function (Task $task) {
            return [
                'id' => $task->id,
                'title' => $task->task_title,
                'status' => $task->status,
                'task' => $task
            ];
        });

    }

I am getting tasks (records for this) from a property function in a trait (however I can confirm this also doesn't work if it isn't in a trait).

public function getTasksProperty()
    {
        ray("getting tasks...");

        // Compose Query
        // Base Queries
        $query = Task::query();
        $query = $query->where('organization_id', Auth::user()->organization_id);
        $query = $query->where('task_title', 'like', '%' . $this->search . '%');


        // Variables for Query
        switch ($this->filter) {
            default:
            case ('open'):
                $query = $query->where('user_id', Auth::user()->id);
                $query = $query->where('complete', '0');
                break;

            case ('assigned'):
                $query = $query->where('assigned_to', Auth::user()->id);
                $query = $query->where('complete', '0');
                break;

            case ('completed'):
                $query = $query->where('assigned_to', Auth::user()->id);
                $query = $query->where('complete', '1');
                break;
        }

        switch ($this->section) {
            case ('meetings'):
                $query = $query->where('meeting_id', $this->sectionItem);
                break;

            case ('projects'):
                $query = $query->where('project_id', $this->sectionItem);
                break;

            case ('people'):
                $query = $query->where('assigned_to', $this->sectionItem);
                break;
        }

        // Base Order/Paginate Queries
        $query = $query->with('user');
        $query = $query->with('subtasks');
        $query = $query->with('updates');
        $query = $query->orderBy('pin', 'desc');
        $query = $query->orderBy('priority', 'desc');
        $query = $query->orderBy('due', 'asc');

        if($this->component == 'board') {
            $results = $query->get();
        } else {
            $results = $query->paginate($this->tasksPerPage);
        }


        return $results;
    }

When a change happens to a filter should I also refresh the component? Any help here would be appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant