/** * {@inheritdoc} */ public function access(AccountInterface $account) { if ($this->options['expose']['hide_no_continuous'] && !$this->continuousManager->hasContinuousJobs()) { return FALSE; } return parent::access($account); }
public function valueForm(&$form, FormStateInterface $form_state) { parent::valueForm($form, $form_state); $exposed = $form_state->get('exposed'); if (!$exposed || empty($this->options['expose']['autocomplete_filter'])) { // It is not an exposed form or autocomplete is not enabled. return; } if (empty($form['value']['#type']) || $form['value']['#type'] !== 'textfield') { // Not a textfield. return; } // Add autocomplete path to the exposed textfield. $view_args = !empty($this->view->args) ? implode('||', $this->view->args) : 0; $form['value']['#autocomplete_route_name'] = 'viewsfilters.autocomplete'; $form['value']['#autocomplete_route_parameters'] = array('view_name' => $this->view->storage->get('id'), 'view_display' => $this->view->current_display, 'filter_name' => $this->options['id'], 'view_args' => $view_args); // Add JS script with core autocomplete overrides to the end of JS files // list to be sure it is added after the "misc/autocomplete.js" file. Also // mark the field with special class. if (!empty($this->options['expose']['autocomplete_dependent'])) { $form['#attached']['library'][] = 'views_autocomplete_filters/drupal.views-autocomplete-filters-dependent'; $form['value']['#attributes']['class'][] = 'views-ac-dependent-filter'; } }
/** * {@inheritdoc} */ public function validate() { $errors = parent::validate(); $fields = $this->view->display_handler->getHandlers('field'); foreach ($this->options['fields'] as $id) { if (!isset($fields[$id])) { // Combined field filter only works with fields that are in the field // settings. $errors[] = $this->t('Field %field set in %filter is not set in this display.', array('%field' => $id, '%filter' => $this->adminLabel())); break; } } return $errors; }
/** * {@inheritdoc} */ public function validate() { $errors = parent::validate(); $fields = $this->view->display_handler->getHandlers('field'); foreach ($this->options['fields'] as $id) { if (!isset($fields[$id])) { // Combined field filter only works with fields that are in the field // settings. $errors[] = $this->t('Field %field set in %filter is not set in this display.', array('%field' => $id, '%filter' => $this->adminLabel())); break; } elseif (!$fields[$id]->clickSortable()) { // Combined field filter only works with simple fields. If the field is // not click sortable we can assume it is not a simple field. // @todo change this check to isComputed. See // https://www.drupal.org/node/2349465 $errors[] = $this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => $fields[$id]->adminLabel(), '%filter' => $this->adminLabel())); } } return $errors; }
/** * {@inheritdoc} */ public function validate() { $errors = parent::validate(); if ($this->displayHandler->usesFields()) { $fields = $this->displayHandler->getHandlers('field'); foreach ($this->options['fields'] as $id) { if (!isset($fields[$id])) { // Combined field filter only works with fields that are in the field // settings. $errors[] = $this->t('Field %field set in %filter is not set in display %display.', array('%field' => $id, '%filter' => $this->adminLabel(), '%display' => $this->displayHandler->display['display_title'])); break; } elseif (!$fields[$id]->clickSortable()) { // Combined field filter only works with simple fields. If the field // is not click sortable we can assume it is not a simple field. // @todo change this check to isComputed. See // https://www.drupal.org/node/2349465 $errors[] = $this->t('Field %field set in %filter is not usable for this filter type. Combined field filter only works for simple fields.', array('%field' => $fields[$id]->adminLabel(), '%filter' => $this->adminLabel())); } } } else { $errors[] = $this->t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', array('%display' => $this->displayHandler->display['display_title'], '%filter' => $this->adminLabel())); } return $errors; }