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;
.cp-broadcast {
display: flex;
img {
width: 30px;
}
font-size: 30px;
align-items: center;
padding: 0 5px;
color: @cp_dropdown-fg;
&.preview {
color: red; // XXX
}
}
.cp-avatar {
.avatar_main(30px);

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

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

Loading…
Cancel
Save