8 – correct way to access node-revision change property in twig

I have a Drupal 8.9.17 website. My theme (based on Garland) includes in templates/page.html.twig:

{% if node %}
(...)
Last updated {{ node.changed.value|format_date('custom', 'D M d Y') }}
(...)
{% endif %}

This displays the property when viewing nodes at: /node/<nid>

However, when attempting to view revisions at /node/<nid>/revisions/<vid>/view, format_date() fails with “null timestamp” error so I assume that the revision is not being properly loaded.

What is the correct way to access the property so it works at both routes?

list – TypeError: Cannot read property ‘style’ of null & TypeError: Cannot read property ‘_events’ of null

I have a list with 14 columns. One of it is “rowId” which is numbering the columns and one is “FaelligkeitUeberpruefung” which includes a date.
Everytime I edit something in the table I get the mistake “TypeError: Cannot read property ‘style’ of null & TypeError: Cannot read property ‘_events’ of null”.

Do the fields in the table have to be filled all?
If yes is there any character I shouldn´t use?
Is it a problem if I have more columns but hidden and they are empty?
Or do I only have a mistake in my code?

Thanks for helping.
Here is my full code:

<script>
function colorCodeRows() {
 
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides({
        OnPostRender: function (ctx) {
 
            // get today's date
            var today = new Date();
            // zero out the time portion so we will only compare days
            today.setHours(0,0,0,0);
 
            var rows = ctx.ListData.Row;
            for (var i = 0; i < rows.length; i++) {
 
                // get the date set in your date YourDateField
                var itemDate = new Date(rows(i)('FaelligkeitUeberpruefung'));
                // zero out the time portion so we only compare days
                itemDate.setHours(0,0,0,0);
var difference = today - itemDate;
var differencedays = difference/3600000/24;
 
                var rowId = GenerateIIDForListItem(ctx, rows(i));
                var row = document.getElementById(rowId);
 
                if (differencedays >0) {
                    row.style.backgroundColor = '#ED9898';
                }
else if(differencedays >-7)
{
row.style.backgroundColor = '#FFFF00';
}
else{row.style.backgroundColor = '#FFFFFF';}
 
            }
ctx.skipNextAnimation = true;
        }
    });
}

RegisterModuleInit(SPClientTemplates.Utility.ReplaceUrlTokens('~site/SiteAssets/Scripts/example.js'), colorCodeRows);

colorCodeRows();
</script>

Javascript :Uncaught TypeError: Cannot read property ‘innerHTML’ of undefined at HTMLButtonElement

I cannot solve this error , it tells me that my buttons are undefined and cannot read their innerHtml attribute, the convert method is defined in the original code file and i have no problem with it,can you help me , the error comes from the code section below:

var btnsArr = document.getElementsByClassName("btn")

for (var i = 0; i < btnsArr.length; i++) {
    btnsArr(i).addEventListener("click", function () {
        Convert(btnsArr(i).innerHTML);
        return false;
    })
}

javascript – TypeError: Cannot read property ‘id’ of undefined at ClientDataManager.newChannel ClientDataManager.js:81

my node.js discord bot (discord.js based) suddenly shut down an hour ago and now produces an error on startup.

:81
        guild.channels.set(channel.id, channel);
                                   ^

TypeError: Cannot read property 'id' of undefined
    at ClientDataManager.newChannel (C:UsersNHMQDesktopAInode_modulesdisco
rd.jssrcclientClientDataManager.js:81:36)
    at Guild.setup (C:UsersNHMQDesktopAInode_modulesdiscord.jssrcstructu
resGuild.js:307:68)
    at GuildCreateHandler.handle (C:UsersNHMQDesktopAInode_modulesdiscord.
jssrcclientwebsocketpacketshandlersGuildCreate.js:12:15)
    at WebSocketPacketManager.handle (C:UsersNHMQDesktopAInode_modulesdisc
ord.jssrcclientwebsocketpacketsWebSocketPacketManager.js:108:65)
    at WebSocketConnection.onPacket (C:UsersNHMQDesktopAInode_modulesdisco
rd.jssrcclientwebsocketWebSocketConnection.js:336:35)
    at WebSocketConnection.onMessage (C:UsersNHMQDesktopAInode_modulesdisc
ord.jssrcclientwebsocketWebSocketConnection.js:299:17)
    at WebSocket.onMessage (C:UsersNHMQDesktopAInode_moduleswslibevent-t
arget.js:120:16)
    at WebSocket.emit (events.js:375:28)
    at Receiver.receiverOnMessage (C:UsersNHMQDesktopAInode_moduleswslib
websocket.js:789:20)
    at Receiver.emit (events.js:375:28)```

powerapp – Change a combobox IsSearchable property to true will keep changing to false


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




python – @property in abstract base class and its subclass

I saw a code implement the abstract class as well as its subclass as follows

class ProcessProtocol(ABC):
   
    @abstractmethod
    def read_data(self):
        pass

    @property
    @abstractmethod
    def x_names(self):
        Pass

class usecase1(ProcessProtocol):
    def read_data(self):
        return read_csv_data()

    @property
    def x_names(self):
        return ('co1', 'col2', 'col3')

Here, the method of read_data is decorated with “abstractmethod”, but the function of x_names is decorated with both “property” and “abstractmethod”. What should be the design consideration of having @property for x_names

Moreover, if I need the function of x_names in subclass usecase1 to have one extra parameter, e.g.,value, so that its return will be controlled by that input value, how should I modify the above code? Should I add x_name.setter? Do I need to change abstract base class as well?

sharepoint server – Uncaught TypeError: Cannot read property ‘isNullOrUndefined’ of undefined from sp.core.js

My SharePoint 2019 classic page is not displaying list view webpart items (refreshing the page for multiple times will show the list view webpart items). When I checked the browser console found the below error.

enter image description here

When I checked for the error in sp.core.js , found the below

enter image description here

Devtools is logging that the error is occurring from the below code (from function init_zz10_TopNavigationMenu. Code is copied from the .aspx page and formatted.)

g_QuickLaunchControlIds.push("zz10_TopNavigationMenu");
_spBodyOnLoadFunctionNames.push('QuickLaunchInitDroppable');
var g_zz10_TopNavigationMenu = null;

function init_zz10_TopNavigationMenu()
{
    if (g_zz10_TopNavigationMenu == null) g_zz10_TopNavigationMenu = $create(SP.UI.AspMenu, null, null, null, $get('zz10_TopNavigationMenu'));
}
ExecuteOrDelayUntilScriptLoaded(init_zz10_TopNavigationMenu, 'SP.Core.js');

The only similar issue found in the internet was this

Could someone guide me what could be the root cause of this error. Any suggestions are greatly appreciated. Thanks.

python – How to assign to a property within a lambda expression?

I have a class that is similar to the following:

class Foo:
    def __init__(self, enabled=False):
        self._event_listeners = ()
        self._enabled = enabled
    
    def register_event_listener(self, event_listener):
        self._event_listeners.append(event_listener)

    @property
    def enabled(self):
        return self._enabled
    
    @enabled.setter
    def enabled(self, enabled):
        self._enabled = enabled
        for event_listener in self._event_listeners:
            event_listener(self)

Now, say I have two instances of Fooa and b. I would like the enabled state of b to follow that of a. My initial approach was to do this:

a.register_event_listener(lambda x, y=b: (y.enabled := x.enabled))

Where I immediately discovered that assignment expressions are not legal for properties. Is there any way to accomplish this without setattr ugliness?

Property about free variable function

Reading lambda calculus and combinators, unable to prove the following simple property about $FV$

If $x in FV(M)$ then $FV((N/x)M) = FV(N) cup (FV(M) – {x})$

javascript – Unobtrusive client validation only firing on first property in collection

I’m wrote a custom ValidationAttribute that also implements IClientValidatable so that I can perform client-side validation using the Jquery.Unobtrusive library.

The issue I have is that even though I have multiple items in the EditLeadViewMode.AssociatedUsers collection, the GetClientValidationRules method only fires once, for the first item in the collectio and only the first item on the form is validated on the client. I can’t figure out why it won’t fire/validate for all of the items in my collection.

Sample HTML from the form. You can see that the data-val-requiredassignedto attribute is not set on the second box

<select id="AssociatedUsers(1).UserId" name="AssociatedUsers(1).UserId" class="form-control valid" data-val-requiredassignedto="ErrorMessage" aria-describedby="AssociatedUsers(1).UserId-error" aria-invalid="false"><option value="">-- Assign To --</option>
<option selected="selected" value="2">A.Carlie Predovic</option>
<option value="4">A.Earline Pfeffer</option>
<option value="10">F.Dorris Dare</option>
<option value="7">I.Alexandrea Hane</option>
<option value="8">I.Alexandrea Rogahn</option>
<option value="6">I.Heber Greenfelder</option>
<option value="9">I.Maeve Koepp</option>
</select>


<select id="AssociatedUsers(2).UserId" name="AssociatedUsers(2).UserId" class="form-control" ><option value="">-- Assign To --</option>
<option value="2">A.Carlie Predovic</option>
<option value="4">A.Earline Pfeffer</option>
<option value="5">A.Jarrod Breitenberg</option>
<option selected="selected" value="3">A.Sheridan Maggio</option>
<option value="10">F.Dorris Dare</option>
</select>

ViewModel bound to the view

public sealed class EditLeadViewModel : IHelperSetup
    {
        public EditLeadViewModel()
        {
        }

        public IEnumerable<UserInLeadRole> AssociatedUsers { get; set; }
    }

public class UserInLeadRole
    {
        (AssignToUserValidationAttribute)
        public int? UserId { get; set; }
    }

Custom Attribute

 public class AssignToUserValidationAttribute : ValidationAttribute, IClientValidatable
    {
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            //Server side validation here
        }
        
        public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
        {
            return new List<ModelClientValidationRule>
            { 
                new ModelClientValidationRule{
                    ValidationType = "requiredassignedto",
                    ErrorMessage = "This field is required"
                }
            };

        }
    }

Javascript for wiring up my custom unobtrusive adapter

 function addRule(name, params, ruleFn)
    {
        $.validator.addMethod(name, ruleFn);
        $.validator.unobtrusive.adapters.add(name, params,
            function (options)
            {
                options.rules(name) = options.params;
                options.messages(name) = options.message;
            });
    }
   
    addRule("requiredassignedto",(),
        function (value, el, params) {
            ///Client side validation logic here
        });

})(jQuery);

I can’t find any documentation saying that a custom validator will only fire once on a collection, but I’m obviously missing something.