Draft: Issue #3457119 by kksandr: added support for remembering sorting in view tables
5 unresolved threads
5 unresolved threads
Closes #3457119
Merge request reports
Activity
62 66 */ 63 67 public $order; 64 68 69 /** 70 * The current user. 71 */ 72 protected AccountInterface $currentUser; 73 74 /** 75 * {@inheritdoc} 76 */ 77 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { 78 $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); 79 $instance->currentUser = $container->get('current_user'); 75 93 $options['summary'] = ['default' => '']; 76 94 $options['description'] = ['default' => '']; 77 95 $options['empty_table'] = ['default' => FALSE]; 96 $options['remember'] = ['default' => FALSE]; 101 121 * Add our actual sort criteria. 102 122 */ 103 123 public function buildSortPost() { 104 $query = $this->view->getRequest()->query; 124 $request = $this->view->getRequest(); 125 $query = $request->query; 105 126 $order = $query->get('order'); 106 if (!isset($order)) { 107 // check for a 'default' clickSort. If there isn't one, exit gracefully. 108 if (empty($this->options['default'])) { 109 return; 127 // Try to get the remembered sort selection from the session. 128 if ($this->options['remember']) { 129 $allowed_rids = array_filter($this->options['remember_roles']); 130 if ($allowed_rids && array_intersect(array_keys($allowed_rids), $this->currentUser->getRoles())) { 131 $display_id = ($this->view->display_handler->isDefaulted('filters')) ? 'default' : $this->view->current_display;
Please register or sign in to reply