Enable properties modal when the pad is not stored

pull/1/head
yflory 4 years ago
parent a69fb1fae9
commit e7a72896d5

@ -836,13 +836,8 @@ define([
.text(Messages.propertiesButton))
.click(common.prepareFeedback(type))
.click(function () {
common.isPadStored(function (err, data) {
if (!data) {
return void UI.alert(Messages.autostore_notAvailable);
}
sframeChan.event('EV_PROPERTIES_OPEN');
});
});
break;
case 'save': // OnlyOffice save
button = $('<button>', {

@ -18,6 +18,16 @@ define([
opts = opts || {};
var $d = $('<div>');
if (!data) { return void cb(void 0, $d); }
data = Util.clone(data);
var privateData = common.getMetadataMgr().getPrivateData();
if (privateData.propChannels) {
var p = privateData.propChannels;
data.channel = data.channel || p.channel;
data.rtChannel = data.rtChannel || p.rtChannel;
data.lastVersion = data.lastVersion || p.lastVersion;
data.lastCpHash = data.lastCpHash || p.lastCpHash;
}
if (data.channel) {
$('<label>', { 'for': 'cp-app-prop-id'}).text(Messages.documentID).appendTo($d);
@ -26,6 +36,7 @@ define([
}));
}
if (!data.fakeHref) {
if (data.href) {
$('<label>', {'for': 'cp-app-prop-link'}).text(Messages.editShare).appendTo($d);
$d.append(UI.dialog.selectable(data.href, {
@ -39,6 +50,7 @@ define([
id: 'cp-app-prop-rolink',
}));
}
}
if (data.tags && Array.isArray(data.tags)) {
$d.append(h('div.cp-app-prop', [Messages.fm_prop_tagsList, h('br'), h('span.cp-app-prop-content', data.tags.join(', '))]));
@ -54,7 +66,6 @@ define([
if (!common.isLoggedIn()) { return void cb(void 0, $d); }
var privateData = common.getMetadataMgr().getPrivateData();
if (privateData.offline) { return void cb(void 0, $d); }
// File and history size...
@ -179,6 +190,7 @@ define([
Properties.getPropertiesModal = function (common, opts, cb) {
cb = cb || function () {};
opts = opts || {};
opts.access = true;
var tabs = [{
getTab: getPadProperties,
title: Messages.fc_prop,

@ -26,6 +26,10 @@ define([
obj.ooVersionHash = version;
obj.ooForceVersion = localStorage.CryptPad_ooVersion || "";
};
var channels = {};
var getPropChannels = function () {
return channels;
};
var addRpc = function (sframeChan, Cryptpad, Utils) {
sframeChan.on('Q_OO_SAVE', function (data, cb) {
var chanId = Utils.Hash.hrefToHexChannelId(data.url);
@ -38,14 +42,17 @@ define([
Cryptpad.pinPads([chanId], function (e) {
if (e) { return void cb(e); }
Cryptpad.setPadAttribute('lastVersion', data.url, cb);
channels.lastVersion = data.url;
});
Cryptpad.setPadAttribute('lastCpHash', data.hash, cb);
channels.lastCpHash = data.hash;
});
sframeChan.on('Q_OO_OPENCHANNEL', function (data, cb) {
Cryptpad.getPadAttribute('rtChannel', function (err, res) {
// If already stored, don't pin it again
if (res && res === data.channel) { return; }
Cryptpad.pinPads([data.channel], function () {
channels.rtChannel = data.channel;
Cryptpad.setPadAttribute('rtChannel', data.channel, function () {});
});
});
@ -144,6 +151,7 @@ define([
useCreationScreen: true,
addData: addData,
addRpc: addRpc,
getPropChannels: getPropChannels,
messaging: true
});
});

@ -1378,6 +1378,14 @@ define([
// Secure modal
var SecureModal = {};
// Create or display the iframe and modal
var getPropChannels = function () {
var channels = {};
if (cfg.getPropChannels) {
channels = Utils.Util.clone(cfg.getPropChannels());
}
channels.channel = secret.channel;
return channels;
};
var initSecureModal = function (type, cfg, cb) {
cfg.modal = type;
SecureModal.cb = cb;
@ -1397,7 +1405,8 @@ define([
app: parsed.type,
hashes: hashes,
password: password,
isTemplate: isTemplate
isTemplate: isTemplate,
getPropChannels: getPropChannels
};
config.addCommonRpc = addCommonRpc;
config.modules = {

@ -103,6 +103,7 @@ define([
feedbackAllowed: Utils.Feedback.state,
hashes: config.data.hashes,
password: config.data.password,
propChannels: config.data.getPropChannels(),
isTemplate: isTemplate,
file: config.data.file,
secureIframe: true,

Loading…
Cancel
Save