Index: trunk/extensions/Translate/specials/SpecialAggregateGroups.php |
— | — | @@ -84,7 +84,6 @@ |
85 | 85 | $aggregategroups = ApiAggregateGroups::getAggregateGroups( ); |
86 | 86 | $res = $this->loadPagesFromDB(); |
87 | 87 | $pages = $this->buildPageArray( $res ); |
88 | | - $pages = $this->filterUnGroupedPages( $pages, $aggregategroups ); |
89 | 88 | foreach ( $aggregategroups as $id => $group ) { |
90 | 89 | $wgOut->addHtml( "<div id='tpt-aggregate-group'>" ); |
91 | 90 | |
— | — | @@ -112,7 +111,7 @@ |
113 | 112 | } |
114 | 113 | $wgOut->addHtml( "</ol>" ); |
115 | 114 | |
116 | | - $this->groupSelector ( $pages, $id ); |
| 115 | + $this->groupSelector ( $pages, $group ); |
117 | 116 | $addButton = Html::element( 'input', |
118 | 117 | array( 'type' => 'button', |
119 | 118 | 'value' => wfMsg( 'tpt-aggregategroup-add' ), |
— | — | @@ -148,7 +147,7 @@ |
149 | 148 | $wgOut->addHtml( $newGroupDiv ); |
150 | 149 | } |
151 | 150 | |
152 | | - protected function groupSelector( $pages, $id ) { |
| 151 | + protected function groupSelector( $pages, $group ) { |
153 | 152 | global $wgOut; |
154 | 153 | $out = $wgOut; |
155 | 154 | if ( !count( $pages ) ) { |
— | — | @@ -156,16 +155,19 @@ |
157 | 156 | return; |
158 | 157 | } |
159 | 158 | $options = "\n"; |
| 159 | + $subgroups = $group['subgroups']; |
160 | 160 | if ( count( $pages ) ) { |
161 | 161 | foreach ( $pages as $pageId => $page ) { |
162 | 162 | $title = $page['title']->getText(); |
163 | 163 | $pageid = TranslatablePage::getMessageGroupIdFromTitle( $page['title'] ) ; |
164 | | - $options .= Xml::option( $title , $pageid, false , array( 'id' => $pageid ) ) . "\n"; |
| 164 | + if ( ! isset( $subgroups[$pageid] ) ) { |
| 165 | + $options .= Xml::option( $title , $pageid, false , array( 'id' => $pageid ) ) . "\n"; |
| 166 | + } |
165 | 167 | } |
166 | 168 | } |
167 | 169 | $selector = Xml::tags( 'select', |
168 | 170 | array( |
169 | | - 'id' => 'tp-aggregate-groups-select-' . $id, |
| 171 | + 'id' => 'tp-aggregate-groups-select-' . $group['id'], |
170 | 172 | 'name' => 'group', |
171 | 173 | 'class' => 'tp-aggregate-group-chooser', |
172 | 174 | ), |
— | — | @@ -174,17 +176,4 @@ |
175 | 177 | $out->addHtml( $selector ); |
176 | 178 | } |
177 | 179 | |
178 | | - protected function filterUnGroupedPages( $pages, $aggregategroups ) { |
179 | | - foreach ( $aggregategroups as $aggregategroup ) { |
180 | | - $subgroups = $aggregategroup['subgroups']; |
181 | | - foreach ( $pages as $id => $page ) { |
182 | | - $pageid = TranslatablePage::getMessageGroupIdFromTitle( $page['title'] ) ; |
183 | | - if ( isset( $subgroups[$pageid] ) ) { |
184 | | - unset( $pages[$id] ); |
185 | | - } |
186 | | - } |
187 | | - } |
188 | | - return $pages; |
189 | | - } |
190 | | - |
191 | 180 | } |
Index: trunk/extensions/Translate/resources/ext.translate.special.aggregategroups.js |
— | — | @@ -4,17 +4,20 @@ |
5 | 5 | |
6 | 6 | function associate( event ){ |
7 | 7 | var aggregategroup = event.target.id; |
8 | | - var selected = $( '#tp-aggregate-groups-select-'+ aggregategroup + ' option:selected' ).text(); |
9 | | - var group = $( '#tp-aggregate-groups-select-'+ aggregategroup + ' option:selected' ).val(); |
| 8 | + var $selected = $( '#tp-aggregate-groups-select-'+ aggregategroup + ' option:selected' ); |
| 9 | + var groupName = $selected.text(); |
| 10 | + var groupId = $selected.val(); |
10 | 11 | var $select= $( 'select.tp-aggregate-group-chooser' ) ; |
11 | 12 | |
12 | 13 | var successFunction = function( data, textStatus ) { |
13 | 14 | if ( data.error ) { |
14 | 15 | alert( data.error.info ); |
15 | 16 | }else{ |
16 | | - $( '#tp-aggregate-groups-ol-'+ aggregategroup ).append( '<li><a id='+group+' href='+selected+'>'+selected+'</a><span class=\'tp-aggregate-remove-button\' id='+group+'></span></li>' ); |
17 | | - $( 'option#'+ group ).remove(); |
18 | | - $( 'span#'+group ).on ( "click", function(event){ dissociate(event); } ); |
| 17 | + $( '#tp-aggregate-groups-ol-'+ aggregategroup ).append( '<li><a id='+groupId+' href='+groupName+'>'+groupName+'</a><span class=\'tp-aggregate-remove-button\' id='+groupId+'></span></li>' ); |
| 18 | + // remove this group from the select. |
| 19 | + $selected.remove(); |
| 20 | + // bind click event to the dissociate(remove) button. |
| 21 | + $( 'span#'+groupId ).on ( "click", function(event){ dissociate(event); } ); |
19 | 22 | } |
20 | 23 | }; |
21 | 24 | |
— | — | @@ -22,7 +25,7 @@ |
23 | 26 | action: "aggregategroups", |
24 | 27 | 'do' : 'associate', |
25 | 28 | token: $( "#token" ).val(), |
26 | | - group: group, |
| 29 | + group: groupId, |
27 | 30 | aggregategroup: aggregategroup, |
28 | 31 | format: "json" |
29 | 32 | }; |
— | — | @@ -30,19 +33,16 @@ |
31 | 34 | } |
32 | 35 | |
33 | 36 | function dissociate(event){ |
34 | | - var group = event.target.id; |
35 | | - var selected = $( 'a#'+group ).text(); |
36 | | - var $select= $( 'select.tp-aggregate-group-chooser' ) ; |
37 | | - var aggregategroup = $( 'a#'+group ).closest( 'div' ).find( 'h2' ).attr( 'id' ); |
38 | | - |
| 37 | + var groupId = event.target.id; |
| 38 | + var groupName = $( 'a#'+groupId ).text(); |
| 39 | + var aggregategroup = $( 'a#'+groupId ).closest( 'div' ).find( 'h2' ).attr( 'id' ); |
| 40 | + var $select = $( '#tp-aggregate-groups-select-'+ aggregategroup ); |
39 | 41 | var successFunction = function( data, textStatus ) { |
40 | 42 | if ( data.error ) { |
41 | 43 | alert( data.error.info ); |
42 | 44 | }else{ |
43 | | - $select.each( function(){ |
44 | | - $( this ).append( '<option value="'+group+'">'+selected+'</option>' ); |
45 | | - } ); |
46 | | - $( 'span#'+ group ).closest( 'li' ).remove(); |
| 45 | + $select .append( '<option value="'+groupId+'">'+groupName+'</option>' ); |
| 46 | + $( 'span#'+ groupId ).closest( 'li' ).remove(); |
47 | 47 | } |
48 | 48 | }; |
49 | 49 | |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | action: "aggregategroups", |
52 | 52 | 'do' : 'dissociate', |
53 | 53 | token: $( "#token" ).val(), |
54 | | - group: group, |
| 54 | + group: groupId, |
55 | 55 | aggregategroup: aggregategroup, |
56 | 56 | format: "json" |
57 | 57 | }; |
— | — | @@ -59,19 +59,10 @@ |
60 | 60 | |
61 | 61 | function removeGroup(event){ |
62 | 62 | var aggregategroup = event.target.id; |
63 | | - var $select= $( 'select.tp-aggregate-group-chooser') ; |
64 | | - |
65 | 63 | var successFunction = function( data, textStatus ) { |
66 | 64 | if ( data.error ) { |
67 | 65 | alert( data.error.info ); |
68 | 66 | }else{ |
69 | | - $( 'span#'+ aggregategroup ).parent().parent().find('li a').each(function(){ |
70 | | - $groupId = $( this ).attr('id'); |
71 | | - $groupName = $( this ).text(); |
72 | | - $select.each( function(){ |
73 | | - $ (this ).append('<option value="'+$groupId+'">'+$groupName+'</option>'); |
74 | | - } ); |
75 | | - }); |
76 | 67 | $( 'span#'+ aggregategroup ).closest('div#tpt-aggregate-group').remove(); |
77 | 68 | } |
78 | 69 | }; |