r66190 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r66189‎ | r66190 | r66191 >
Date:12:25, 11 May 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Added delete button to story review
Modified paths:
  • /trunk/extensions/Storyboard/Storyboard.i18n.php (modified) (history)
  • /trunk/extensions/Storyboard/Storyboard.php (modified) (history)
  • /trunk/extensions/Storyboard/api/ApiStoryReview.php (modified) (history)
  • /trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js (modified) (history)
  • /trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php (modified) (history)
  • /trunk/extensions/Storyboard/storyboard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Storyboard/jquery/jquery.ajaxscroll.js
@@ -133,7 +133,7 @@
134134 }
135135
136136 function vEnd() {
137 - if ( ele.scrollTop > 0 && ele.scrollHeight - ele.scrollTop < opt.eBound ) {
 137+ if ( ele.scrollTop > 0 && ele.scrollHeight - ele.scrollTop < opt.eBound && opt.loaded ) {
138138 batch( $sp, opt );
139139 return 1;
140140 }
Index: trunk/extensions/Storyboard/Storyboard.i18n.php
@@ -98,6 +98,8 @@
9999 'storyboard-imagedeleted' => 'Image deleted',
100100 'storyboard-showimage' => 'Show image',
101101 'storyboard-hideimage' => 'Hide image',
 102+ 'storyboard-deletestory' => 'Remove',
 103+ 'storyboard-storydeletionconfirm' => 'Are you sure you want to permanently delete this story?'
102104 );
103105
104106 /** Message documentation (Message documentation)
Index: trunk/extensions/Storyboard/specials/StoryReview/StoryReview_body.php
@@ -40,7 +40,8 @@
4141 }
4242
4343 private function addOutput() {
44 - global $wgOut, $wgRequest, $wgJsMimeType, $wgContLanguageCode, $egStoryboardScriptPath;
 44+ global $wgOut, $wgRequest, $wgJsMimeType, $wgContLanguageCode, $wgUser;
 45+ global $egStoryboardScriptPath;
4546
4647 efStoryboardAddJSLocalisation();
4748 $wgOut->addStyle( $egStoryboardScriptPath . '/storyboard.css' );
@@ -58,6 +59,8 @@
5960 $language = $wgRequest->getText( 'language', false );
6061 if ( !$language ) $language = $wgContLanguageCode;
6162
 63+ $canDelete = $wgUser->isAllowed( 'delete' ) ? 'true' : 'false';
 64+
6265 $wgOut->addHTML( <<<EOT
6366 <div id="storyreview-tabs">
6467 <ul>
@@ -72,6 +75,7 @@
7376
7477 <script type="$wgJsMimeType">
7578 var storyboardLanguage = "$language";
 79+ var storyboardCanDelete = $canDelete;
7680
7781 jQuery( function() {
7882 jQuery( "#storyreview-tabs" ).tabs();
Index: trunk/extensions/Storyboard/storyboard.js
@@ -136,6 +136,7 @@
137137 /**
138138 * Loads new stories into the board by making a getJSON request to the QueryStories API module.
139139 *
 140+ * @param ajaxscrollObj
140141 * @param $storyboard
141142 */
142143 function stbUpdateReviewBoard( ajaxscrollObj, $storyboard ) {
@@ -157,7 +158,7 @@
158159 requestArgs,
159160 function( data ) {
160161 if ( data.query ) {
161 - stbAddStories( ajaxscrollObj, $storyboard, data.query );
 162+ stbAddStories( ajaxscrollObj, $storyboard, data );
162163 } else {
163164 alert( stbMsgExt( 'storyboard-anerroroccured', [data.error.info] ) );
164165 }
@@ -168,15 +169,16 @@
169170 /**
170171 * Adds a list of stories to the board.
171172 *
 173+ * @param ajaxscrollObj
172174 * @param $storyboard
173 - * @param query
 175+ * @param data
174176 */
175 -function stbAddStories( ajaxscrollObj, $storyboard, query ) {
 177+function stbAddStories( ajaxscrollObj, $storyboard, data ) {
176178 // Remove the empty boxes.
177179 $storyboard.html( '' );
178180
179 - for ( var i in query.stories ) {
180 - var story = query.stories[i];
 181+ for ( var i in data.query.stories ) {
 182+ var story = data.query.stories[i];
181183 var $storyBody = jQuery( "<div />" ).addClass( "storyboard-box" ).attr( "id", "story_" + story.id );
182184
183185 var $header = jQuery( "<div />" ).addClass( "story-header" ).appendTo( $storyBody );
@@ -243,9 +245,19 @@
244246 }
245247
246248 controlDiv.append( '&nbsp;&nbsp;&nbsp;' );
247 - controlDiv.append( jQuery( "<button />" ).text( stbMsg( "edit" ) )
248 - .attr( "onclick", "window.location='" + story.modifyurl + "'" ) );
 249+ controlDiv.append( jQuery( "<button />" )
 250+ .text( stbMsg( "edit" ) )
 251+ .attr( "onclick", "window.location='" + story.modifyurl + "'" )
 252+ );
249253
 254+ if ( window.storyboardCanDelete ) {
 255+ controlDiv.append( '&nbsp;&nbsp;&nbsp;' );
 256+ controlDiv.append( jQuery( "<button />" )
 257+ .text( stbMsg( "storyboard-deletestory" ) )
 258+ .attr( "onclick", "stbDeleteStory( this, " + story.id + " )" )
 259+ );
 260+ }
 261+
250262 if ( story.imageurl ) {
251263 controlDiv.append( '&nbsp;&nbsp;&nbsp;' );
252264
@@ -303,7 +315,7 @@
304316 function( data ) {
305317 if ( data.storyreview ) {
306318 switch( data.storyreview.action ) {
307 - case 'publish' : case 'unpublish' : case 'hide' :
 319+ case 'publish' : case 'unpublish' : case 'hide' : case 'delete' :
308320 sender.innerHTML = stbMsg( 'storyboard-done' );
309321 jQuery( '#story_' + data.storyreview.id ).slideUp( 'slow', function () {
310322 jQuery( this ).remove();
@@ -357,7 +369,7 @@
358370 }
359371
360372 /**
361 - * Asks the user to confirm the deletion of an image, and if confirmed, calls stbDoStoryAction with action=delete.
 373+ * Asks the user to confirm the deletion of an image, and if confirmed, calls stbDoStoryAction with action=deleteimage.
362374 *
363375 * @param sender The UI element invocing the action, typically a button.
364376 * @param storyid Id identifying the story.
@@ -370,4 +382,20 @@
371383 stbDoStoryAction( sender, storyid, 'deleteimage' );
372384 }
373385 return confirmed;
 386+}
 387+
 388+/**
 389+ * Asks the user to confirm the deletion of a story, and if confirmed, calls stbDoStoryAction with action=delete.
 390+ *
 391+ * @param sender The UI element invocing the action, typically a button.
 392+ * @param storyid Id identifying the story.
 393+ *
 394+ * @return Boolean indicating whether the deletion was confirmed.
 395+ */
 396+function stbDeleteStory( sender, storyid ) {
 397+ var confirmed = confirm( stbMsg( 'storyboard-storydeletionconfirm' ) );
 398+ if ( confirmed ) {
 399+ stbDoStoryAction( sender, storyid, 'delete' );
 400+ }
 401+ return confirmed;
374402 }
\ No newline at end of file
Index: trunk/extensions/Storyboard/api/ApiStoryReview.php
@@ -52,10 +52,15 @@
5353 if ( !isset( $params['storyid'] ) ) {
5454 $this->dieUsageMsg( array( 'missingparam', 'storyid' ) );
5555 }
 56+
5657 if ( !isset( $params['storyaction'] ) ) {
5758 $this->dieUsageMsg( array( 'missingparam', 'storyaction' ) );
5859 }
5960
 61+ if ( $params['storyaction'] == 'delete' && !$wgUser->isAllowed( 'delete' ) ) {
 62+ $this->dieUsageMsg( array( 'badaccess-groups' ) );
 63+ }
 64+
6065 $dbw = wfGetDB( DB_MASTER );
6166
6267 if ( $params['storyaction'] == 'delete' ) {
Index: trunk/extensions/Storyboard/Storyboard.php
@@ -155,6 +155,8 @@
156156 'storyboard-publish',
157157 'storyboard-hide',
158158 'storyboard-deleteimage',
 159+ 'storyboard-deletestory',
 160+ 'storyboard-storydeletionconfirm'
159161 );
160162
161163 $data = array();

Status & tagging log