File tree Expand file tree Collapse file tree 1 file changed +24
-6
lines changed
ckanext/blocksmith/assets/js Expand file tree Collapse file tree 1 file changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -239,11 +239,10 @@ ckan.module("blocksmith-editor", function ($) {
239239 'X-CSRFToken' : csrf_token
240240 } ,
241241 success : ( resp ) => {
242- if ( resp . success ) {
243- window . location . href = this . sandbox . client . url ( resp . result . url ) ;
244- } else {
245- console . error ( resp ) ;
246- }
242+ window . location . href = this . sandbox . client . url ( resp . result . url ) ;
243+ } ,
244+ error : ( resp ) => {
245+ this . _showErrorModal ( resp ) ;
247246 }
248247 } ) ;
249248 } ,
@@ -328,6 +327,25 @@ ckan.module("blocksmith-editor", function ($) {
328327 */
329328 _onUrlBlur : function ( e ) {
330329 e . target . value = this . _slugify ( e . target . value ) ;
331- }
330+ } ,
331+
332+ /**
333+ * Show an error modal.
334+ *
335+ * @param {object } resp
336+ */
337+ _showErrorModal : function ( resp ) {
338+ const modal = this . editor . Modal ;
339+ modal . setTitle ( 'Save Error' ) ;
340+ modal . setContent ( `
341+ <div style="padding: 10px;">
342+ <p><strong>There was a problem saving the page.</strong></p>
343+ <pre style="background: white; color: black; padding: 10px; border-radius: 3px;">
344+ ${ JSON . stringify ( resp . responseJSON , null , 2 ) }
345+ </pre>
346+ </div>
347+ ` ) ;
348+ modal . open ( ) ;
349+ } ,
332350 }
333351} ) ;
You can’t perform that action at this time.
0 commit comments