RCFilters: Display specific error if query times out
[lhc/web/wiklou.git] / resources / src / mediawiki.rcfilters / ui / mw.rcfilters.ui.FormWrapperWidget.js
index 5a64edd..4edc272 100644 (file)
@@ -87,7 +87,6 @@
         */
        mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelInvalidate = function () {
                this.$submitButton.prop( 'disabled', true );
-               this.$element.removeClass( 'mw-rcfilters-ui-ready' );
        };
 
        /**
         *
         * @param {jQuery|string} $changesList Updated changes list
         * @param {jQuery} $fieldset Updated fieldset
+        * @param {boolean} isDatabaseTimeout Whether this is an error state due to a database query
         * @param {boolean} isInitialDOM Whether $changesListContent is the existing (already attached) DOM
         */
-       mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset, isInitialDOM ) {
+       mw.rcfilters.ui.FormWrapperWidget.prototype.onChangesModelUpdate = function ( $changesList, $fieldset, isDatabaseTimeout, isInitialDOM ) {
                this.$submitButton.prop( 'disabled', false );
-               this.$element.removeClass( 'mw-rcfilters-ui-ready' );
 
                // Replace the entire fieldset
                this.$element.empty().append( $fieldset.contents() );
                        this.$element.find( 'hr' ).detach();
                }
 
+               // Get rid of all <br>s, which are inside rcshowhide
+               // If we still have content in rcshowhide, the <br>s are
+               // gone. Instead, the CSS now has a rule to mark all <span>s
+               // inside .rcshowhide with display:block; to simulate newlines
+               // where they're actually needed.
+               this.$element.find( 'br' ).detach();
                if ( !this.$element.find( '.rcshowhide' ).contents().length ) {
                        this.$element.find( '.rcshowhide' ).detach();
-                       // If we're hiding rcshowhide, the '<br>'s are around it,
-                       // there's no need for them either.
-                       this.$element.find( 'br' ).detach();
                }
 
                if ( this.$element.find( '.cloption' ).text().trim() === '' ) {
                        this.$element.find( '.cloption-submit' ).detach();
                }
 
-               if ( mw.rcfilters.featureFlags.liveUpdate ) {
-                       this.$element.find(
-                               '.rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
-                       ).detach();
-               }
+               this.$element.find(
+                       '.rclistfrom, .rcnotefrom, .rcoptions-listfromreset'
+               ).detach();
+
+               // Get rid of the legend
+               this.$element.find( 'legend' ).detach();
 
-               if ( this.$element.text().trim() === this.$element.find( 'legend' ).text() ) {
+               // Check if the element is essentially empty, and detach it if it is
+               if ( !this.$element.text().trim().length ) {
                        this.$element.detach();
                }
        };