http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88426

Revision: 88426
Author:   jeroendedauw
Date:     2011-05-19 20:27:44 +0000 (Thu, 19 May 2011)
Log Message:
-----------
work on watchlist groups management

Modified Paths:
--------------
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
    trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
    trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
    trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php       
2011-05-19 19:56:26 UTC (rev 88425)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php       
2011-05-19 20:27:44 UTC (rev 88426)
@@ -32,9 +32,11 @@
        'swl-group-remove-property' => 'Remove property',
        'swl-group-page-selection' => 'Pages in',
        'swl-group-save' => 'Save',
+       'swl-group-delete' => 'Delete',
        'swl-group-category' => 'category',
        'swl-group-namespace' => 'namespace',
        'swl-group-concept' => 'concept',
+       'swl-group-confirmdelete' => 'Are you sure you want to delete the "$1" 
watchlist group?',
 
        // Special:SemanticWatchlist
        'swl-watchlist-position' => "Showing '''$1''' of the last changes 
starting with '''#$2'''.",

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-19 
19:56:26 UTC (rev 88425)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-19 
20:27:44 UTC (rev 88426)
@@ -117,9 +117,11 @@
                'swl-group-remove-property',
                'swl-group-page-selection',
                'swl-group-save',
+               'swl-group-delete',
                'swl-group-category',
                'swl-group-namespace',
                'swl-group-concept',
+               'swl-group-confirmdelete',
        )
 );
 

Modified: 
trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php  
2011-05-19 19:56:26 UTC (rev 88425)
+++ trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php  
2011-05-19 20:27:44 UTC (rev 88426)
@@ -95,6 +95,7 @@
                        'fieldset',
                        array(
                                'id' => 'swl_group_' . $group->getId(),
+                               'groupid' => $group->getId(),
                                'class' => 'swl_group',
                                'groupname' => $group->getName(),
                                'categories' => implode( '|', 
$group->getCategories() ),

Modified: 
trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js  
2011-05-19 19:56:26 UTC (rev 88425)
+++ trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js  
2011-05-19 20:27:44 UTC (rev 88426)
@@ -23,6 +23,7 @@
                element.watchlistcondition(
                        {
                                name: element.attr( 'groupname' ),
+                               id: element.attr( 'groupid' ),
                                categories: getSplitAttrValue( element, 
'categories', '|' ),
                                namespaces: getSplitAttrValue( element, 
'namespaces', '|' ),
                                properties: getSplitAttrValue( element, 
'properties', '|' ),

Modified: 
trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js    
2011-05-19 19:56:26 UTC (rev 88425)
+++ trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js    
2011-05-19 20:27:44 UTC (rev 88426)
@@ -9,6 +9,7 @@
 (function( $ ){ $.fn.watchlistcondition = function( group, options ) {
 
        var self = this;
+       this.group = group;
        
        this.buildHtml = function() {
                this.html( $( '<legend />' ).text( group.name ) );
@@ -25,12 +26,12 @@
                        propTd.append( this.getPropertyDiv( group.properties[i] 
) );
                }
                
-               var nameInput = $( '<input />' ).attr( {
+               this.nameInput = $( '<input />' ).attr( {
                        'type': 'text',
                        'value': group.name,
                        'size': 30
                } );
-               var nameTd = $( '<td />' ).html( $( '<p />' ).text( 
mediaWiki.msg( 'swl-group-name' ) + ' ' ).append( nameInput ) );
+               var nameTd = $( '<td />' ).html( $( '<p />' ).text( 
mediaWiki.msg( 'swl-group-name' ) + ' ' ).append( this.nameInput ) );
                table.append( $( '<tr />' ).html( nameTd ).append( propTd ) );
                
                var conditionValue, conditionType;
@@ -71,6 +72,7 @@
                var conditionTd = $( '<td />' ).html( 
                        $( '<p />' ).text( mediaWiki.msg( 
'swl-group-page-selection' ) + ' ' )
                        .append( conditionTypeInput )
+                       .append( '&nbsp;' )
                        .append( conditionNameInput )
                );
                
@@ -86,7 +88,21 @@
                                this.disabled = true;
                                self.doSave( function() { this.disabled = 
false; } );
                        } )
-               );              
+               );
+               
+               this.append( '&nbsp;' );
+               
+               this.append(
+                       $( '<input />' ).attr( {
+                               'type': 'button',
+                               'value': mediaWiki.msg( 'swl-group-delete' )
+                       } ).click( function() {
+                               if ( confirm( mediaWiki.msg( 
'swl-group-confirmdelete', self.nameInput.val() ) ) ) {
+                                       this.disabled = true;
+                                       self.doDelete( function() { 
this.disabled = false; } );                                 
+                               }
+                       } )
+               );
        }
        
        this.getPropertyDiv = function( property ) {
@@ -114,18 +130,29 @@
                $.getJSON(
                        wgScriptPath + '/api.php',
                        {
-                               'action': 'semanticwatchlist',
+                               'action': 'editswlgroup',
                                'format': 'json',
-                               'images': images.join( '|' ), 
-                               'targets': targetUrl
                        },
                        function( data ) {
                                callback();
                        }
                );
-               
        }
        
+       this.doDelete = function( callback ) {
+               $.getJSON(
+                       wgScriptPath + '/api.php',
+                       {
+                               'action': 'deleteswlgroup',
+                               'format': 'json',
+                               'ids': this.group.id
+                       },
+                       function( data ) {
+                               callback();
+                       }
+               );              
+       }
+       
        this.buildHtml();
        
        return this;


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

Reply via email to