Access modal for calendars

pull/1/head
yflory 4 years ago
parent 547b0c1d3e
commit 09b229203c

@ -133,6 +133,9 @@
&:hover {
background: fade(@cryptpad_text_col, 10%);
}
&.cp-restricted {
color: @cp_drive-header-fg;
}
&.cp-active {
background: @cp_sidebar-left-active;
}

@ -390,6 +390,36 @@ Messages.calendar_import = "Import to my calendars";
return true;
}
});
options.push({
tag: 'a',
attributes: {
'class': 'fa fa-lock',
},
content: h('span', Messages.accessButton),
action: function (e) {
e.stopPropagation();
var friends = common.getFriends();
var cal = APP.calendars[id];
var title = Util.find(cal, ['content', 'metadata', 'title']);
var color = Util.find(cal, ['content', 'metadata', 'color']);
var h = cal.hashes || {};
var href = Hash.hashToHref(h.editHash || h.viewHash, 'calendar');
Access.getAccessModal(common, {
title: title,
password: cal.password, // XXX support passwords
calendar: {
title: title,
color: color,
channel: id,
},
common: common,
noExpiration: true,
channel: id,
href: href
});
return true;
}
});
}
if (!cantRemove) {
options.push({
@ -443,14 +473,16 @@ Messages.calendar_import = "Import to my calendars";
var md = Util.find(data, ['content', 'metadata']);
if (!md) { return; }
var active = data.hidden ? '' : '.cp-active';
var calendar = h('div.cp-calendar-entry'+active, {
var restricted = data.restricted ? '.cp-restricted' : '';
var calendar = h('div.cp-calendar-entry'+active+restricted, {
'data-uid': id
}, [
h('span.cp-calendar-color', {
style: 'background-color: '+md.color+';'
}),
h('span.cp-calendar-title', md.title),
isReadOnly(id, teamId) ? h('i.fa.fa-eye', {title: Messages.readonly}) : undefined,
data.restricted ? h('i.fa.fa-ban', {title: Messages.fm_restricted}) :
(isReadOnly(id, teamId) ? h('i.fa.fa-eye', {title: Messages.readonly}) : undefined),
edit
]);
$(calendar).click(function () {

@ -2921,7 +2921,7 @@ define([
var dismiss = function () {
common.mailbox.dismiss(data, function (err) {
console.log(err);
if (err) { console.log(err); }
});
};
var answer = function (yes) {
@ -2930,6 +2930,7 @@ define([
href: msg.content.href,
password: msg.content.password,
title: msg.content.title,
calendar: msg.content.calendar,
answer: yes
}, {
channel: msg.content.user.notifications,
@ -2965,6 +2966,18 @@ define([
// Add the pad to your drive
// This command will also add your mailbox to the metadata log
// The callback is called when the pad is stored, independantly of the metadata command
if (data.calendar) {
var calendarModule = common.makeUniversal('calendar');
var calendarData = data.calendar;
calendarData.href = data.href;
calendarData.teamId = 1;
calendarModule.execCommand('ADD', calendarData, function (obj) {
if (obj && obj.error) {
console.error(obj.error);
return void UI.warn(Messages.error);
}
});
} else {
sframeChan.query('Q_ACCEPT_OWNERSHIP', data, function (err, res) {
if (err || (res && res.error)) {
return void console.error(err | res.error);
@ -2975,6 +2988,7 @@ define([
delete autoStoreModal[data.channel];
}
});
}
// Remove yourself from the pending owners
sframeChan.query('Q_SET_PAD_METADATA', {

@ -336,6 +336,7 @@ define([
common.mailbox.sendTo("ADD_OWNER", {
channel: channel,
href: href,
calendar: opts.calendar,
password: data.password || priv.password,
title: data.title || title
}, {
@ -1016,7 +1017,7 @@ define([
var owned = Modal.isOwned(Env, data);
// Request edit access
if (common.isLoggedIn() && ((data.roHref && !data.href) || data.fakeHref) && !owned) {
if (common.isLoggedIn() && ((data.roHref && !data.href) || data.fakeHref) && !owned && !opts.calendar) {
var requestButton = h('button.btn.btn-secondary.no-margin.cp-access-margin-right',
Messages.requestEdit_button);
var requestBlock = h('p', requestButton);
@ -1054,7 +1055,7 @@ define([
var canMute = data.mailbox && owned === true && (
(typeof (data.mailbox) === "string" && data.owners[0] === edPublic) ||
data.mailbox[edPublic]);
if (owned === true) {
if (owned === true && !opts.calendar) {
var cbox = UI.createCheckbox('cp-access-mute', Messages.access_muteRequests, !canMute);
var $cbox = $(cbox);
var spinner = UI.makeSpinner($cbox);

Loading…
Cancel
Save