Always show the delete section in the broadcast panel

pull/1/head
yflory 4 years ago
parent 39ce9dd02b
commit 098011d1b2

@ -19,10 +19,13 @@
display: flex; display: flex;
.cp-broadcast { .cp-broadcast {
display: flex; display: flex;
img { font-size: 30px;
width: 30px; align-items: center;
}
padding: 0 5px; padding: 0 5px;
color: @cp_dropdown-fg;
&.preview {
color: red; // XXX
}
} }
.cp-avatar { .cp-avatar {
.avatar_main(30px); .avatar_main(30px);

@ -74,7 +74,8 @@ define([
'cp-admin-support-init' 'cp-admin-support-init'
], ],
'broadcast': [ // Msg.admin_cat_support 'broadcast': [ // Msg.admin_cat_support
'cp-admin-broadcast' 'cp-admin-broadcast-delete',
'cp-admin-broadcast',
], ],
'performance': [ // Msg.admin_cat_performance 'performance': [ // Msg.admin_cat_performance
'cp-admin-refresh-performance', 'cp-admin-refresh-performance',
@ -942,6 +943,10 @@ define([
Messages.admin_cat_broadcast = "Broadcast"; // XXX Messages.admin_cat_broadcast = "Broadcast"; // XXX
// Messages.admin_broadcastHint // XXX // Messages.admin_broadcastHint // XXX
// Messages.admin_broadcastTitle // XXX // Messages.admin_broadcastTitle // XXX
//Messages.admin_broadcastDeleteHint // XXX
//Messages.admin_broadcastDeleteTitle // XXX
Messages.broadcast_new = "New message"; Messages.broadcast_new = "New message";
Messages.broadcast_maintenance = 'maintenance';// XXX Messages.broadcast_maintenance = 'maintenance';// XXX
Messages.broadcast_survey = 'survey'; // XXX Messages.broadcast_survey = 'survey'; // XXX
@ -961,6 +966,7 @@ define([
Messages.broadcast_empty = "No active message"; Messages.broadcast_empty = "No active message";
Messages.broadcast_noFallback = "Don't fallback to a default language"; Messages.broadcast_noFallback = "Don't fallback to a default language";
var onRefreshBroadcast = Util.mkEvent();
var getBroadcastForm = function ($form, key) { var getBroadcastForm = function ($form, key) {
$form.empty(); $form.empty();
@ -991,6 +997,7 @@ define([
// Clear the UI // Clear the UI
reset(); reset();
onRefreshBroadcast.fire();
// Only print success if there is no callback // Only print success if there is no callback
if (!_cb) { UI.log(Messages.saved); } if (!_cb) { UI.log(Messages.saved); }
@ -1048,7 +1055,6 @@ define([
var $noFallbackBtn = $(noFallbackBtn); var $noFallbackBtn = $(noFallbackBtn);
var checkFallbackBtn = function () { var checkFallbackBtn = function () {
var hasDefault = $container.find('.cp-broadcast-lang .cp-checkmark input:checked').length; var hasDefault = $container.find('.cp-broadcast-lang .cp-checkmark input:checked').length;
console.error(hasDefault);
if (hasDefault) { if (hasDefault) {
$noFallbackBtn.css('visibility', ''); $noFallbackBtn.css('visibility', '');
} else { } else {
@ -1364,7 +1370,7 @@ define([
return; return;
} }
// On success, reload the "delete" tab // On success, reload the "delete" tab
getBroadcastForm($form, key); onRefreshBroadcast.fire();
}); });
}); });
}); });
@ -1392,7 +1398,6 @@ define([
'survey', 'survey',
'version', 'version',
'custom', 'custom',
'delete'
]; ];
// The "version" message only works if the instance is using a manual /api/config // The "version" message only works if the instance is using a manual /api/config
@ -1423,6 +1428,20 @@ define([
return $div; return $div;
}; };
create['broadcast-delete'] = function () {
var key = 'broadcast-delete';
var $div = makeBlock(key);
var form = h('div.cp-admin-broadcast-form');
var $form = $(form).appendTo($div);
getBroadcastForm($form, 'delete');
onRefreshBroadcast.reg(function () {
getBroadcastForm($form, 'delete');
});
return $div;
};
var onRefreshPerformance = Util.mkEvent(); var onRefreshPerformance = Util.mkEvent();

@ -1,6 +1,5 @@
define([ define([
'jquery', 'jquery',
'/api/config',
'/common/common-util.js', '/common/common-util.js',
'/common/common-hash.js', '/common/common-hash.js',
'/common/common-interface.js', '/common/common-interface.js',
@ -8,7 +7,7 @@ define([
'/common/notifications.js', '/common/notifications.js',
'/common/hyperscript.js', '/common/hyperscript.js',
'/customize/messages.js', '/customize/messages.js',
], function ($, ApiConfig, Util, Hash, UI, UIElements, Notifications, h, Messages) { ], function ($, Util, Hash, UI, UIElements, Notifications, h, Messages) {
var Mailbox = {}; var Mailbox = {};
Mailbox.create = function (Common) { Mailbox.create = function (Common) {
@ -62,10 +61,10 @@ define([
return; return;
} }
if (data.type === 'broadcast') { if (data.type === 'broadcast') {
var urlArgs = Util.find(ApiConfig, ['requireConf', 'urlArgs']) || ''; avatar = h('i.fa.fa-bullhorn.cp-broadcast');
avatar = h('span.cp-broadcast', h('img', { if (/^LOCAL\|/.test(data.content.hash)) {
src: '/customize/CryptPad_logo.svg?' + urlArgs, $(avatar).addClass('preview');
})); }
} else if (userData && typeof(userData) === "object" && userData.profile) { } else if (userData && typeof(userData) === "object" && userData.profile) {
avatar = h('span.cp-avatar'); avatar = h('span.cp-avatar');
Common.displayAvatar($(avatar), userData.avatar, userData.displayName || userData.name); Common.displayAvatar($(avatar), userData.avatar, userData.displayName || userData.name);

Loading…
Cancel
Save