Fix 'enable cba' button in properties

pull/1/head
yflory 5 years ago
parent b208ca367d
commit 0ca779dbd1

@ -1621,7 +1621,17 @@ define([
if (!data) { if (!data) {
return void UI.alert(Messages.autostore_notAvailable); return void UI.alert(Messages.autostore_notAvailable);
} }
sframeChan.event('EV_PROPERTIES_OPEN'); sframeChan.query('Q_PROPERTIES_OPEN', null, function (err, data) {
if (!data || !data.cmd) { return; }
if (data.cmd === "UPDATE_METADATA") {
if (!data.key) { return; }
var metadataMgr = common.getMetadataMgr();
var md = Util.clone(metadataMgr.getMetadata());
md[data.key] = data.value;
if (!data.value) { delete md[data.key]; }
metadataMgr.updateMetadata(md);
}
});
}); });
}); });
break; break;

@ -58,6 +58,7 @@ define([
Messages.cba_disable = "Clear all colors and disable"; // XXX Messages.cba_disable = "Clear all colors and disable"; // XXX
if (owned && priv.app === 'code') { if (owned && priv.app === 'code') {
(function () { (function () {
var sframeChan = common.getSframeChannel();
var md = metadataMgr.getMetadata(); var md = metadataMgr.getMetadata();
var div = h('div'); var div = h('div');
var hint = h('div.cp-app-prop-hint', Messages.cba_hint); var hint = h('div.cp-app-prop-hint', Messages.cba_hint);
@ -73,10 +74,12 @@ define([
classes: 'btn-primary' classes: 'btn-primary'
}, function () { }, function () {
$button.remove(); $button.remove();
var md = Util.clone(metadataMgr.getMetadata()); sframeChan.event("EV_SECURE_ACTION", {
md.enableColors = true; cmd: 'UPDATE_METADATA',
key: 'enableColors',
value: true
});
common.setAttribute(['code', 'enableColors'], true); common.setAttribute(['code', 'enableColors'], true);
metadataMgr.updateMetadata(md);
setButton(false); setButton(false);
}); });
return; return;
@ -87,10 +90,12 @@ define([
classes: 'btn-danger' classes: 'btn-danger'
}, function () { }, function () {
$button.remove(); $button.remove();
var md = Util.clone(metadataMgr.getMetadata()); sframeChan.event("EV_SECURE_ACTION", {
md.enableColors = false; cmd: 'UPDATE_METADATA',
key: 'enableColors',
value: false
});
common.setAttribute(['code', 'enableColors'], false); common.setAttribute(['code', 'enableColors'], false);
metadataMgr.updateMetadata(md);
setButton(true); setButton(true);
}); });
}; };

@ -1036,8 +1036,8 @@ define([
initSecureModal('filepicker', data || {}, cb); initSecureModal('filepicker', data || {}, cb);
}); });
sframeChan.on('EV_PROPERTIES_OPEN', function (data) { sframeChan.on('Q_PROPERTIES_OPEN', function (data, cb) {
initSecureModal('properties', data || {}, null); initSecureModal('properties', data || {}, cb);
}); });
sframeChan.on('EV_ACCESS_OPEN', function (data) { sframeChan.on('EV_ACCESS_OPEN', function (data) {

Loading…
Cancel
Save