jenkins-bot has submitted this change and it was merged.

Change subject: Avoid error when cite is missing a templateName in the config 
map
......................................................................


Avoid error when cite is missing a templateName in the config map

Bug: T124107
Change-Id: I2267f888f5be69b373e23d364ccc522474415563
---
M modules/ve.ui.CiteFromIdInspector.js
1 file changed, 24 insertions(+), 10 deletions(-)

Approvals:
  Alex Monk: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve.ui.CiteFromIdInspector.js 
b/modules/ve.ui.CiteFromIdInspector.js
index 3fab695..d9963b6 100644
--- a/modules/ve.ui.CiteFromIdInspector.js
+++ b/modules/ve.ui.CiteFromIdInspector.js
@@ -541,6 +541,9 @@
                                return inspector.buildTemplateResults( 
searchResults )
                                        .then( function () {
                                                inspector.setModePanel( 'auto', 
'result' );
+                                       }, function () {
+                                               inspector.lookupFailed();
+                                               return $.Deferred().resolve();
                                        } );
                        },
                        // Fail
@@ -548,13 +551,7 @@
                                if ( response && response.textStatus === 
'abort' ) {
                                        return $.Deferred().reject();
                                }
-                               // Enable the input and lookup button
-                               inspector.$noticeLabel.removeClass( 
'oo-ui-element-hidden' );
-                               inspector.lookupInput.once( 'change', function 
() {
-                                       inspector.$noticeLabel.addClass( 
'oo-ui-element-hidden' );
-                                       inspector.updateSize();
-                               } ).setValidityFlag( false );
-                               inspector.updateSize();
+                               inspector.lookupFailed();
                                return $.Deferred().resolve();
                        } )
                .always( function () {
@@ -568,6 +565,19 @@
                } )
                .promise( { abort: xhr.abort } );
        return this.lookupPromise;
+};
+
+/**
+ * Set the auto panel to the error-state
+ */
+ve.ui.CiteFromIdInspector.prototype.lookupFailed = function () {
+       // Enable the input and lookup button
+       this.$noticeLabel.removeClass( 'oo-ui-element-hidden' );
+       this.lookupInput.once( 'change', function () {
+               this.$noticeLabel.addClass( 'oo-ui-element-hidden' );
+               this.updateSize();
+       }.bind( this ) ).setValidityFlag( false );
+       this.updateSize();
 };
 
 /**
@@ -626,9 +636,13 @@
                                optionWidgets.push( refWidget );
                                renderPromises.push( 
refWidget.getRenderPromise() );
                        }
-                       // Add to the select widget
-                       inspector.previewSelectWidget.addItems( optionWidgets );
-                       return $.when.apply( $, renderPromises );
+                       if ( optionWidgets.length > 0 ) {
+                               // Add to the select widget
+                               inspector.previewSelectWidget.addItems( 
optionWidgets );
+                               return $.when.apply( $, renderPromises );
+                       }
+                       // failed, so go back
+                       return $.Deferred().reject();
                } );
 };
 

-- 
To view, visit https://gerrit.wikimedia.org/r/281691
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I2267f888f5be69b373e23d364ccc522474415563
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to