Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 33... Línea 33...
33
    'core/str',
33
    'core/str',
34
    'core/templates',
34
    'core/templates',
35
    'core/user_date',
35
    'core/user_date',
36
    'core_message/message_drawer_view_conversation_constants',
36
    'core_message/message_drawer_view_conversation_constants',
37
    'core/aria',
37
    'core/aria',
-
 
38
    'core/truncate',
38
],
39
],
39
function(
40
function(
40
    $,
41
    $,
41
    Notification,
42
    Notification,
42
    Str,
43
    Str,
43
    Templates,
44
    Templates,
44
    UserDate,
45
    UserDate,
45
    Constants,
46
    Constants,
46
    Aria
47
    Aria,
-
 
48
    Truncate,
47
) {
49
) {
48
    var SELECTORS = Constants.SELECTORS;
50
    var SELECTORS = Constants.SELECTORS;
49
    var TEMPLATES = Constants.TEMPLATES;
51
    var TEMPLATES = Constants.TEMPLATES;
50
    var CONVERSATION_TYPES = Constants.CONVERSATION_TYPES;
52
    var CONVERSATION_TYPES = Constants.CONVERSATION_TYPES;
Línea 1151... Línea 1153...
1151
     * @param {Object} user User to block.
1153
     * @param {Object} user User to block.
1152
     * @return {Object} jQuery promise
1154
     * @return {Object} jQuery promise
1153
     */
1155
     */
1154
    var renderConfirmBlockUser = function(header, body, footer, user) {
1156
    var renderConfirmBlockUser = function(header, body, footer, user) {
1155
        if (user) {
1157
        if (user) {
-
 
1158
            const username = truncateUsername(user.fullname);
1156
            if (user.canmessageevenifblocked) {
1159
            if (user.canmessageevenifblocked) {
1157
                return Str.get_string('cantblockuser', 'core_message', user.fullname)
1160
                return Str.get_string('cantblockuser', 'core_message', username)
1158
                    .then(function(string) {
1161
                    .then(function(string) {
1159
                        return showConfirmDialogue(header, body, footer, [], string, '', false, false, true);
1162
                        return showConfirmDialogue(header, body, footer, [], string, '', false, false, true);
1160
                    });
1163
                    });
1161
            } else {
1164
            } else {
1162
                return Str.get_string('blockuserconfirm', 'core_message', user.fullname)
1165
                return Str.get_string('blockuserconfirm', 'core_message', username)
1163
                    .then(function(string) {
1166
                    .then(function(string) {
1164
                        return showConfirmDialogue(header, body, footer, [SELECTORS.ACTION_CONFIRM_BLOCK], string, '', true, false);
1167
                        return showConfirmDialogue(header, body, footer, [SELECTORS.ACTION_CONFIRM_BLOCK], string, '', true, false);
1165
                    });
1168
                    });
1166
            }
1169
            }
1167
        } else {
1170
        } else {
Línea 1178... Línea 1181...
1178
     * @param {Object} user User to unblock.
1181
     * @param {Object} user User to unblock.
1179
     * @return {Object} jQuery promise
1182
     * @return {Object} jQuery promise
1180
     */
1183
     */
1181
    var renderConfirmUnblockUser = function(header, body, footer, user) {
1184
    var renderConfirmUnblockUser = function(header, body, footer, user) {
1182
        if (user) {
1185
        if (user) {
1183
            return Str.get_string('unblockuserconfirm', 'core_message', user.fullname)
1186
            return Str.get_string('unblockuserconfirm', 'core_message', truncateUsername(user.fullname))
1184
                .then(function(string) {
1187
                .then(function(string) {
1185
                    return showConfirmDialogue(header, body, footer, [SELECTORS.ACTION_CONFIRM_UNBLOCK], string, '', true, false);
1188
                    return showConfirmDialogue(header, body, footer, [SELECTORS.ACTION_CONFIRM_UNBLOCK], string, '', true, false);
1186
                });
1189
                });
1187
        } else {
1190
        } else {
1188
            return hideConfirmDialogue(header, body, footer);
1191
            return hideConfirmDialogue(header, body, footer);
Línea 1198... Línea 1201...
1198
     * @param {Object} user User to add as contact.
1201
     * @param {Object} user User to add as contact.
1199
     * @return {Object} jQuery promise
1202
     * @return {Object} jQuery promise
1200
     */
1203
     */
1201
    var renderConfirmAddContact = function(header, body, footer, user) {
1204
    var renderConfirmAddContact = function(header, body, footer, user) {
1202
        if (user) {
1205
        if (user) {
-
 
1206
            // Truncate long usernames.
-
 
1207
            const userFullName = Truncate.truncate(user.fullname, {
-
 
1208
                length: 30,
-
 
1209
                words: true,
-
 
1210
                ellipsis: '...'
-
 
1211
            });
1203
            return Str.get_string('addcontactconfirm', 'core_message', user.fullname)
1212
            return Str.get_string('addcontactconfirm', 'core_message', userFullName)
1204
                .then(function(string) {
1213
                .then(function(string) {
1205
                    return showConfirmDialogue(
1214
                    return showConfirmDialogue(
1206
                        header,
1215
                        header,
1207
                        body,
1216
                        body,
1208
                        footer,
1217
                        footer,
Línea 1227... Línea 1236...
1227
     * @param {Object} user User to remove from contacts.
1236
     * @param {Object} user User to remove from contacts.
1228
     * @return {Object} jQuery promise
1237
     * @return {Object} jQuery promise
1229
     */
1238
     */
1230
    var renderConfirmRemoveContact = function(header, body, footer, user) {
1239
    var renderConfirmRemoveContact = function(header, body, footer, user) {
1231
        if (user) {
1240
        if (user) {
1232
            return Str.get_string('removecontactconfirm', 'core_message', user.fullname)
1241
            return Str.get_string('removecontactconfirm', 'core_message', truncateUsername(user.fullname))
1233
                .then(function(string) {
1242
                .then(function(string) {
1234
                    return showConfirmDialogue(
1243
                    return showConfirmDialogue(
1235
                        header,
1244
                        header,
1236
                        body,
1245
                        body,
1237
                        footer,
1246
                        footer,
Línea 1332... Línea 1341...
1332
     * Render the confirm delete conversation dialogue.
1341
     * Render the confirm delete conversation dialogue.
1333
     *
1342
     *
1334
     * @param {Object} header The header container element.
1343
     * @param {Object} header The header container element.
1335
     * @param {Object} body The body container element.
1344
     * @param {Object} body The body container element.
1336
     * @param {Object} footer The footer container element.
1345
     * @param {Object} footer The footer container element.
1337
     * @param {Bool} user The other user object.
1346
     * @param {Object} user The other user object.
1338
     * @return {Object} jQuery promise
1347
     * @return {Object} jQuery promise
1339
     */
1348
     */
1340
    var renderConfirmContactRequest = function(header, body, footer, user) {
1349
    var renderConfirmContactRequest = function(header, body, footer, user) {
1341
        if (user) {
1350
        if (user) {
1342
            return Str.get_string('userwouldliketocontactyou', 'core_message', user.fullname)
1351
            return Str.get_string('userwouldliketocontactyou', 'core_message', truncateUsername(user.fullname))
1343
                .then(function(string) {
1352
                .then(function(string) {
1344
                    var buttonSelectors = [
1353
                    var buttonSelectors = [
1345
                        SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST,
1354
                        SELECTORS.ACTION_ACCEPT_CONTACT_REQUEST,
1346
                        SELECTORS.ACTION_DECLINE_CONTACT_REQUEST
1355
                        SELECTORS.ACTION_DECLINE_CONTACT_REQUEST
1347
                    ];
1356
                    ];
Línea 1639... Línea 1648...
1639
     * Show or hide the require add contact panel.
1648
     * Show or hide the require add contact panel.
1640
     *
1649
     *
1641
     * @param {Object} header The header container element.
1650
     * @param {Object} header The header container element.
1642
     * @param {Object} body The body container element.
1651
     * @param {Object} body The body container element.
1643
     * @param {Object} footer The footer container element.
1652
     * @param {Object} footer The footer container element.
1644
     * @param {Object} userFullName Full name of the other user.
1653
     * @param {String} userFullName Full name of the other user.
1645
     * @return {Object|true} jQuery promise
1654
     * @return {Object|true} jQuery promise
1646
     */
1655
     */
1647
    var renderContactRequestSent = function(header, body, footer, userFullName) {
1656
    var renderContactRequestSent = function(header, body, footer, userFullName) {
1648
        var container = getContactRequestSentContainer(body);
1657
        var container = getContactRequestSentContainer(body);
1649
        if (userFullName) {
1658
        if (userFullName) {
1650
            return Str.get_string('yourcontactrequestpending', 'core_message', userFullName)
1659
            return Str.get_string('yourcontactrequestpending', 'core_message', truncateUsername(userFullName))
1651
                .then(function(string) {
1660
                .then(function(string) {
1652
                    container.find(SELECTORS.TEXT).text(string);
1661
                    container.find(SELECTORS.TEXT).text(string);
1653
                    container.removeClass('hidden');
1662
                    container.removeClass('hidden');
1654
                    return string;
1663
                    return string;
1655
                });
1664
                });
Línea 1752... Línea 1761...
1752
                return;
1761
                return;
1753
            })
1762
            })
1754
            .catch(Notification.exception);
1763
            .catch(Notification.exception);
1755
    };
1764
    };
Línea -... Línea 1765...
-
 
1765
 
-
 
1766
    /**
-
 
1767
     * Truncate long usernames.
-
 
1768
     *
-
 
1769
     * @param {String} username Text to truncate.
-
 
1770
     * @return {String} Truncated string.
-
 
1771
     */
-
 
1772
    var truncateUsername = function(username) {
-
 
1773
        return Truncate.truncate(username, {
-
 
1774
            length: 30,
-
 
1775
            words: true,
-
 
1776
            ellipsis: '...'
-
 
1777
        });
-
 
1778
    };
1756
 
1779
 
1757
    return {
1780
    return {
1758
        render: render,
1781
        render: render,
1759
    };
1782
    };