MDL-65093 core_message: show 'OK' dialogue

This commit is contained in:
Mark Nelson 2019-07-17 14:08:51 +08:00
parent 66fffdbce5
commit 386634bab3
10 changed files with 23 additions and 8 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1545,6 +1545,7 @@ function(
[SELECTORS.ACTION_CONFIRM_REMOVE_CONTACT, generateConfirmActionHandler(removeContact)], [SELECTORS.ACTION_CONFIRM_REMOVE_CONTACT, generateConfirmActionHandler(removeContact)],
[SELECTORS.ACTION_CONFIRM_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(deleteSelectedMessages)], [SELECTORS.ACTION_CONFIRM_DELETE_SELECTED_MESSAGES, generateConfirmActionHandler(deleteSelectedMessages)],
[SELECTORS.ACTION_CONFIRM_DELETE_CONVERSATION, generateConfirmActionHandler(deleteConversation)], [SELECTORS.ACTION_CONFIRM_DELETE_CONVERSATION, generateConfirmActionHandler(deleteConversation)],
[SELECTORS.ACTION_OKAY_CONFIRM, generateConfirmActionHandler(cancelRequest)],
[SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)], [SELECTORS.ACTION_REQUEST_ADD_CONTACT, generateConfirmActionHandler(requestAddContact)],
[SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST, generateConfirmActionHandler(acceptContactRequest)], [SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST, generateConfirmActionHandler(acceptContactRequest)],
[SELECTORS.ACTION_DECLINE_CONTACT_REQUEST, generateConfirmActionHandler(declineContactRequest)], [SELECTORS.ACTION_DECLINE_CONTACT_REQUEST, generateConfirmActionHandler(declineContactRequest)],

View File

@ -25,6 +25,7 @@ define([], function() {
var SELECTORS = { var SELECTORS = {
ACTION_ACCEPT_CONTACT_REQUEST: '[data-action="accept-contact-request"]', ACTION_ACCEPT_CONTACT_REQUEST: '[data-action="accept-contact-request"]',
ACTION_CANCEL_CONFIRM: '[data-action="cancel-confirm"]', ACTION_CANCEL_CONFIRM: '[data-action="cancel-confirm"]',
ACTION_OKAY_CONFIRM: '[data-action="okay-confirm"]',
ACTION_CANCEL_EDIT_MODE: '[data-action="cancel-edit-mode"]', ACTION_CANCEL_EDIT_MODE: '[data-action="cancel-edit-mode"]',
ACTION_CONFIRM_ADD_CONTACT: '[data-action="confirm-add-contact"]', ACTION_CONFIRM_ADD_CONTACT: '[data-action="confirm-add-contact"]',
ACTION_CONFIRM_BLOCK: '[data-action="confirm-block"]', ACTION_CONFIRM_BLOCK: '[data-action="confirm-block"]',
@ -50,6 +51,7 @@ define([], function() {
CONFIRM_DIALOGUE_CANCEL_BUTTON: '[data-action="cancel-confirm"]', CONFIRM_DIALOGUE_CANCEL_BUTTON: '[data-action="cancel-confirm"]',
CONFIRM_DIALOGUE_CONTAINER: '[data-region="confirm-dialogue-container"]', CONFIRM_DIALOGUE_CONTAINER: '[data-region="confirm-dialogue-container"]',
CONFIRM_DIALOGUE_HEADER: '[data-region="dialogue-header"]', CONFIRM_DIALOGUE_HEADER: '[data-region="dialogue-header"]',
CONFIRM_DIALOGUE_OKAY_BUTTON: '[data-action="okay-confirm"]',
CONFIRM_DIALOGUE_TEXT: '[data-region="dialogue-text"]', CONFIRM_DIALOGUE_TEXT: '[data-region="dialogue-text"]',
CONTACT_REQUEST_SENT_MESSAGE_CONTAINER: '[data-region="contact-request-sent-message-container"]', CONTACT_REQUEST_SENT_MESSAGE_CONTAINER: '[data-region="contact-request-sent-message-container"]',
CONTENT_PLACEHOLDER_CONTAINER: '[data-region="content-placeholder"]', CONTENT_PLACEHOLDER_CONTAINER: '[data-region="content-placeholder"]',

View File

@ -981,6 +981,7 @@ function(
* @param {String} headerText Text to show in dialogue header. * @param {String} headerText Text to show in dialogue header.
* @param {Bool} canCancel Can this dialogue be cancelled. * @param {Bool} canCancel Can this dialogue be cancelled.
* @param {Bool} skipHeader Skip blanking out the header * @param {Bool} skipHeader Skip blanking out the header
* @param {Bool} showOk Show an 'Okay' button for a dialogue which will close it
*/ */
var showConfirmDialogue = function( var showConfirmDialogue = function(
header, header,
@ -990,13 +991,15 @@ function(
bodyText, bodyText,
headerText, headerText,
canCancel, canCancel,
skipHeader skipHeader,
showOk
) { ) {
var dialogue = getConfirmDialogueContainer(body); var dialogue = getConfirmDialogueContainer(body);
var buttons = buttonSelectors.map(function(selector) { var buttons = buttonSelectors.map(function(selector) {
return dialogue.find(selector); return dialogue.find(selector);
}); });
var cancelButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_CANCEL_BUTTON); var cancelButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_CANCEL_BUTTON);
var okayButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_OKAY_BUTTON);
var text = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_TEXT); var text = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_TEXT);
var dialogueHeader = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_HEADER); var dialogueHeader = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_HEADER);
@ -1008,6 +1011,12 @@ function(
cancelButton.addClass('hidden'); cancelButton.addClass('hidden');
} }
if (showOk) {
okayButton.removeClass('hidden');
} else {
okayButton.addClass('hidden');
}
if (headerText) { if (headerText) {
dialogueHeader.removeClass('hidden'); dialogueHeader.removeClass('hidden');
dialogueHeader.text(headerText); dialogueHeader.text(headerText);
@ -1041,6 +1050,7 @@ function(
var hideConfirmDialogue = function(header, body, footer) { var hideConfirmDialogue = function(header, body, footer) {
var dialogue = getConfirmDialogueContainer(body); var dialogue = getConfirmDialogueContainer(body);
var cancelButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_CANCEL_BUTTON); var cancelButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_CANCEL_BUTTON);
var okayButton = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_OKAY_BUTTON);
var text = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_TEXT); var text = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_TEXT);
var dialogueHeader = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_HEADER); var dialogueHeader = dialogue.find(SELECTORS.CONFIRM_DIALOGUE_HEADER);
@ -1050,6 +1060,7 @@ function(
hideConfirmDialogueContainer(header); hideConfirmDialogueContainer(header);
dialogue.find('button').addClass('hidden'); dialogue.find('button').addClass('hidden');
cancelButton.removeClass('hidden'); cancelButton.removeClass('hidden');
okayButton.removeClass('hidden');
text.text(''); text.text('');
dialogueHeader.addClass('hidden'); dialogueHeader.addClass('hidden');
dialogueHeader.text(''); dialogueHeader.text('');
@ -1072,7 +1083,7 @@ function(
if (user.canmessageevenifblocked) { if (user.canmessageevenifblocked) {
return Str.get_string('cantblockuser', 'core_message', user.fullname) return Str.get_string('cantblockuser', 'core_message', user.fullname)
.then(function(string) { .then(function(string) {
return showConfirmDialogue(header, body, footer, [], string, '', true, false); return showConfirmDialogue(header, body, footer, [], string, '', false, false, true);
}); });
} else { } else {
return Str.get_string('blockuserconfirm', 'core_message', user.fullname) return Str.get_string('blockuserconfirm', 'core_message', user.fullname)

View File

@ -80,5 +80,6 @@
<span data-region="dialogue-button-text">{{#str}} decline, core_message {{/str}}</span> <span data-region="dialogue-button-text">{{#str}} decline, core_message {{/str}}</span>
<span class="hidden" data-region="loading-icon-container">{{> core/loading }}</span> <span class="hidden" data-region="loading-icon-container">{{> core/loading }}</span>
</button> </button>
<button type="button" class="btn btn-primary btn-block" data-action="okay-confirm">{{#str}} ok, core {{/str}}</button>
<button type="button" class="btn btn-secondary btn-block" data-action="cancel-confirm">{{#str}} cancel, core {{/str}}</button> <button type="button" class="btn btn-secondary btn-block" data-action="cancel-confirm">{{#str}} cancel, core {{/str}}</button>
</div> </div>