Uncheck "create account" on Special:Block for partial blocks
authorThalia <thalia.e.chan@googlemail.com>
Wed, 13 Feb 2019 13:08:22 +0000 (13:08 +0000)
committerThalia <thalia.e.chan@googlemail.com>
Mon, 18 Feb 2019 17:19:07 +0000 (17:19 +0000)
Set the default state for the checkbox for preventing a user
from creating an account to unchecked, if the block is set to
partial. However, if the user has already interacted with the
checkbox, do not change its state just because the block type
changes.

Bug: T208510
Change-Id: If17b82b03553810508f22070865719bd1926949d

resources/src/mediawiki.special.block.js

index 58409b4..02e380a 100644 (file)
                        editingRestrictionWidget = infuseIfExists( $( '#mw-input-wpEditingRestriction' ) ),
                        preventTalkPageEdit = infuseIfExists( $( '#mw-input-wpDisableUTEdit' ) ),
                        pageRestrictionsWidget = infuseIfExists( $( '#mw-input-wpPageRestrictions' ) ),
-                       namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) );
+                       namespaceRestrictionsWidget = infuseIfExists( $( '#mw-input-wpNamespaceRestrictions' ) ),
+                       createAccountWidget = infuseIfExists( $( '#mw-input-wpCreateAccount' ) ),
+                       userChangedCreateAccount = false,
+                       updatingBlockOptions = false;
 
                function updateBlockOptions() {
                        var blocktarget = blockTargetWidget.getValue().trim(),
                                        ) === -1
                                );
                        }
+                       if ( !userChangedCreateAccount ) {
+                               updatingBlockOptions = true;
+                               createAccountWidget.setSelected( isSitewide );
+                               updatingBlockOptions = false;
+                       }
 
                }
 
                                namespaceRestrictionsWidget.on( 'change', updateBlockOptions );
                        }
 
+                       createAccountWidget.on( 'change', function () {
+                               if ( !updatingBlockOptions ) {
+                                       userChangedCreateAccount = true;
+                               }
+                       } );
+
                        // Call them now to set initial state (ie. Special:Block/Foobar?wpBlockExpiry=2+hours)
                        updateBlockOptions();
                }