Просмотр исходного кода

group admin area, new states

master
Daniel 2 лет назад
Родитель
Сommit
546f193561
10 измененных файлов: 203 добавлений и 30 удалений
  1. +5
    -1
      src/client/app/js/app/core/Dict.js
  2. +23
    -17
      src/client/app/js/app/gui/ActionButton.js
  3. +32
    -8
      src/client/app/js/app/state/GroupMemberManagementMember.js
  4. +15
    -0
      src/client/app/tmpl/group-detail.html
  5. +2
    -3
      src/client/app/tmpl/group-member-management-member-body.html
  6. +1
    -1
      src/client/app/tmpl/gui-actionbutton.html
  7. +48
    -0
      src/server/server/control/TB_Server_Control_Team.php
  8. +32
    -0
      src/server/server/core/TB_Server_Core_Notification.php
  9. +6
    -0
      src/server/shared/ent/teamdata/TB_Shared_Ent_TeamData_Appointment.php
  10. +39
    -0
      src/server/shared/ent/teamdata/TB_Shared_Ent_TeamData_Profile.php

+ 5
- 1
src/client/app/js/app/core/Dict.js Просмотреть файл

@@ -547,7 +547,11 @@ app.core.Dict = {
"GROUP_MANAGEMENT_MEMBERS_ACTIVE" : "Aktiv",
"GROUP_MANAGEMENT_MEMBERS_INACTIVE" : "Inaktiv",
"GROUP_MANAGEMENT_MEMBERS_NOT_APPROVED" : "Unbestätigt",
"GROUP_MANAGEMENT_MEMBERS_CHANGE_STATUS" : "Gruppenstatus ändern"
"GROUP_MANAGEMENT_MEMBERS_CHANGE_STATUS" : "Gruppenstatus ändern",
"BTN_GROUP_MANAGEMENT_MEMBERS_SAVE_STATUS" : "Status speichern",
"MEMBER_STATUS_CHANGED" : "Status erfolgreich geändert.",
"GROUP_DETAIL_NOTE_INACTIVE_OR_NOT_APPROVED" : "Du bist bereits Mitglied dieser Gruppe, deine volle Mitgliedschaft muss von einem Admin aktiviert werden. Aktuell kannst du noch keine Gruppentermine sehen oder an ihnen teilnehmen.",
"GROUP_DETAIL_STATUS" : "Dein Gruppenstatus",
},
"en" : {
}

+ 23
- 17
src/client/app/js/app/gui/ActionButton.js Просмотреть файл

@@ -148,23 +148,29 @@ app.gui.ActionButton = (function()
return;
}
switch ( stateId )
{
case 'appointment-create':
case 'appointment-edit':
case 'appointment-edit-attendee':
case 'configuration-profile-edit':
case 'group-detail-edit':
case 'group-members-edit':
case 'group-member-management':
$actionButton.hide();
break;
default:
$actionButton.css( 'right', '20px' );
$actionButton.css( 'marginRight', 0);
$actionButton.show();
}
// switch ( stateId )
// {
// case 'appointment-create':
// case 'appointment-edit':
// case 'appointment-edit-attendee':
// case 'configuration-profile-edit':
// case 'group-detail-edit':
// case 'group-members-edit':
// case 'group-member-management':
// $actionButton.hide();
// break;
//
// default:
// $actionButton.css( 'right', '20px' );
// $actionButton.css( 'marginRight', 0);
// $actionButton.show();
// }
// NOTE: Show by default - maybe there are some states when to hide action button later
$actionButton.css( 'right', '20px' );
$actionButton.css( 'marginRight', 0);
$actionButton.show();
}.bind( this ));
}
,


+ 32
- 8
src/client/app/js/app/state/GroupMemberManagementMember.js Просмотреть файл

@@ -26,10 +26,6 @@ app.state.GroupMemberManagementMember = function()
fnRenderMemberForm = function( profile )
{
console.log(profile);
//console.log(profile.getGroupData(groupId));
// console.log(group);
//console.log(profile.getGroupData(groupId).status);
$memberContainer = $content.find( '[data-id="member-container"]' ).first();
$memberContainer.html(
app.core.View.getTemplate(
@@ -198,10 +194,10 @@ app.state.GroupMemberManagementMember = function()
$content.on( 'click', '[data-id="btn-update-role"]', function()
{
var newRole = $content.find( '[data-id="select-member-role"]' ).first().val();
if ( memberToEdit.getRoleInGroup( group.getId() ) === newRole )
{
return;
}
// if ( memberToEdit.getRoleInGroup( group.getId() ) === newRole )
// {
// return;
// }
app.gui.PageLoader.show();
app.core.Rpc.call(
'Team',
@@ -223,6 +219,34 @@ app.state.GroupMemberManagementMember = function()
);
});
$content.on( 'click', '[data-id="btn-update-status"]', function()
{
var newStatus = $content.find( '[data-id="select-member-status"]' ).first().val();
// if ( memberToEdit.getGroupData( group.getId() ).status === newStatus )
// {
// return;
// }
app.gui.PageLoader.show();
app.core.Rpc.call(
'Team',
'changeMemberStatus',
{
groupId : group.getId(),
memberId : memberToEdit.getId(),
newStatus : newStatus
},
function( res )
{
app.core.View.toastSuccess( _lc( 'MEMBER_STATUS_CHANGED' ) );
if ( app.model.SessionUser.isOwnProfile( memberToEdit ) )
{
app.core.Controller.redirect( '#/group/' + group.getId() );
}
app.gui.PageLoader.hide();
}
);
});
$content.on( 'click', '[data-id="btn-update-contract"]', function()
{
var contractUnix = null;


+ 15
- 0
src/client/app/tmpl/group-detail.html Просмотреть файл

@@ -77,6 +77,21 @@
<% } %>
</div>
</div>
<div class="row">
<% var status = currentProfile.getGroupData( group.getId() ).status %>
<%= _lc( 'GROUP_DETAIL_STATUS' ) %>:
<% if ( status === 'active' ) { %>
<%= _lc( 'GROUP_MANAGEMENT_MEMBERS_ACTIVE' ) %>
<% } else if ( status === 'inactive' ) { %>
<%= _lc( 'GROUP_MANAGEMENT_MEMBERS_INACTIVE' ) %>
<% } else if ( status === 'not_approved' ) { %>
<%= _lc( 'GROUP_MANAGEMENT_MEMBERS_NOT_APPROVED' ) %>
<% } %>
<br>
<% if ( status === 'inactive' || status === 'not_approved' ) { %>
<%= _lc( 'GROUP_DETAIL_NOTE_INACTIVE_OR_NOT_APPROVED' ) %>
<% } %>
</div>
</div>
</div>
</div>

+ 2
- 3
src/client/app/tmpl/group-member-management-member-body.html Просмотреть файл

@@ -132,9 +132,8 @@
</select>
</div>
<div class="col">
<button class="btn btn-primary btn-sm"
data-id="btn-update-role">
<%= _lc( 'BTN_SAVE_NEW_ROLE' ) %>
<button class="btn btn-primary btn-sm" data-id="btn-update-status">
<%= _lc( 'BTN_GROUP_MANAGEMENT_MEMBERS_SAVE_STATUS' ) %>
</button>
</div>
<% if ( 'trainer' === p.getRoleInGroup( g.getId() ) ) { %>


+ 1
- 1
src/client/app/tmpl/gui-actionbutton.html Просмотреть файл

@@ -34,7 +34,7 @@
</a>
</li>
<li class="action-list-item">
<a href="<%= '#/group/' + ( currentUser.getGroupData()[0].team_id ) + '/membermanagement' %>">
<a href="<%= '#/group/' + adminGroups[ 0 ].getId() + '/membermanagement' %>">
<i class="fas fa-users"></i>&nbsp;&nbsp;<span><%= _lc( 'GROUP_EDIT_MEMBERS' ) %></span>
</a>
</li>


+ 48
- 0
src/server/server/control/TB_Server_Control_Team.php Просмотреть файл

@@ -237,6 +237,54 @@ class TB_Server_Control_Team {
return $resp;
}
public static function changeMemberStatus( TB_Server_Core_RequestData $params )
{
$resp = new TB_Server_Core_Response();
$teamId = $params->get( 'groupId' );
$team = TB_Shared_Ent_TeamData_Team::get( $teamId );
$newStatus = $params->get( 'newStatus' );
if (!in_array($newStatus, TB_Shared_Ent_TeamData_Profile::getValidStates())) {
throw new \Exception( 'Invalid new status: ' . $newStatus );
}
if ( is_null( $team ) )
{
throw new \Exception( 'Invalid group id for update member.' );
}
$sessionProfile = TB_Server_Core_Session::get()->getProfile();
if ( false === $sessionProfile->isAdminOfTeam( $teamId ) )
{
throw new \Exception( 'Not allowed to update member' );
}
$memberId = $params->get( 'memberId' );
$memberToUpdate = TB_Shared_Ent_TeamData_Profile::get( $params->get( 'memberId' ) );
if ( is_null( $memberToUpdate ) )
{
throw new \Exception( 'cannot find member to update with id', $memberId );
}
if ( false === $memberToUpdate->isInTeam( $teamId ) )
{
throw new \Exception( 'profile to update is not a member of current team.' );
}
if ( $memberToUpdate->isOwnerOfTeam( $teamId ) )
{
throw new \Exception( 'Trainer cannot be updated within this function' );
}
$memberToUpdate->setStatusInTeam( $teamId, $newStatus );
$memberToUpdate->save();
TB_Server_Core_Notification::notifyNewStatus( $memberToUpdate, $team, $newStatus );
return $resp;
}
public static function changeMemberContract( TB_Server_Core_RequestData $params )
{
$resp = new TB_Server_Core_Response();


+ 32
- 0
src/server/server/core/TB_Server_Core_Notification.php Просмотреть файл

@@ -262,6 +262,38 @@ class TB_Server_Core_Notification
);
}
/**
* @param TB_Shared_Ent_TeamData_Profile $profile
* @param TB_Shared_Ent_TeamData_Team $group
* @param $newStatus
* @throws Exception
*/
public static function notifyNewStatus(TB_Shared_Ent_TeamData_Profile $profile, TB_Shared_Ent_TeamData_Team $group, $newStatus )
{
$profileIds = array( $profile->id );
$statusText = "";
switch ($newStatus) {
case TB_Shared_Ent_TeamData_Profile::STATUS_ACTIVE:
$statusText = 'Aktiv';
break;
case TB_Shared_Ent_TeamData_Profile::STATUS_INACTIVE:
$statusText = 'Inaktiv';
break;
case TB_Shared_Ent_TeamData_Profile::STATUS_NOT_APPROVED:
$statusText = 'Unbestätigt';
break;
}
$msg = 'Deine Status im Team ' . $group->display_name . ' wurde auf ' . $statusText. ' gesetzt.';
TB_Server_Core_Notification::sendToProfiles(
'Neuer Status',
$msg,
$profileIds,
TB_Server_Core_Notification::createAdditionalData( '#/group/members' . $group->id, true )
);
}
/**
* @param TB_Shared_Ent_TeamData_Profile $profile
* @param TB_Shared_Ent_TeamData_Team $group


+ 6
- 0
src/server/shared/ent/teamdata/TB_Shared_Ent_TeamData_Appointment.php Просмотреть файл

@@ -381,6 +381,12 @@ class TB_Shared_Ent_TeamData_Appointment extends Francis_Db_Row
}
}
// Check if user is not approved in group yet
$profileTeamData = $profile->getTeamsData($this->team_id);
if ($profileTeamData['status'] === TB_Shared_Ent_TeamData_Profile::STATUS_NOT_APPROVED) {
$isVisible = false;
}
return $isVisible;
}


+ 39
- 0
src/server/shared/ent/teamdata/TB_Shared_Ent_TeamData_Profile.php Просмотреть файл

@@ -69,6 +69,15 @@ class TB_Shared_Ent_TeamData_Profile extends Francis_Db_Row {
);
}
public static function getValidStates()
{
return array(
self::STATUS_ACTIVE,
self::STATUS_INACTIVE,
self::STATUS_NOT_APPROVED
);
}
/**
* Get first profile by account id
* @param $accountId
@@ -395,6 +404,36 @@ class TB_Shared_Ent_TeamData_Profile extends Francis_Db_Row {
$this->teams_js = $profileTeamData;
}
/**
* @param $teamId
* @param $status
*/
public function setStatusInTeam($teamId, $status )
{
if ( !in_array( $status, self::getValidStates() ) )
{
throw new \Exception( "Invalid status to set: " . $status );
}
$profileTeamData = array();
if ( is_array( $this->teams_js ) )
{
// Make a copy
$profileTeamData = unserialize( serialize( $this->teams_js ) );
}
foreach( $profileTeamData as &$teamData )
{
if ( $teamId === $teamData[ 'team_id' ] )
{
$teamData[ 'status' ] = $status;
}
}
$this->teams_js = $profileTeamData;
}
/**
* @param $teamId
* @param $contract


Загрузка…
Отмена
Сохранить