r109578 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109577‎ | r109578 | r109579 >
Date:22:46, 19 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
ui work on instructor management
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/resources/ep.instructor.js (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -147,15 +147,21 @@
148148 }
149149
150150 if ( false ) { // count( $instructors ) == 1
151 - return $instList[0];
 151+ $html = $instList[0];
152152 }
153153 else {
154 - return '<ul id="ep-course-instructors"><li>' . implode( '</li><li>', $instList ) . '</li></ul>';
 154+ $html = '<ul><li>' . implode( '</li><li>', $instList ) . '</li></ul>';
155155 }
156156 }
157157 else {
158 - return wfMsgHtml( 'ep-course-no-instructors' );
 158+ $html = wfMsgHtml( 'ep-course-no-instructors' );
159159 }
 160+
 161+ return Html::rawElement(
 162+ 'div',
 163+ array( 'id' => 'ep-course-instructors' ),
 164+ $html
 165+ );
160166 }
161167
162168 /**
Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -377,6 +377,7 @@
378378 'ep-instructor-add-cancel-button',
379379 'ep-instructor-summary-input',
380380 'ep-instructor-name-input',
 381+ 'ep-course-no-instructors',
381382 ),
382383 );
383384
Index: trunk/extensions/EducationProgram/resources/ep.instructor.js
@@ -37,7 +37,14 @@
3838 $remove.remove();
3939 $cancel.button( 'option', 'label', ep.msg( 'ep-instructor-close-button' ) );
4040 $cancel.focus();
41 - $this.closest( 'li' ).remove();
 41+
 42+ $li = $this.closest( 'li' );
 43+ $ul = $li.closest( 'ul' );
 44+ $li.remove();
 45+
 46+ if ( $ul.find( 'li' ).length < 1 ) {
 47+ $ul.closest( 'div' ).text( mw.msg( 'ep-course-no-instructors' ) );
 48+ }
4249 } ).fail( function() {
4350 $remove.button( 'option', 'disabled', false );
4451 $remove.button( 'option', 'label', ep.msg( 'ep-instructor-remove-retry' ) );
@@ -101,14 +108,16 @@
102109 'type': 'text',
103110 'size': 30,
104111 'maxlength': 250,
105 - 'id': 'ep-instructor-nameinput'
 112+ 'id': 'ep-instructor-nameinput',
 113+ 'name': 'ep-instructor-nameinput'
106114 } );
107115
108116 this.summaryInput = $( '<input>' ).attr( {
109117 'type': 'text',
110118 'size': 60,
111119 'maxlength': 250,
112 - 'id': 'ep-instructor-summaryinput'
 120+ 'id': 'ep-instructor-summaryinput',
 121+ 'name': 'ep-instructor-summaryinput'
113122 } );
114123
115124 this.getName = function() {
@@ -138,7 +147,14 @@
139148 $cancel.focus();
140149
141150 // TODO: link name to user page and show control links
142 - $( '#ep-course-instructors' ).append( $( '<li>' ).text( _this.getName() ) )
 151+ $ul = $( '#ep-course-instructors' ).find( 'ul' );
 152+
 153+ if ( $ul.length < 1 ) {
 154+ $ul = $( '<ul>' );
 155+ $( '#ep-course-instructors' ).html( $ul );
 156+ }
 157+
 158+ $ul.append( $( '<li>' ).text( _this.getName() ) )
143159 } ).fail( function() {
144160 // TODO: implement nicer handling for fails caused by invalid user name
145161

Status & tagging log