http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88433
Revision: 88433
Author: jeroendedauw
Date: 2011-05-19 22:00:17 +0000 (Thu, 19 May 2011)
Log Message:
-----------
work on watchlist groups management
Modified Paths:
--------------
trunk/extensions/SemanticWatchlist/api/ApiEditWatchlistGroup.php
trunk/extensions/SemanticWatchlist/includes/SWL_Group.php
trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
Modified: trunk/extensions/SemanticWatchlist/api/ApiEditWatchlistGroup.php
===================================================================
--- trunk/extensions/SemanticWatchlist/api/ApiEditWatchlistGroup.php
2011-05-19 21:43:58 UTC (rev 88432)
+++ trunk/extensions/SemanticWatchlist/api/ApiEditWatchlistGroup.php
2011-05-19 22:00:17 UTC (rev 88433)
@@ -36,7 +36,11 @@
$params['concepts']
);
- $group->writeToDB();
+ $this->getResult()->addValue(
+ null,
+ 'success',
+ $group->writeToDB()
+ );
}
public function getAllowedParams() {
Modified: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php
===================================================================
--- trunk/extensions/SemanticWatchlist/includes/SWL_Group.php 2011-05-19
21:43:58 UTC (rev 88432)
+++ trunk/extensions/SemanticWatchlist/includes/SWL_Group.php 2011-05-19
22:00:17 UTC (rev 88433)
@@ -49,24 +49,24 @@
public function writeToDB() {
if ( is_null( $this->id ) ) {
- $this->insertIntoDB();
+ return $this->insertIntoDB();
}
else {
- $this->updateInDB();
+ return $this->updateInDB();
}
}
protected function updateInDB() {
$dbr = wfGetDB( DB_MASTER );
- $dbr->update(
+ return $dbr->update(
'swl_groups',
array(
'group_name' => $this->name,
- 'group_properties' => $this->properties,
- 'group_categories' => $this->categories,
- 'group_namespaces' => $this->namespaces,
- 'group_concepts' => $this->concepts,
+ 'group_properties' => implode( '|',
$this->properties ),
+ 'group_categories' => implode( '|',
$this->categories ),
+ 'group_namespaces' => implode( '|',
$this->namespaces ),
+ 'group_concepts' => implode( '|',
$this->concepts ),
),
array( 'group_id' => $this->id )
);
Modified:
trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
2011-05-19 21:43:58 UTC (rev 88432)
+++ trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js
2011-05-19 22:00:17 UTC (rev 88433)
@@ -31,6 +31,6 @@
},
{}
);
- }) ;
+ });
} ); })(jQuery);
\ No newline at end of file
Modified:
trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
2011-05-19 21:43:58 UTC (rev 88432)
+++ trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
2011-05-19 22:00:17 UTC (rev 88433)
@@ -51,29 +51,32 @@
break;
}
- var conditionTypeInput = $( '<select />' );
+ this.conditionTypeInput = $( '<select />' );
var conditionTypes = [ 'category', 'namespace', 'concept' ];
+ var conditionTypeGroups = [ 'categories', 'namespaces',
'concepts' ];
for ( i in conditionTypes ) {
- var optionElement = $( '<option />' ).text(
mediaWiki.msg( 'swl-group-' + conditionTypes[i] ) ).attr( 'value',
conditionTypes[i] );
+ var optionElement = $( '<option />' )
+ .text( mediaWiki.msg( 'swl-group-' +
conditionTypes[i] ) )
+ .attr( { 'value': conditionTypes[i], 'type':
conditionTypeGroups[i] } );
if ( conditionType == conditionTypes[i] ) {
optionElement.attr( 'selected', 'selected' );
}
- conditionTypeInput.append( optionElement );
+ this.conditionTypeInput.append( optionElement );
}
- var conditionNameInput = $( '<input />' ).attr( {
+ this.conditionNameInput = $( '<input />' ).attr( {
'type': 'text',
'value': conditionValue,
'size': 30
} );
var conditionTd = $( '<td />' ).html(
$( '<p />' ).text( mediaWiki.msg(
'swl-group-page-selection' ) + ' ' )
- .append( conditionTypeInput )
+ .append( this.conditionTypeInput )
.append( ' ' )
- .append( conditionNameInput )
+ .append( this.conditionNameInput )
);
table.append( $( '<tr />' ).html( conditionTd ) );
@@ -86,7 +89,18 @@
'value': mediaWiki.msg( 'swl-group-save' )
} ).click( function() {
this.disabled = true;
- self.doSave( function() { this.disabled =
false; } );
+ var button = this;
+
+ self.doSave( function( success ) {
+ if ( success ) {
+ // TODO: indicate success?
+ }
+ else {
+ alert( 'Could not update the
watchlist group.' );
+ }
+
+ button.disabled = false;
+ } );
} )
);
@@ -99,6 +113,7 @@
} ).click( function() {
if ( confirm( mediaWiki.msg(
'swl-group-confirmdelete', self.nameInput.val() ) ) ) {
this.disabled = true;
+ var button = this;
self.doDelete( function( success ) {
if ( success ) {
@@ -106,7 +121,7 @@
}
else {
alert( 'Could not
delete the watchlist group.' );
- this.disabled = false;
+ button.disabled = false;
}
} );
}
@@ -120,7 +135,8 @@
var propInput = $( '<input />' ).attr( {
'type': 'text',
'value': property,
- 'size': 30
+ 'size': 30,
+ 'class': 'swl-group-prop'
} );
var removeButton = $( '<input />' ).attr( {
@@ -135,15 +151,32 @@
return propDiv.html( propInput ).append( removeButton );
}
+ this.getProperties = function() {
+ var props = [];
+
+ this.find( '.swl-group-prop' ).each( function( index,
domElement ) {
+ props.push( $( domElement ).val() );
+ } );
+
+ return props;
+ }
+
this.doSave = function( callback ) {
+ var args = {
+ 'action': 'editswlgroup',
+ 'format': 'json',
+ 'id': this.group.id,
+ 'name': this.nameInput.val(),
+ 'properties': this.getProperties().join( '|' )
+ };
+
+ args[this.conditionTypeInput.find( 'option:selected' ).attr(
'type' )] = this.conditionNameInput.val();
+
$.getJSON(
wgScriptPath + '/api.php',
- {
- 'action': 'editswlgroup',
- 'format': 'json',
- },
+ args,
function( data ) {
- callback();
+ callback( data.success );
}
);
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs