This affects all the display plugin files (use_ajax will turn into usesAjax).

Annotations are:

 * @Plugin(
 *   id = "attachment",
 *   title = @Translation("Attachment"),
 *   help = @Translation("Attachments added to other displays to achieve multiple views in the same view."),
 *   theme = "views_view",
 *   contextual_links_locations = {""},
 *   use_ajax = TRUE,
 *   use_pager = FALSE,
 *   use_more = TRUE,
 *   accept_attachments = FALSE,
 *   help_topic = "display-attachment"
 * )

Apart from title and help, what should we do with the other properties? Should we do the same? I don't really know from how many places those are called and what / whether more files would be affected.

Working on the patch for usesAjax in the meantime.

Comments

dawehner’s picture


Apart from title and help, what should we do with the other properties? Should we do the same? I don't really know from how many places those are called and what / whether more files would be affected.

I think we should try to port them in groups which are logically connected, like uses_fields, uses_row_plugin, uses_row_class.

slv_’s picture

Status: Active » Needs review
StatusFileSize
new5.91 KB

Patch attached.

dawehner’s picture

Thanks for you patch!

I have looked at the patch and i realized that the default of the value is set to TRUE, so only subclasses which changes that need to have this value. On the other side you somehow missed to rename the calls, so there was still $this->use_ajax used,
so here is a new version for that.

slv_’s picture

Agree, no need to redeclare the property if it's not changing. Completely forgot about renaming the calls! Was the last step and missed it!. Thanks for the corrections, it looks good to me now.

aspilicious’s picture

tim will kill you for having camelcase properties:

+ protected $usesAjax = TRUE;

Hmm why define this property again in Feed?

+ /**
+ * Whether the display uses AJAX or not.
+ *
+ * @var bool
+ */
+ protected $usesAjax = FALSE;

I would just set the basePlugin $uses_ajax in the constructor

tim.plunkett’s picture

lowerCamelCase properties are correct.
And overriding it is how we did the other ones, so that's fine.

aspilicious’s picture

Status: Needs review » Reviewed & tested by the community

Whoops I was mixing properties with variable names. (/me is still tired)
Oh rly? Never done such things before in other programming languages but whateva :)

Rtbc than

dawehner’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.phpundefined
@@ -340,12 +347,11 @@ abstract class DisplayPluginBase extends PluginBase {
-  function use_ajax() {
-    if (!empty($this->definition['use_ajax'])) {
-      return $this->get_option('use_ajax');
-    }
-    return FALSE;
+  function usesAjax() {
+    return $this->usesAjax;

@@ -1239,7 +1245,7 @@ abstract class DisplayPluginBase extends PluginBase {
-    if (!empty($this->definition['use_ajax'])) {

Mh, this sadly changes the logic. Sadly that's my fault, but to keep a good standard we should talk about how to handle that.

For example $this->definition['use_ajax'] could directly use $this->usesAjax instead of calling the function. Alternative an additional parameter could also help. Any opinions?

dawehner’s picture

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

We kind of agreed that there should be two methods:

  1. getUsesProperty for just getting the definition on the object
  2. usesProperty to take into account the actual option as well

Here is a patch which should do that.

slv_’s picture

StatusFileSize
new5.64 KB

I'd suggest a name change for getUsesProperty. As it is, seems confusing and is not quite clear what it does differently from usesProperty.

If before accessing an option we need to check whether the option is allowed or not, I think it makes sense to call the method something like "allowsProperty". I think that way what the function does is self explanatory.

Patch attached with the suggested change.

aspilicious’s picture

if you go with that I should rename the property too

slv_’s picture

StatusFileSize
new5.67 KB

That's right. Amended here.

Is it the same case then for $usesOptions and other changes recently done?

Status: Needs review » Needs work

The last submitted patch, 1748102-use_ajax-12.patch, failed testing.

slv_’s picture

StatusFileSize
new5.67 KB

Oh, the rush...

slv_’s picture

Status: Needs work » Needs review
tim.plunkett’s picture

Status: Needs review » Needs work
+++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.phpundefined
@@ -57,6 +57,13 @@ abstract class DisplayPluginBase extends PluginBase {
+   * Whether the display allows the use of AJAX or not.

This makes sense as a comment.

+++ b/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.phpundefined
@@ -339,10 +346,21 @@ abstract class DisplayPluginBase extends PluginBase {
+   * Does the display type allows the use of AJAX?

This does not make sense as a comment.

slv_’s picture

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

Senseless, indeed!

Corrected and attached.

slv_’s picture

StatusFileSize
new5.74 KB

So, patch re-rolled. Renamed usesAjax() function to isAjaxEnabled().

tim.plunkett’s picture

allowsAjax to usesAJAX
isAjaxEnabled to isAJAXEnabled

slv_’s picture

StatusFileSize
new5.74 KB

patch re-rolled

aspilicious’s picture

Still the same and don't forget the property

slv_’s picture

StatusFileSize
new5.73 KB

Sorry, thought it was a writing mistake on #19! We actually wanted it back to usesAJAX! Patch re-rolled.

damiankloip’s picture

Status: Needs review » Reviewed & tested by the community

That seems good to me.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Committed it now!

Status: Fixed » Closed (fixed)

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

xjm’s picture

Assigned: slv_ » Unassigned
Status: Closed (fixed) » Active
Issue tags: +Needs change record
xjm’s picture

Title: Move use_ajax form plugin annotation to class property. » [Change notice] Move use_ajax form plugin annotation to class property.
chris matthews’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 8.x-3.x-dev » 8.7.x-dev
Component: Code » views.module
Issue summary: View changes

For more information as to why this issue was moved to the Drupal core project, please see issue #3030347: Plan to clean process issue queue

chris matthews’s picture

Project: Drupal core » Views (for Drupal 7)
Version: 8.7.x-dev » 7.x-3.x-dev
Component: views.module » Code
Status: Active » Closed (outdated)

Moving back to the contributed Views issue queue and closing as outdated per https://www.drupal.org/project/views/issues/3030347#comment-13023447