25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

95 satır
3.4 KiB

  1. /**
  2. * Created by Benny on 12.10.2014.
  3. */
  4. "use strict";
  5. var TB = TB || {};
  6. TB.Control = TB.Control || {};
  7. TB.Control.Profiles = {
  8. // Overview
  9. index : function( params ) {
  10. TB.GUI.showLoader();
  11. var page = new TB.Page( 'profiles' );
  12. TB.Service.request('Profile', 'getAll', {}, function (data) {
  13. TB.GUI.hideLoader();
  14. if ( data && data.profiles ) {
  15. TB.Client.updateSessionProfiles( data.profiles) ;
  16. }
  17. TB.GUI.show( page, { profile : TB.Client.profile, profiles: TB.Client.profiles, teams : TB.Client.teams } );
  18. page.$container.find( 'button[data-action="change_profile"]' ).on( "click", function() {
  19. TB.Service.request( 'Profile', 'change', { profile_id : $(this).attr( "data-profile_id" ) },
  20. function( data ) {
  21. if ( data && data.session && data.profile && data.profiles && data.teams ) {
  22. TB.Client.setSessionData( TB.Client.account, data.profile, data.session, data.profiles, data.teams );
  23. location.reload( true );
  24. }
  25. });
  26. });
  27. page.$container.find( 'button[data-action="new-team"]').on( 'click', function() {
  28. TB.Controller.do( 'Profiles', 'newteam' );
  29. });
  30. });
  31. },
  32. newteam : function( params ) {
  33. var page = new TB.Page( 'profiles_newteam' );
  34. TB.GUI.show( page, {} );
  35. page.$container.find( '#btn_cancel_add_new_team').click( function() {
  36. TB.Controller.do( 'Profiles' );
  37. });
  38. page.$container.find( '#registerteamcategory' ).easyAutocomplete({
  39. // Note:
  40. // Duplicate list
  41. data : TB.Config.General.team_categories,
  42. list: {
  43. maxNumberOfElements: 10,
  44. match: {
  45. enabled: true
  46. }
  47. }
  48. });
  49. page.$container.find( '#btn_add_new_team').click( function() {
  50. if ( !TB.GUI.performFormValidation( $( '#form_add_new_team' ) ) ) {
  51. return false;
  52. }
  53. TB.Service.request( 'Profile', 'addNewTeam', {
  54. 'team_name' : page.$container.find( '#form_add_new_team input[name="register.team_name"]' ).val(),
  55. 'team_category' : page.$container.find( '#form_add_new_team input[name="register.team_category"]' ).val()
  56. }, function( res ) {
  57. if ( res && res.new_profile_id ) {
  58. TB.Service.request( 'Profile', 'change', { profile_id : res.new_profile_id },
  59. function( data ) {
  60. if ( data && data.session && data.profile && data.profiles && data.teams ) {
  61. TB.Client.setSessionData( TB.Client.account, data.profile, data.session, data.profiles, data.teams );
  62. TB.Controller.do( 'Profiles' );
  63. location.reload( true );
  64. }
  65. });
  66. } else {
  67. TB.Ext.Alert.show( 'Fehler', 'Ein Fehler ist aufgetreten. Bitte versuche es später erneut.' );
  68. }
  69. return false;
  70. });
  71. return false;
  72. });
  73. }
  74. };