Fix displaying the options in the UI only when the user has permissions

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-07-13 16:07:42 +02:00
Родитель ff2598ac04
Коммит c7a3c95962
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E166FD8976B3BAC8
3 изменённых файлов: 37 добавлений и 18 удалений

Просмотреть файл

@ -525,6 +525,10 @@ video {
overflow: hidden;
}
#app-navigation .app-navigation-entry-menu input.first-option {
margin-top: 5px;
}
#app-navigation .app-navigation-entry-menu li span {
display: inline-block;
height: 36px;

Просмотреть файл

@ -42,6 +42,7 @@
'</div>'+
'<div class="app-navigation-entry-menu">'+
'<ul class="app-navigation-entry-menu-list">'+
'{{#if canModerate}}'+
'<li>'+
'<button class="add-person-button">'+
'<span class="icon-add"></span>'+
@ -67,6 +68,13 @@
'<div class="clipboardButton icon-clippy private-room" data-clipboard-target="#shareInput-{{id}}"></div>'+
'<div class="icon-delete private-room"></div>'+
'</li>'+
'{{/if}}'+
'{{#if showShareLink}}'+
'<li>'+
'<input id="shareInput-{{id}}" class="share-link-input private-room first-option" readonly="readonly" type="text"/>'+
'<div class="clipboardButton icon-clippy private-room" data-clipboard-target="#shareInput-{{id}}"></div>'+
'</li>'+
'{{/if}}'+
'<li>'+
'<button class="leave-room-button">'+
'<span class="{{#if isDeletable}}icon-close{{else}}icon-delete{{/if}}"></span>'+
@ -82,9 +90,11 @@
'</li>'+
'{{/if}}'+
'</ul>'+
'{{#if canModerate}}'+
'<form class="oca-spreedme-add-person hidden">'+
'<input class="add-person-input" type="text" placeholder="Type name..."/>'+
'</form>'+
'{{/if}}'+
'</div>';
var RoomItenView = Marionette.View.extend({
@ -116,6 +126,15 @@
}
});
},
templateContext: function() {
var canModerate = this.model.get('participantType') === 1 || this.model.get('participantType') === 2;
return {
canModerate: canModerate,
showShareLink: !canModerate && this.model.get('type') === ROOM_TYPE_PUBLIC_CALL,
isNameEditable: canModerate && this.model.get('type') !== ROOM_TYPE_ONE_TO_ONE,
isDeletable: canModerate && (Object.keys(this.model.get('participants')).length > 2 || this.model.get('numGuests') > 0)
}
},
onRender: function() {
var roomURL, completeURL;

Просмотреть файл

@ -162,24 +162,6 @@ class RoomController extends OCSController {
$participantType = Participant::GUEST;
}
$canModerate = $participantType === Participant::MODERATOR || $participantType === Participant::OWNER;
$roomData = [
'id' => $room->getId(),
'token' => $room->getToken(),
'type' => $room->getType(),
'name' => $room->getName(),
'displayName' => $room->getName(),
'isNameEditable' => $room->getType() !== Room::ONE_TO_ONE_CALL,
'isModerator' => $participantType === Participant::MODERATOR,
'isOwner' => $participantType === Participant::OWNER,
'isDeletable' => $canModerate && (count($participantList) > 2 || !empty($participants['guests'])),
'count' => $room->getNumberOfParticipants(time() - 30),
'lastPing' => isset($participants['users'][$this->userId]['lastPing']) ? $participants['users'][$this->userId]['lastPing'] : 0,
'sessionId' => isset($participants['users'][$this->userId]['sessionId']) ? $participants['users'][$this->userId]['sessionId'] : '0',
'participants' => $participantList,
];
$activeGuests = array_filter($participants['guests'], function($data) {
return $data['lastPing'] > time() - 30;
});
@ -189,6 +171,20 @@ class RoomController extends OCSController {
$room->cleanGuestParticipants();
}
$roomData = [
'id' => $room->getId(),
'token' => $room->getToken(),
'type' => $room->getType(),
'name' => $room->getName(),
'displayName' => $room->getName(),
'participantType' => $participantType,
'count' => $room->getNumberOfParticipants(time() - 30),
'lastPing' => isset($participants['users'][$this->userId]['lastPing']) ? $participants['users'][$this->userId]['lastPing'] : 0,
'sessionId' => isset($participants['users'][$this->userId]['sessionId']) ? $participants['users'][$this->userId]['sessionId'] : '0',
'participants' => $participantList,
'numGuests' => $numActiveGuests,
];
if ($this->userId !== null) {
unset($participantList[$this->userId]);
$numOtherParticipants = count($participantList);