Index: trunk/extensions/EducationProgram/EducationProgram.php |
— | — | @@ -555,6 +555,9 @@ |
556 | 556 | 'ep-instructor-addittion-null', |
557 | 557 | 'ep-online-addittion-null', |
558 | 558 | 'ep-campus-addittion-null', |
| 559 | + 'ep-instructor-addittion-invalid-user', |
| 560 | + 'ep-online-addittion-invalid-user', |
| 561 | + 'ep-campus-addittion-invalid-user', |
559 | 562 | 'ep-instructor-add-close-button', |
560 | 563 | 'ep-online-add-close-button', |
561 | 564 | 'ep-campus-add-close-button', |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -627,6 +627,7 @@ |
628 | 628 | 'ep-instructor-addittion-success' => '$1 has been successfully added as {{GENDER:$1|instructor}} for course $2!', |
629 | 629 | 'ep-instructor-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|instructor}} for course $2!', |
630 | 630 | 'ep-instructor-addittion-null' => '$1 has already been added as {{GENDER:$1|instructor}} to course $2', |
| 631 | + 'ep-instructor-addittion-invalid-user' => 'There is no user with name $1, so no one has been added to course $2', |
631 | 632 | 'ep-instructor-add-close-button' => 'Close', |
632 | 633 | 'ep-instructor-add-retry' => 'Retry', |
633 | 634 | 'ep-instructor-addittion-failed' => 'Something went wrong - could not add the instructor to the course.', |
— | — | @@ -654,6 +655,7 @@ |
655 | 656 | 'ep-online-addittion-success' => '$1 has been successfully added as {{GENDER:$1|Online Ambassador}} for course $2!', |
656 | 657 | 'ep-online-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|Online Ambassador}} for course $2!', |
657 | 658 | 'ep-online-addittion-null' => '$1 has already been added as {{GENDER:$1|Online Ambassador}} to course $2', |
| 659 | + 'ep-online-addittion-invalid-user' => 'There is no user with name $1, so no one has been added to course $2', |
658 | 660 | 'ep-online-add-close-button' => 'Close', |
659 | 661 | 'ep-online-add-retry' => 'Retry', |
660 | 662 | 'ep-online-addittion-failed' => 'Something went wrong - could not add the Online Ambassador to the course.', |
— | — | @@ -681,6 +683,7 @@ |
682 | 684 | 'ep-campus-addittion-success' => '$1 has been successfully added as {{GENDER:$1|Campus Ambassador}} for course $2!', |
683 | 685 | 'ep-campus-addittion-self-success' => 'You have been successfully added as {{GENDER:$1|Campus Ambassador}} for course $2!', |
684 | 686 | 'ep-campus-addittion-null' => '$1 has already been added as {{GENDER:$1|Campus Ambassador}} to course $2', |
| 687 | + 'ep-campus-addittion-invalid-user' => 'There is no user with name $1, so no one has been added to course $2', |
685 | 688 | 'ep-campus-add-close-button' => 'Close', |
686 | 689 | 'ep-campus-add-retry' => 'Retry', |
687 | 690 | 'ep-campus-addittion-failed' => 'Something went wrong - could not add the Campus Ambassador to the course.', |
Index: trunk/extensions/EducationProgram/resources/ep.enlist.js |
— | — | @@ -108,7 +108,8 @@ |
109 | 109 | $( '.ep-add-role' ).click( function( event ) { |
110 | 110 | var $this = $( this ), |
111 | 111 | _this = this, |
112 | | - role = $this.attr( 'data-role' ); |
| 112 | + role = $this.attr( 'data-role' ), |
| 113 | + isCompletionEnter = false; |
113 | 114 | |
114 | 115 | this.courseId = $this.attr( 'data-courseid' ); |
115 | 116 | this.courseName = $this.attr( 'data-coursename' ); |
— | — | @@ -137,8 +138,7 @@ |
138 | 139 | |
139 | 140 | this.doAdd = function() { |
140 | 141 | var $add = $( '#ep-' + role + '-add-button' ), |
141 | | - $cancel = $( '#ep-' + role + '-add-cancel-button' ), |
142 | | - isCompletionEnter = false; |
| 142 | + $cancel = $( '#ep-' + role + '-add-cancel-button' ); |
143 | 143 | |
144 | 144 | $add.button( 'option', 'disabled', true ); |
145 | 145 | $add.button( 'option', 'label', ep.msg( 'ep-' + role + '-adding' ) ); |
— | — | @@ -180,11 +180,16 @@ |
181 | 181 | $ul.append( $( '<li>' ).text( _this.getName() ) ); |
182 | 182 | } |
183 | 183 | } ).fail( function( data ) { |
184 | | - // TODO: implement nicer handling for fails caused by invalid user name |
185 | | - |
186 | 184 | $add.button( 'option', 'disabled', false ); |
187 | 185 | $add.button( 'option', 'label', ep.msg( 'ep-' + role + '-add-retry' ) ); |
188 | | - alert( ep.msg( 'ep-' + role + '-addittion-failed' ) ); |
| 186 | + |
| 187 | + var msgKey = data.error ? 'ep-' + role + '-addittion-' + data.error.code : 'ep-' + role + '-addittion-failed'; |
| 188 | + |
| 189 | + alert( ep.msg( |
| 190 | + msgKey, |
| 191 | + _this.getName(), |
| 192 | + _this.courseName |
| 193 | + ) ); |
189 | 194 | } ); |
190 | 195 | }; |
191 | 196 | |