Index: trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js |
— | — | @@ -51,29 +51,32 @@ |
52 | 52 | break; |
53 | 53 | } |
54 | 54 | |
55 | | - var conditionTypeInput = $( '<select />' ); |
| 55 | + this.conditionTypeInput = $( '<select />' ); |
56 | 56 | var conditionTypes = [ 'category', 'namespace', 'concept' ]; |
| 57 | + var conditionTypeGroups = [ 'categories', 'namespaces', 'concepts' ]; |
57 | 58 | |
58 | 59 | for ( i in conditionTypes ) { |
59 | | - var optionElement = $( '<option />' ).text( mediaWiki.msg( 'swl-group-' + conditionTypes[i] ) ).attr( 'value', conditionTypes[i] ); |
| 60 | + var optionElement = $( '<option />' ) |
| 61 | + .text( mediaWiki.msg( 'swl-group-' + conditionTypes[i] ) ) |
| 62 | + .attr( { 'value': conditionTypes[i], 'type': conditionTypeGroups[i] } ); |
60 | 63 | |
61 | 64 | if ( conditionType == conditionTypes[i] ) { |
62 | 65 | optionElement.attr( 'selected', 'selected' ); |
63 | 66 | } |
64 | 67 | |
65 | | - conditionTypeInput.append( optionElement ); |
| 68 | + this.conditionTypeInput.append( optionElement ); |
66 | 69 | } |
67 | 70 | |
68 | | - var conditionNameInput = $( '<input />' ).attr( { |
| 71 | + this.conditionNameInput = $( '<input />' ).attr( { |
69 | 72 | 'type': 'text', |
70 | 73 | 'value': conditionValue, |
71 | 74 | 'size': 30 |
72 | 75 | } ); |
73 | 76 | var conditionTd = $( '<td />' ).html( |
74 | 77 | $( '<p />' ).text( mediaWiki.msg( 'swl-group-page-selection' ) + ' ' ) |
75 | | - .append( conditionTypeInput ) |
| 78 | + .append( this.conditionTypeInput ) |
76 | 79 | .append( ' ' ) |
77 | | - .append( conditionNameInput ) |
| 80 | + .append( this.conditionNameInput ) |
78 | 81 | ); |
79 | 82 | |
80 | 83 | table.append( $( '<tr />' ).html( conditionTd ) ); |
— | — | @@ -86,7 +89,18 @@ |
87 | 90 | 'value': mediaWiki.msg( 'swl-group-save' ) |
88 | 91 | } ).click( function() { |
89 | 92 | this.disabled = true; |
90 | | - self.doSave( function() { this.disabled = false; } ); |
| 93 | + var button = this; |
| 94 | + |
| 95 | + self.doSave( function( success ) { |
| 96 | + if ( success ) { |
| 97 | + // TODO: indicate success? |
| 98 | + } |
| 99 | + else { |
| 100 | + alert( 'Could not update the watchlist group.' ); |
| 101 | + } |
| 102 | + |
| 103 | + button.disabled = false; |
| 104 | + } ); |
91 | 105 | } ) |
92 | 106 | ); |
93 | 107 | |
— | — | @@ -99,6 +113,7 @@ |
100 | 114 | } ).click( function() { |
101 | 115 | if ( confirm( mediaWiki.msg( 'swl-group-confirmdelete', self.nameInput.val() ) ) ) { |
102 | 116 | this.disabled = true; |
| 117 | + var button = this; |
103 | 118 | |
104 | 119 | self.doDelete( function( success ) { |
105 | 120 | if ( success ) { |
— | — | @@ -106,7 +121,7 @@ |
107 | 122 | } |
108 | 123 | else { |
109 | 124 | alert( 'Could not delete the watchlist group.' ); |
110 | | - this.disabled = false; |
| 125 | + button.disabled = false; |
111 | 126 | } |
112 | 127 | } ); |
113 | 128 | } |
— | — | @@ -120,7 +135,8 @@ |
121 | 136 | var propInput = $( '<input />' ).attr( { |
122 | 137 | 'type': 'text', |
123 | 138 | 'value': property, |
124 | | - 'size': 30 |
| 139 | + 'size': 30, |
| 140 | + 'class': 'swl-group-prop' |
125 | 141 | } ); |
126 | 142 | |
127 | 143 | var removeButton = $( '<input />' ).attr( { |
— | — | @@ -135,15 +151,32 @@ |
136 | 152 | return propDiv.html( propInput ).append( removeButton ); |
137 | 153 | } |
138 | 154 | |
| 155 | + this.getProperties = function() { |
| 156 | + var props = []; |
| 157 | + |
| 158 | + this.find( '.swl-group-prop' ).each( function( index, domElement ) { |
| 159 | + props.push( $( domElement ).val() ); |
| 160 | + } ); |
| 161 | + |
| 162 | + return props; |
| 163 | + } |
| 164 | + |
139 | 165 | this.doSave = function( callback ) { |
| 166 | + var args = { |
| 167 | + 'action': 'editswlgroup', |
| 168 | + 'format': 'json', |
| 169 | + 'id': this.group.id, |
| 170 | + 'name': this.nameInput.val(), |
| 171 | + 'properties': this.getProperties().join( '|' ) |
| 172 | + }; |
| 173 | + |
| 174 | + args[this.conditionTypeInput.find( 'option:selected' ).attr( 'type' )] = this.conditionNameInput.val(); |
| 175 | + |
140 | 176 | $.getJSON( |
141 | 177 | wgScriptPath + '/api.php', |
142 | | - { |
143 | | - 'action': 'editswlgroup', |
144 | | - 'format': 'json', |
145 | | - }, |
| 178 | + args, |
146 | 179 | function( data ) { |
147 | | - callback(); |
| 180 | + callback( data.success ); |
148 | 181 | } |
149 | 182 | ); |
150 | 183 | } |
Index: trunk/extensions/SemanticWatchlist/specials/ext.swl.watchlistconditions.js |
— | — | @@ -31,6 +31,6 @@ |
32 | 32 | }, |
33 | 33 | {} |
34 | 34 | ); |
35 | | - }) ; |
| 35 | + }); |
36 | 36 | |
37 | 37 | } ); })(jQuery); |
\ No newline at end of file |
Index: trunk/extensions/SemanticWatchlist/includes/SWL_Group.php |
— | — | @@ -49,24 +49,24 @@ |
50 | 50 | |
51 | 51 | public function writeToDB() { |
52 | 52 | if ( is_null( $this->id ) ) { |
53 | | - $this->insertIntoDB(); |
| 53 | + return $this->insertIntoDB(); |
54 | 54 | } |
55 | 55 | else { |
56 | | - $this->updateInDB(); |
| 56 | + return $this->updateInDB(); |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | 60 | protected function updateInDB() { |
61 | 61 | $dbr = wfGetDB( DB_MASTER ); |
62 | 62 | |
63 | | - $dbr->update( |
| 63 | + return $dbr->update( |
64 | 64 | 'swl_groups', |
65 | 65 | array( |
66 | 66 | 'group_name' => $this->name, |
67 | | - 'group_properties' => $this->properties, |
68 | | - 'group_categories' => $this->categories, |
69 | | - 'group_namespaces' => $this->namespaces, |
70 | | - 'group_concepts' => $this->concepts, |
| 67 | + 'group_properties' => implode( '|', $this->properties ), |
| 68 | + 'group_categories' => implode( '|', $this->categories ), |
| 69 | + 'group_namespaces' => implode( '|', $this->namespaces ), |
| 70 | + 'group_concepts' => implode( '|', $this->concepts ), |
71 | 71 | ), |
72 | 72 | array( 'group_id' => $this->id ) |
73 | 73 | ); |
Index: trunk/extensions/SemanticWatchlist/api/ApiEditWatchlistGroup.php |
— | — | @@ -36,7 +36,11 @@ |
37 | 37 | $params['concepts'] |
38 | 38 | ); |
39 | 39 | |
40 | | - $group->writeToDB(); |
| 40 | + $this->getResult()->addValue( |
| 41 | + null, |
| 42 | + 'success', |
| 43 | + $group->writeToDB() |
| 44 | + ); |
41 | 45 | } |
42 | 46 | |
43 | 47 | public function getAllowedParams() { |