[MediaWiki-commits] [Gerrit] mediawiki...CollaborationKit[master]: Fix js list editing in the single column case
jenkins-bot has submitted this change and it was merged. Change subject: Fix js list editing in the single column case .. Fix js list editing in the single column case Change-Id: If5da95c161123f118cae86fb7ac640232a142044 --- M includes/content/CollaborationListContent.php M modules/ext.CollaborationKit.list.edit.js 2 files changed, 23 insertions(+), 19 deletions(-) Approvals: Brian Wolff: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/content/CollaborationListContent.php b/includes/content/CollaborationListContent.php index f668ed8..46ba902 100644 --- a/includes/content/CollaborationListContent.php +++ b/includes/content/CollaborationListContent.php @@ -912,10 +912,7 @@ && $title->userCan( 'edit', $user, 'quick' ) ) { $output->addJsConfigVars( 'wgEnableCollaborationKitListEdit', true ); - /* - Disabling until JavaScript module is updated. $output->addModules( 'ext.CollaborationKit.list.edit' ); - */ $output->preventClickjacking(); } } diff --git a/modules/ext.CollaborationKit.list.edit.js b/modules/ext.CollaborationKit.list.edit.js index 6012bbd..8c83a08 100644 --- a/modules/ext.CollaborationKit.list.edit.js +++ b/modules/ext.CollaborationKit.list.edit.js @@ -37,7 +37,7 @@ modifyExistingItem = function ( itemName ) { getCurrentJson( mw.config.get( 'wgArticleId' ), function ( res ) { var done = false; - $.each( res.content.items, function ( index ) { + $.each( res.content.columns[ 0 ].items, function ( index ) { if ( this.title === itemName ) { done = true; modifyItem( { @@ -71,15 +71,15 @@ } itemToAdd.title = curUserTitle.getPrefixedText(); - for ( i = 0; i < res.content.items.length; i++ ) { + for ( i = 0; i < res.content.columns[ 0 ].items.length; i++ ) { // TODO: Title normalization maybe? - if ( res.content.items[ i ].title === itemToAdd.title ) { + if ( res.content.columns[ 0 ].items[ i ].title === itemToAdd.title ) { alert( mw.msg( 'collaborationkit-list-alreadyadded' ) ); return; } } - index = res.content.items.length; - res.content.items[ index ] = itemToAdd; + index = res.content.columns[ 0 ].items.length; + res.content.columns[ 0 ].items[ index ] = itemToAdd; res.summary = mw.msg( 'collaborationkit-list-add-self-summary', itemToAdd.title ); saveJson( res, function () { location.reload(); @@ -103,13 +103,13 @@ cur = getCurrentJson( mw.config.get( 'wgArticleId' ), function ( res ) { var newItems = []; - $.each( res.content.items, function ( index ) { + $.each( res.content.columns[ 0 ].items, function ( index ) { if ( this.title === title ) { return; } newItems[ newItems.length ] = this; } ); - res.content.items = newItems; + res.content.columns[ 0 ].items = newItems; // Interface for extension defined tags lacking... // res.tags = 'collabkit-list-delete'; // FIXME inContentLanguage??? @@ -137,7 +137,8 @@ */ getListOfTitles = function ( $elm ) { var list = []; - $elm.children( '.mw-ck-list-item' ).each( function () { + // FIXME must be changed for multilist. + $elm.children().children( '.mw-ck-list-item' ).each( function () { list[ list.length ] = $( this ).data( 'collabkit-item-title' ); } ); return list; @@ -162,11 +163,11 @@ reorderedItem = $item.data( 'collabkit-item-title' ); - if ( res.content.items.length !== originalOrder.length ) { + if ( res.content.columns[ 0 ].items.length !== originalOrder.length ) { isEditConflict = true; } else { for ( i = 0; i <
[MediaWiki-commits] [Gerrit] mediawiki...CollaborationKit[master]: Fix js list editing in the single column case
Brian Wolff has uploaded a new change for review. https://gerrit.wikimedia.org/r/320834 Change subject: Fix js list editing in the single column case .. Fix js list editing in the single column case Change-Id: If5da95c161123f118cae86fb7ac640232a142044 --- M includes/content/CollaborationListContent.php M modules/ext.CollaborationKit.list.edit.js 2 files changed, 23 insertions(+), 19 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit refs/changes/34/320834/1 diff --git a/includes/content/CollaborationListContent.php b/includes/content/CollaborationListContent.php index f668ed8..46ba902 100644 --- a/includes/content/CollaborationListContent.php +++ b/includes/content/CollaborationListContent.php @@ -912,10 +912,7 @@ && $title->userCan( 'edit', $user, 'quick' ) ) { $output->addJsConfigVars( 'wgEnableCollaborationKitListEdit', true ); - /* - Disabling until JavaScript module is updated. $output->addModules( 'ext.CollaborationKit.list.edit' ); - */ $output->preventClickjacking(); } } diff --git a/modules/ext.CollaborationKit.list.edit.js b/modules/ext.CollaborationKit.list.edit.js index 6012bbd..8c83a08 100644 --- a/modules/ext.CollaborationKit.list.edit.js +++ b/modules/ext.CollaborationKit.list.edit.js @@ -37,7 +37,7 @@ modifyExistingItem = function ( itemName ) { getCurrentJson( mw.config.get( 'wgArticleId' ), function ( res ) { var done = false; - $.each( res.content.items, function ( index ) { + $.each( res.content.columns[ 0 ].items, function ( index ) { if ( this.title === itemName ) { done = true; modifyItem( { @@ -71,15 +71,15 @@ } itemToAdd.title = curUserTitle.getPrefixedText(); - for ( i = 0; i < res.content.items.length; i++ ) { + for ( i = 0; i < res.content.columns[ 0 ].items.length; i++ ) { // TODO: Title normalization maybe? - if ( res.content.items[ i ].title === itemToAdd.title ) { + if ( res.content.columns[ 0 ].items[ i ].title === itemToAdd.title ) { alert( mw.msg( 'collaborationkit-list-alreadyadded' ) ); return; } } - index = res.content.items.length; - res.content.items[ index ] = itemToAdd; + index = res.content.columns[ 0 ].items.length; + res.content.columns[ 0 ].items[ index ] = itemToAdd; res.summary = mw.msg( 'collaborationkit-list-add-self-summary', itemToAdd.title ); saveJson( res, function () { location.reload(); @@ -103,13 +103,13 @@ cur = getCurrentJson( mw.config.get( 'wgArticleId' ), function ( res ) { var newItems = []; - $.each( res.content.items, function ( index ) { + $.each( res.content.columns[ 0 ].items, function ( index ) { if ( this.title === title ) { return; } newItems[ newItems.length ] = this; } ); - res.content.items = newItems; + res.content.columns[ 0 ].items = newItems; // Interface for extension defined tags lacking... // res.tags = 'collabkit-list-delete'; // FIXME inContentLanguage??? @@ -137,7 +137,8 @@ */ getListOfTitles = function ( $elm ) { var list = []; - $elm.children( '.mw-ck-list-item' ).each( function () { + // FIXME must be changed for multilist. + $elm.children().children( '.mw-ck-list-item' ).each( function () { list[ list.length ] = $( this ).data( 'collabkit-item-title' ); } ); return list; @@ -162,11 +163,11 @@ reorderedItem = $item.data( 'collabkit-item-title' ); - if ( res.content.items.length !== originalOrder.length ) { + if ( res.content.columns[ 0 ].items.length !== originalOrder.length ) { isEditConflict = true;