Fix 'enable cba' button in properties

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

@ -1621,7 +1621,17 @@ define([
if (!data) {
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;

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

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

Loading…
Cancel
Save