From 9b45f0dd7949449ec287dc0ced7e87a62eb17103 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 16 Jul 2019 17:29:55 +0200 Subject: [PATCH] Add translation keys --- .../src/less2/include/notifications.less | 14 +++++++ www/common/notifications.js | 40 ++++++++++++++++--- www/common/outer/mailbox-handlers.js | 4 +- www/common/toolbar3.js | 10 ++++- 4 files changed, 60 insertions(+), 8 deletions(-) diff --git a/customize.dist/src/less2/include/notifications.less b/customize.dist/src/less2/include/notifications.less index b19a9c86b..e68b3a72d 100644 --- a/customize.dist/src/less2/include/notifications.less +++ b/customize.dist/src/less2/include/notifications.less @@ -1,4 +1,5 @@ @import (reference) "./colortheme-all.less"; +@import (reference) "./avatar.less"; .notifications_main() { --LessLoader_require: LessLoader_currentFile(); @@ -53,6 +54,19 @@ } } } + .cp-notifications-requestedit-verified { + display: flex; + align-items: center; + &> span.cp-avatar { + .avatar_main(50px); + } + &> span { + margin-right: 10px; + } + &> p { + margin: 0; + } + } } diff --git a/www/common/notifications.js b/www/common/notifications.js index 4a3f7ca19..7312b33f7 100644 --- a/www/common/notifications.js +++ b/www/common/notifications.js @@ -115,18 +115,48 @@ define([ // Display the notification content.getFormatText = function () { - return 'Edit access request: ' + msg.content.title + ' - ' + msg.content.user.displayName; - }; // XXX + return Messages._getKey('requestEdit_request', [msg.content.title, msg.content.displayName]); + }; // if not archived, add handlers content.handler = function () { - UI.confirm("Give edit rights?", function (yes) { + var metadataMgr = common.getMetadataMgr(); + var priv = metadataMgr.getPrivateData(); + + var link = h('a', { + href: '#' + }, Messages.requestEdit_viewPad); + var verified = h('p.cp-notifications-requestedit-verified'); + + if (priv.friends && priv.friends[msg.author]) { + var f = priv.friends[msg.author]; + var $verified = $(verified); + $verified.append(h('span.fa.fa-certificate')); + var $avatar = $(h('span.cp-avatar')).appendTo($verified); + $verified.append(h('p', Messages._getKey('requestEdit_verified', [f.displayName]))); + common.displayAvatar($avatar, f.avatar, f.displayName); + } + + var div = h('div', [ + h('p', Messages._getKey('requestEdit_confirm', [msg.content.title, msg.content.displayName])), + verified, + link + ]); + $(link).click(function (e) { + e.preventDefault(); + e.stopPropagation(); + common.openURL(msg.content.href); + }); + UI.confirm(div, function (yes) { if (!yes) { return; } common.getSframeChannel().event('EV_GIVE_ACCESS', { channel: msg.content.channel, user: msg.content.user }); defaultDismiss(common, data)(); + }, { + ok: Messages.friendRequest_accept, + cancel: Messages.friendRequest_decline }); }; @@ -146,8 +176,8 @@ define([ // Display the notification content.getFormatText = function () { - return 'Edit access received: ' + msg.content.title + ' from ' + msg.content.user.displayName; - }; // XXX + return Messages._getKey('requestEdit_accepted', [msg.content.title, msg.content.displayName]); + }; // if not archived, add handlers content.handler = function () { diff --git a/www/common/outer/mailbox-handlers.js b/www/common/outer/mailbox-handlers.js index 6bc0536be..9d383caa1 100644 --- a/www/common/outer/mailbox-handlers.js +++ b/www/common/outer/mailbox-handlers.js @@ -222,17 +222,19 @@ define([ if (!res.length) { return void cb(true); } var edPublic = ctx.store.proxy.edPublic; - var title; + var title, href; if (!res.some(function (obj) { if (obj.data && Array.isArray(obj.data.owners) && obj.data.owners.indexOf(edPublic) !== -1 && obj.data.href) { + href = obj.data.href; title = obj.data.filename || obj.data.title; return true; } })) { return void cb(true); } content.title = title; + content.href = href; cb(false); }; diff --git a/www/common/toolbar3.js b/www/common/toolbar3.js index 53aa93f4f..6c262e2d1 100644 --- a/www/common/toolbar3.js +++ b/www/common/toolbar3.js @@ -585,7 +585,7 @@ MessengerUI, Messages) { var $requestBlock = $('