diff --git a/dev/App/User.jsx b/dev/App/User.jsx index b3accdfbe..a16792283 100644 --- a/dev/App/User.jsx +++ b/dev/App/User.jsx @@ -426,25 +426,36 @@ class AppUser extends AbstractApp if (oItem && oItem.primaryKey) { var - + aEmails = [], + aUsers = [], oPrimaryUser = oItem.getPrimaryUser(), sUser = (oPrimaryUser && oPrimaryUser.user) ? oPrimaryUser.user.userId.userid : (oItem.users && oItem.users[0] ? oItem.users[0].userId.userid : '') ; - oEmail.clear(); - oEmail.mailsoParse(sUser); + if (oItem.users) { + _.each(oItem.users, (oItem) => { + oEmail.clear(); + oEmail.mailsoParse(oItem.userId.userid); + if (oEmail.validate()) + { + aEmails.push(oEmail.email); + aUsers.push(oItem.userId.userid); + } + }); + } - if (oEmail.validate()) + if (aEmails.length) { aKeys.push(new OpenPgpKeyModel( iIndex, oItem.primaryKey.getFingerprint(), oItem.primaryKey.getKeyId().toHex().toLowerCase(), - sUser, - oEmail.email, + aUsers, + aEmails, oItem.isPrivate(), - oItem.armor()) + oItem.armor(), + sUser) ); } } diff --git a/dev/Model/OpenPgpKey.js b/dev/Model/OpenPgpKey.js index 5d555bea0..c68c7013d 100644 --- a/dev/Model/OpenPgpKey.js +++ b/dev/Model/OpenPgpKey.js @@ -18,23 +18,25 @@ * @param {string} iIndex * @param {string} sGuID * @param {string} sID - * @param {string} sUserID - * @param {string} sEmail + * @param {array} aUserIDs + * @param {array} aEmails * @param {boolean} bIsPrivate * @param {string} sArmor + * @param {string} sUserID * @constructor */ - function OpenPgpKeyModel(iIndex, sGuID, sID, sUserID, sEmail, bIsPrivate, sArmor) + function OpenPgpKeyModel(iIndex, sGuID, sID, aUserIDs, aEmails, bIsPrivate, sArmor, sUserID) { AbstractModel.call(this, 'OpenPgpKeyModel'); this.index = iIndex; this.id = sID; this.guid = sGuID; - this.user = sUserID; - this.email = sEmail; + this.users = aUserIDs; + this.emails = aEmails; this.armor = sArmor; this.isPrivate = !!bIsPrivate; + this.selectUser(sUserID); this.deleteAccess = ko.observable(false); } @@ -45,7 +47,9 @@ OpenPgpKeyModel.prototype.id = ''; OpenPgpKeyModel.prototype.guid = ''; OpenPgpKeyModel.prototype.user = ''; + OpenPgpKeyModel.prototype.users = []; OpenPgpKeyModel.prototype.email = ''; + OpenPgpKeyModel.prototype.emails = []; OpenPgpKeyModel.prototype.armor = ''; OpenPgpKeyModel.prototype.isPrivate = false; @@ -74,6 +78,26 @@ return oKey && oKey.keys ? oKey.keys : null; }; + OpenPgpKeyModel.prototype.select = function (sPattern, sProperty) + { + var index = this[sProperty].indexOf(sPattern); + + if (index !== -1) { + this.user = this.users[index]; + this.email = this.emails[index]; + } + } + + OpenPgpKeyModel.prototype.selectUser = function (sUser) + { + this.select(sUser, 'users'); + } + + OpenPgpKeyModel.prototype.selectEmail = function (sEmail) + { + this.select(sEmail, 'emails'); + } + module.exports = OpenPgpKeyModel; -}()); \ No newline at end of file +}()); diff --git a/dev/Stores/User/Pgp.js b/dev/Stores/User/Pgp.js index 91e0f239d..b24ce9e29 100644 --- a/dev/Stores/User/Pgp.js +++ b/dev/Stores/User/Pgp.js @@ -59,7 +59,7 @@ PgpUserStore.prototype.findPublicKeysByEmail = function (sEmail) { return _.compact(_.flatten(_.map(this.openpgpkeysPublic(), function (oItem) { - var oKey = oItem && sEmail === oItem.email ? oItem : null; + var oKey = oItem && -1 !== oItem.emails.indexOf(sEmail) ? oItem : null; return oKey ? oKey.getNativeKeys() : [null]; }), true)); }; @@ -99,7 +99,7 @@ PgpUserStore.prototype.findPublicKeyByEmailNotNative = function (sEmail) { return _.find(this.openpgpkeysPublic(), function (oItem) { - return oItem && sEmail === oItem.email; + return oItem && -1 !== oItem.emails.indexOf(sEmail); }) || null; }; @@ -110,7 +110,7 @@ PgpUserStore.prototype.findPrivateKeyByEmailNotNative = function (sEmail) { return _.find(this.openpgpkeysPrivate(), function (oItem) { - return oItem && sEmail === oItem.email; + return oItem && -1 !== oItem.emails.indexOf(sEmail); }) || null; }; @@ -125,7 +125,7 @@ oPrivateKeys = [], oPrivateKey = null, oKey = _.find(this.openpgpkeysPrivate(), function (oItem) { - return oItem && sEmail === oItem.email; + return oItem && -1 !== oItem.emails.indexOf(sEmail); }) ; diff --git a/dev/Styles/OpenPgpKey.less b/dev/Styles/OpenPgpKey.less index 82efbcb69..6193ced85 100644 --- a/dev/Styles/OpenPgpKey.less +++ b/dev/Styles/OpenPgpKey.less @@ -33,8 +33,14 @@ min-height: 40px; &-wrp { - overflow: hidden; - text-overflow: ellipsis; + + &:hover { + overflow: auto; + } + + &:hover .key-list__item-name { + overflow: visible; + } &.empty { text-align: center; @@ -48,33 +54,35 @@ color: #333; white-space: nowrap; + padding-bottom: 4px; - &-delete { - display: inline; - cursor: pointer; - margin-right: 5px; + &:last-child { + padding-bottom: 0; } - &-name { - margin-right: 5px; + &-delete { + cursor: pointer; + } + + &-names { color: #333; - display: inline; &.empty { color: red; } } + &-name { + overflow: hidden; + text-overflow: ellipsis; + } + &-error { - margin-right: 5px; color: red; - display: inline; } &-hash { - margin-right: 5px; color: #aaa; - display: inline; } } } @@ -82,6 +90,10 @@ .key-actions { margin-top: 10px; min-height: 40px; + + select option.even { + background-color: #f5f5f5; + } } } @@ -103,15 +115,21 @@ white-space: nowrap; &__radio { - padding-right: 5px; + padding: 3px 5px 0 0; + vertical-align: top; } &__name { + border-bottom: 1px solid transparent; &:hover { border-bottom: 1px dashed #555; } } + + &__names { + display: inline-block; + } } } } @@ -129,4 +147,4 @@ } } } -} \ No newline at end of file +} diff --git a/dev/View/Popup/ComposeOpenPgp.js b/dev/View/Popup/ComposeOpenPgp.js index 7710e12a1..4001fc335 100644 --- a/dev/View/Popup/ComposeOpenPgp.js +++ b/dev/View/Popup/ComposeOpenPgp.js @@ -31,6 +31,14 @@ var self = this; this.optionsCaption = Translator.i18n('PGP_NOTIFICATIONS/ADD_A_PUBLICK_KEY'); + this.addOptionClass = function (oDomOption, oItem) + { + self.defautOptionsAfterRender(oDomOption, oItem); + + if (oItem) { + oDomOption.classList.add(oItem['class']); + } + }; this.notification = ko.observable(''); @@ -54,13 +62,17 @@ }, this); this.publicKeysOptions = ko.computed(function () { - return _.compact(_.map(PgpStore.openpgpkeysPublic(), function (oKey) { - return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : { - 'id': oKey.guid, - 'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + oKey.user, - 'key': oKey - }; - })); + return _.compact(_.flatten(_.map(PgpStore.openpgpkeysPublic(), function (oKey, iIndex) { + return -1 < Utils.inArray(oKey, self.encryptKeysView()) ? null : + _.map(oKey.users, function (sUser) { + return { + 'id': oKey.guid, + 'name': '(' + oKey.id.substr(-8).toUpperCase() + ') ' + sUser, + 'key': oKey, + 'class': iIndex % 2 ? 'odd' : 'even' + }; + }); + }), true)); }); this.submitRequest = ko.observable(false); @@ -236,7 +248,7 @@ aKeys.push({ 'empty': !oOption.key, 'selected': ko.observable(!!oOption.key), - 'user': oOption.key.user, + 'users': oOption.key.users, 'hash': oOption.key.id.substr(-8).toUpperCase(), 'key': oOption.key }); @@ -364,7 +376,7 @@ if (oKey) { this.signKey({ - 'user': oKey.user || sEmail, + 'users': oKey.users || [sEmail], 'hash': oKey.id.substr(-8).toUpperCase(), 'key': oKey }); @@ -383,7 +395,7 @@ return { 'empty': !oKey, 'selected': ko.observable(!!oKey), - 'user': oKey ? (oKey.user || sEmail) : sEmail, + 'users': oKey ? (oKey.users || [sEmail]) : [sEmail], 'hash': oKey ? oKey.id.substr(-8).toUpperCase() : '', 'key': oKey }; @@ -400,4 +412,4 @@ module.exports = ComposeOpenPgpPopupView; -}()); \ No newline at end of file +}()); diff --git a/dev/View/Popup/MessageOpenPgp.js b/dev/View/Popup/MessageOpenPgp.js index 85f178975..a3b26eb80 100644 --- a/dev/View/Popup/MessageOpenPgp.js +++ b/dev/View/Popup/MessageOpenPgp.js @@ -184,4 +184,4 @@ _.delay(_.bind(function() { module.exports = MessageOpenPgpPopupView; -}()); \ No newline at end of file +}()); diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsComposeOpenPgp.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsComposeOpenPgp.html index 22020aba9..d8b3704b9 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsComposeOpenPgp.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsComposeOpenPgp.html @@ -27,12 +27,16 @@ No private key found
-
-
+
+
()
-
- +
+
+
+
+
+
@@ -54,18 +58,22 @@
-
-
+
+
-
+
()
-
- -
-
- (Public key not found) +
+ + +
+
+
+ + (Public key not found) +
@@ -84,7 +92,7 @@
+ optionsAfterRender: addOptionClass">
diff --git a/rainloop/v/0.0.0/app/templates/Views/User/PopupsMessageOpenPgp.html b/rainloop/v/0.0.0/app/templates/Views/User/PopupsMessageOpenPgp.html index 92abe0450..b49087cce 100644 --- a/rainloop/v/0.0.0/app/templates/Views/User/PopupsMessageOpenPgp.html +++ b/rainloop/v/0.0.0/app/templates/Views/User/PopupsMessageOpenPgp.html @@ -18,11 +18,17 @@
- - -   - [] - +
+ +
+ + +   + [] + +
+
+