mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-64045 message: stop favouriting null conversations
Don't show the controls to favourite a conversation until one has been created.
This commit is contained in:
parent
01acb1ea90
commit
b263491138
8 changed files with 49 additions and 23 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -298,6 +298,8 @@ function(
|
|||
totalmembercount: newState.totalMemberCount,
|
||||
imageurl: newState.imageUrl,
|
||||
isfavourite: newState.isFavourite,
|
||||
// Don't show favouriting if we don't have a conversation.
|
||||
showfavourite: newState.id !== null,
|
||||
userid: newOtherUser.id,
|
||||
showonlinestatus: newOtherUser.showonlinestatus,
|
||||
isonline: newOtherUser.isonline,
|
||||
|
@ -334,7 +336,9 @@ function(
|
|||
subname: newState.subname,
|
||||
totalmembercount: totalMemberCount,
|
||||
imageurl: newState.imageUrl,
|
||||
isfavourite: newState.isFavourite
|
||||
isfavourite: newState.isFavourite,
|
||||
// Don't show favouriting if we don't have a conversation.
|
||||
showfavourite: newState.id !== null
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -619,13 +623,23 @@ function(
|
|||
var oldIsFavourite = state.isFavourite;
|
||||
var newIsFavourite = newState.isFavourite;
|
||||
|
||||
if (oldIsFavourite == newIsFavourite) {
|
||||
if (state.id === null && newState.id === null) {
|
||||
// The conversation isn't yet created so don't change anything.
|
||||
return null;
|
||||
} else if (state.id === null && newState.id !== null) {
|
||||
// The conversation was created so we can show the add favourite button.
|
||||
return 'show-add';
|
||||
} else if (state.id !== null && newState.id === null) {
|
||||
// We're changing from a created conversation to a new conversation so hide
|
||||
// the favouriting functionality for now.
|
||||
return 'hide';
|
||||
} else if (oldIsFavourite == newIsFavourite) {
|
||||
// No change.
|
||||
return null;
|
||||
} else if (!oldIsFavourite && newIsFavourite) {
|
||||
return true;
|
||||
return 'show-remove';
|
||||
} else if (oldIsFavourite && !newIsFavourite) {
|
||||
return false;
|
||||
return 'show-add';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1224,15 +1224,27 @@ function(
|
|||
* @param {Object} footer The footer container element.
|
||||
* @param {Bool} isFavourite is this conversation a favourite.
|
||||
*/
|
||||
var renderIsFavourite = function(header, body, footer, isFavourite) {
|
||||
if (isFavourite) {
|
||||
header.find(SELECTORS.FAVOURITE_ICON_CONTAINER).removeClass('hidden');
|
||||
header.find(SELECTORS.ACTION_CONFIRM_FAVOURITE).addClass('hidden');
|
||||
header.find(SELECTORS.ACTION_CONFIRM_UNFAVOURITE).removeClass('hidden');
|
||||
} else {
|
||||
header.find(SELECTORS.FAVOURITE_ICON_CONTAINER).addClass('hidden');
|
||||
header.find(SELECTORS.ACTION_CONFIRM_FAVOURITE).removeClass('hidden');
|
||||
header.find(SELECTORS.ACTION_CONFIRM_UNFAVOURITE).addClass('hidden');
|
||||
var renderIsFavourite = function(header, body, footer, state) {
|
||||
var favouriteIcon = header.find(SELECTORS.FAVOURITE_ICON_CONTAINER);
|
||||
var addFavourite = header.find(SELECTORS.ACTION_CONFIRM_FAVOURITE);
|
||||
var removeFavourite = header.find(SELECTORS.ACTION_CONFIRM_UNFAVOURITE);
|
||||
|
||||
switch (state) {
|
||||
case 'hide':
|
||||
favouriteIcon.addClass('hidden');
|
||||
addFavourite.addClass('hidden');
|
||||
removeFavourite.addClass('hidden');
|
||||
break;
|
||||
case 'show-add':
|
||||
favouriteIcon.addClass('hidden');
|
||||
addFavourite.removeClass('hidden');
|
||||
removeFavourite.addClass('hidden');
|
||||
break;
|
||||
case 'show-remove':
|
||||
favouriteIcon.removeClass('hidden');
|
||||
addFavourite.addClass('hidden');
|
||||
removeFavourite.removeClass('hidden');
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -78,10 +78,10 @@
|
|||
<a class="dropdown-item" href="#" data-action="view-contact">
|
||||
{{#str}} info, core_message {{/str}}
|
||||
</a>
|
||||
<a class="dropdown-item {{#isfavourite}}hidden{{/isfavourite}}" href="#" data-action="confirm-favourite">
|
||||
<a class="dropdown-item {{#isfavourite}}hidden{{/isfavourite}} {{^showfavourite}}hidden{{/showfavourite}}" href="#" data-action="confirm-favourite">
|
||||
{{#str}} addtofavourites, core_message {{/str}}
|
||||
</a>
|
||||
<a class="dropdown-item {{^isfavourite}}hidden{{/isfavourite}}" href="#" data-action="confirm-unfavourite">
|
||||
<a class="dropdown-item {{^isfavourite}}hidden{{/isfavourite}} {{^showfavourite}}hidden{{/showfavourite}}" href="#" data-action="confirm-unfavourite">
|
||||
{{#str}} removefromfavourites, core_message {{/str}}
|
||||
</a>
|
||||
<a class="dropdown-item {{#isblocked}}hidden{{/isblocked}}" href="#" data-action="request-block">
|
||||
|
|
|
@ -76,10 +76,10 @@
|
|||
<a class="dropdown-item" href="#" data-action="view-group-info">
|
||||
{{#str}} groupinfo, core_message {{/str}}
|
||||
</a>
|
||||
<a class="dropdown-item {{#isfavourite}}hidden{{/isfavourite}}" href="#" data-action="confirm-favourite">
|
||||
<a class="dropdown-item {{#isfavourite}}hidden{{/isfavourite}} {{^showfavourite}}hidden{{/showfavourite}}" href="#" data-action="confirm-favourite">
|
||||
{{#str}} addtofavourites, core_message {{/str}}
|
||||
</a>
|
||||
<a class="dropdown-item {{^isfavourite}}hidden{{/isfavourite}}" href="#" data-action="confirm-unfavourite">
|
||||
<a class="dropdown-item {{^isfavourite}}hidden{{/isfavourite}} {{^showfavourite}}hidden{{/showfavourite}}" href="#" data-action="confirm-unfavourite">
|
||||
{{#str}} removefromfavourites, core_message {{/str}}
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue