From 8abb5fde976af7c50201716d440490413c022cf7 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 31 May 2019 15:42:36 +0300 Subject: [PATCH] [DE mobile] Refactoring Edit Users --- .../mobile/app/controller/Collaboration.js | 53 +++++++++---------- 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/Collaboration.js b/apps/documenteditor/mobile/app/controller/Collaboration.js index 1cbf3264e..4fef06d36 100644 --- a/apps/documenteditor/mobile/app/controller/Collaboration.js +++ b/apps/documenteditor/mobile/app/controller/Collaboration.js @@ -576,48 +576,43 @@ define([ }, initEditUsers: function() { - var templateUserItem = _.template([ - '<% _.each(users, function(item) { %>', - '
  • ' + - '
    ' + - '
    <%= item.initial %>
    '+ - '' + - '<% if (item.len>1) { %><% } %>' + - '
    '+ - '
  • ', - '<% }); %>' - ].join('')); - var users = [], - usersSort = [], - len; + var usersArray = []; _.each(editUsers, function(item){ - var fio = item.userName.split(' '); + var fio = item.asc_getUserName().split(' '); var initials = fio[0].substring(0, 1).toUpperCase(); if (fio.length > 1) { initials += fio[fio.length - 1].substring(0, 1).toUpperCase(); } - users.push({color: item.asc_getColor(), id: item.id, idOriginal: item.idOriginal, name: item.userName, view: item.view, initial: initials}) - }); - _.each(users.filter(function (itm) {return !itm.view;}), function(item){ - if (usersSort.filter(function (itemFil) {return item.idOriginal === itemFil.idOriginal;}).length === 0) { - len = users.filter(function (itemFil) { - return (item.idOriginal === itemFil.idOriginal && !itemFil.view); - }).length; - usersSort.push({color: item.color, id: item.id, idOriginal: item.idOriginal, name: item.name, view: item.view, len: len, initial: item.initial}) + if(!item.asc_getView()) { + usersArray.push({ + color: item.asc_getColor(), + id: item.asc_getId(), + idOriginal: item.asc_getIdOriginal(), + name: item.asc_getUserName(), + view: item.asc_getView(), + initial: initials + }) } }); + var userSort = _.chain(usersArray).groupBy('idOriginal').value(); + var templateUserItem = _.template([ + '<% _.each(users, function (user) { %>', + '
  • ' + + '
    ' + + '
    <%= user[0].initial %>
    '+ + '' + + '<% if (user.length>1) { %><% } %>' + + '
    '+ + '
  • ', + '<% }); %>'].join('')); var templateUserList = _.template( '
    ' + this.textEditUser + '
    ' + ''); - $('#user-list').html(templateUserList({ - users: usersSort.filter(function (item) { - return !item.view; - }), - })); + $('#user-list').html(templateUserList()); },