While writing tests in #1866804: Expand test coverage for ViewExecutable(), it seems it would be good to add a getUseAJAX getter to match setUseAJAX.

This is postponed on issue above, tests can be converted to use this method, so then this is tested too.

Comments

damiankloip’s picture

Status: Postponed » Needs review
damiankloip’s picture

Title: Add a getUseAJAX() method for ViewExecutable » Add a usesAJAX() method for ViewExecutable
StatusFileSize
new3.3 KB

Ok, changed the title and the patch to reflect that.

damiankloip’s picture

StatusFileSize
new3.52 KB

And the ViewExecutableTest needs that change too.

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.phpundefined
@@ -250,7 +250,8 @@ public function testRenderNullPager() {
+    // force the value again here.

Let's "Force" it :)

+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/PagerTest.phpundefined
@@ -250,7 +250,8 @@ public function testRenderNullPager() {
+    $view->setUseAJAX(TRUE);

Should be better setUsesAJAX?

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -67,7 +67,7 @@ class ViewExecutable {
+  public $usesAJAX = FALSE;

What about making it protected now?

damiankloip’s picture

StatusFileSize
new2.23 KB
new3.66 KB

All good points. Also cast the setUsesAJAX value to a bool. I know you don't care but do we trust people?! ;)

dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -545,8 +545,19 @@ public function usePager() {
    * rather than a page refresh.

What about documenting the parameter as boolean?

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -545,8 +545,19 @@ public function usePager() {
+   * @see setUseAJAX().

I guess we should use ViewExecuteable::setUsesAJAX here (maybe even with full namespace).

damiankloip’s picture

StatusFileSize
new4.04 KB

Yep, good point. Let's change that too.

damiankloip’s picture

StatusFileSize
new1.07 KB

Oops, and the diff.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

It adds test coverage, has proper documentation etc.

PS: you could nitpick $use_ajax -> $uses_ajax

damiankloip’s picture

StatusFileSize
new4.04 KB

I actually thought about leaving this as use_ajax, but don't mind. I guess uses makes a bit more sense, to match the method.

Don't you just love small issues that have lots of patches ;)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 1866910-9.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new4.83 KB

Oops, sorry.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Perfect, thank you for all the small changes!

catch’s picture

Status: Reviewed & tested by the community » Needs work

setUseAjax() and setUsesAjax() are strange method names. Could it be at least get/set? Is 'uses' the best word here?

damiankloip’s picture

StatusFileSize
new4.45 KB
new5.4 KB

OK, from a brief IRC discussion; let's change this to ajaxEnabled().

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new5.41 KB

Sorry, missed one in views.module.

damiankloip’s picture

Title: Add a usesAJAX() method for ViewExecutable » Add an ajaxEnabled() method for ViewExecutable
dawehner’s picture

+++ b/core/modules/views/lib/Drupal/views/ViewExecutable.phpundefined
@@ -549,19 +549,19 @@ public function usePager() {
+  public function ajaxEnabled() {
+    return $this->ajaxEnabled;
   }

To be honest, it's confusing to both have isAJAXEnabled on the display but also AjaxEnabled, at least we should use AJAXEnabled, but i really vote for more consistency. Either the view or the display uses ajax. This seems not to be rocket science.

damiankloip’s picture

StatusFileSize
new1.58 KB
new6.26 KB

You are right, this should in theory be easy :) and consistency is king. I have changed isAJAXEnabled to ajaxEnabled to we have the same on both ViewExecutable and DisplayPluginBase.

dawehner’s picture

Oh didn't we agreed in Paris to always use uppercase for shortcuts?

damiankloip’s picture

Yeah, we did indeed :) But I spoke to catch/timplunkett and they wanted ajaxEnabled I think...

damiankloip’s picture

StatusFileSize
new5.77 KB

Re rolled.

Status: Needs review » Needs work

The last submitted patch, 1866910-22.patch, failed testing.

damiankloip’s picture

FFS

damiankloip’s picture

Status: Needs work » Needs review

#22: 1866910-22.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Okay, so this looks good now!

catch’s picture

Status: Reviewed & tested by the community » Fixed

There's an issue somewhere about ajax vs. AJAX in method names, I prefer the latter (at least when it's something like testCss() which just looks silly), but I think at the moment it's just camel case in core.

Committed/pushed this to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.