Change activate or deactivate url same url builder


 /**
     *
     * @param array $dataSource
     * @return type
     */
    public function prepareDataSource(array $dataSource)
    {
        $dataSource = parent::prepareDataSource($dataSource);

        if (empty($dataSource['data']['items'])) {
            return $dataSource;
        }

        foreach ($dataSource['data']['items'] as &$item) {
            if (isset($item['entity_id'])) {
                $viewUrlPath = "webtechbuzz/merchandising_builder_filter/view";
                $activateUrlPath = "webtechbuzz/merchandising_ajax_sale_builder/activate";

                $actionPathActive = [
                    'href' => $this->urlBuilder->getUrl(
                            $activateUrlPath,
                            [
                                'id' => $item['entity_id']
                            ]
                    ),
                    'label' => __('Activate'),
                     'isAjax' => true,

                ];

                $actionPathDeactive = [
                    'href' => $this->urlBuilder->getUrl(
                            $activateUrlPath,
                            [
                                'id' => $item['entity_id']
                            ]
                    ),
                    'label' => __('DeActivate'),
                     'isAjax' => true,

                    'confirm' => [
                        'title' => __('DeActivated "${ $.$data.name }"'),
                        'message' => __('Are you sure you wan\'t to DeActivated a "${ $.$data.name }" record?')
                    ]
                ];
                $item[$this->getData('name')] = [
                    'view' => [
                        'href' => $this->urlBuilder->getUrl(
                                $viewUrlPath,
                                [
                                    'id' => $item['entity_id']
                                ]
                        ),
                        'label' => __('View')
                    ],
                    'activate' => ($item['status'] == Config::WEBTECHBUZZ_SALES_BUILDER_FILTER_ACTIVATED) ? $actionPathDeactive : $actionPathActive
                ];
            }
        }
        return $dataSource;
    }

Leave a Reply

Your email address will not be published. Required fields are marked *