mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Merge branch 'improve-announcement' of https://github.com/nztqa/wekan into nztqa-improve-announcement
This commit is contained in:
commit
d213d37dab
10 changed files with 135 additions and 4 deletions
|
|
@ -130,6 +130,7 @@
|
||||||
"Authentication": true,
|
"Authentication": true,
|
||||||
"Integrations": true,
|
"Integrations": true,
|
||||||
"HTTP": true,
|
"HTTP": true,
|
||||||
"AccountSettings": true
|
"AccountSettings": true,
|
||||||
|
"Announcements": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,13 @@ template(name="header")
|
||||||
if appIsOffline
|
if appIsOffline
|
||||||
+offlineWarning
|
+offlineWarning
|
||||||
|
|
||||||
|
if hasAnnouncement
|
||||||
|
.announcement
|
||||||
|
p
|
||||||
|
i.fa.fa-bullhorn
|
||||||
|
| #{announcement}
|
||||||
|
i.fa.fa-times-circle.js-close-announcement
|
||||||
|
|
||||||
template(name="offlineWarning")
|
template(name="offlineWarning")
|
||||||
.offline-warning
|
.offline-warning
|
||||||
p
|
p
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,22 @@ Template.header.helpers({
|
||||||
appIsOffline() {
|
appIsOffline() {
|
||||||
return !Meteor.status().connected;
|
return !Meteor.status().connected;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
hasAnnouncement() {
|
||||||
|
const announcements = Announcements.findOne();
|
||||||
|
return announcements && announcements.enabled;
|
||||||
|
},
|
||||||
|
|
||||||
|
announcement() {
|
||||||
|
$('.announcement').show();
|
||||||
|
const announcements = Announcements.findOne();
|
||||||
|
return announcements && announcements.body;
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.header.events({
|
Template.header.events({
|
||||||
'click .js-create-board': Popup.open('headerBarCreateBoard'),
|
'click .js-create-board': Popup.open('headerBarCreateBoard'),
|
||||||
|
'click .js-close-announcement'() {
|
||||||
|
$('.announcement').hide();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -197,6 +197,7 @@
|
||||||
li
|
li
|
||||||
height: 28px
|
height: 28px
|
||||||
|
|
||||||
|
.announcement,
|
||||||
.offline-warning
|
.offline-warning
|
||||||
width: 100%
|
width: 100%
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ template(name="setting")
|
||||||
a.js-setting-menu(data-id="email-setting") {{_ 'email'}}
|
a.js-setting-menu(data-id="email-setting") {{_ 'email'}}
|
||||||
li
|
li
|
||||||
a.js-setting-menu(data-id="account-setting") {{_ 'accounts'}}
|
a.js-setting-menu(data-id="account-setting") {{_ 'accounts'}}
|
||||||
|
li
|
||||||
|
a.js-setting-menu(data-id="announcement-setting") {{_ 'admin-announcement'}}
|
||||||
.main-body
|
.main-body
|
||||||
if loading.get
|
if loading.get
|
||||||
+spinner
|
+spinner
|
||||||
|
|
@ -23,6 +25,8 @@ template(name="setting")
|
||||||
+email
|
+email
|
||||||
else if accountSetting.get
|
else if accountSetting.get
|
||||||
+accountSettings
|
+accountSettings
|
||||||
|
else if announcementSetting.get
|
||||||
|
+announcementSettings
|
||||||
|
|
||||||
template(name="general")
|
template(name="general")
|
||||||
ul#registration-setting.setting-detail
|
ul#registration-setting.setting-detail
|
||||||
|
|
@ -96,3 +100,19 @@ template(name='accountSettings')
|
||||||
span {{_ 'no'}}
|
span {{_ 'no'}}
|
||||||
li
|
li
|
||||||
button.js-accounts-save.primary {{_ 'save'}}
|
button.js-accounts-save.primary {{_ 'save'}}
|
||||||
|
|
||||||
|
template(name='announcementSettings')
|
||||||
|
ul#announcement-setting.setting-detail
|
||||||
|
li
|
||||||
|
a.flex.js-toggle-activemessage
|
||||||
|
.materialCheckBox(class="{{#if currentSetting.enabled}}is-checked{{/if}}")
|
||||||
|
|
||||||
|
span {{_ 'admin-announcement-active'}}
|
||||||
|
li
|
||||||
|
.admin-announcement(class="{{#if currentSetting.enabled}}{{else}}hide{{/if}}")
|
||||||
|
ul
|
||||||
|
li
|
||||||
|
.title {{_ 'admin-announcement-title'}}
|
||||||
|
textarea#admin-announcement.form-control= currentSetting.body
|
||||||
|
li
|
||||||
|
button.js-announcement-save.primary {{_ 'save'}}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
Meteor.subscribe('setting');
|
Meteor.subscribe('setting');
|
||||||
Meteor.subscribe('mailServer');
|
Meteor.subscribe('mailServer');
|
||||||
Meteor.subscribe('accountSettings');
|
Meteor.subscribe('accountSettings');
|
||||||
|
Meteor.subscribe('announcements');
|
||||||
|
|
||||||
BlazeComponent.extendComponent({
|
BlazeComponent.extendComponent({
|
||||||
onCreated() {
|
onCreated() {
|
||||||
|
|
@ -9,6 +10,7 @@ BlazeComponent.extendComponent({
|
||||||
this.generalSetting = new ReactiveVar(true);
|
this.generalSetting = new ReactiveVar(true);
|
||||||
this.emailSetting = new ReactiveVar(false);
|
this.emailSetting = new ReactiveVar(false);
|
||||||
this.accountSetting = new ReactiveVar(false);
|
this.accountSetting = new ReactiveVar(false);
|
||||||
|
this.announcementSetting = new ReactiveVar(false);
|
||||||
},
|
},
|
||||||
|
|
||||||
setError(error) {
|
setError(error) {
|
||||||
|
|
@ -65,6 +67,7 @@ BlazeComponent.extendComponent({
|
||||||
this.generalSetting.set('registration-setting' === targetID);
|
this.generalSetting.set('registration-setting' === targetID);
|
||||||
this.emailSetting.set('email-setting' === targetID);
|
this.emailSetting.set('email-setting' === targetID);
|
||||||
this.accountSetting.set('account-setting' === targetID);
|
this.accountSetting.set('account-setting' === targetID);
|
||||||
|
this.announcementSetting.set('announcement-setting' === targetID);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -152,3 +155,45 @@ BlazeComponent.extendComponent({
|
||||||
}];
|
}];
|
||||||
},
|
},
|
||||||
}).register('accountSettings');
|
}).register('accountSettings');
|
||||||
|
|
||||||
|
BlazeComponent.extendComponent({
|
||||||
|
onCreated() {
|
||||||
|
this.loading = new ReactiveVar(false);
|
||||||
|
},
|
||||||
|
|
||||||
|
setLoading(w) {
|
||||||
|
this.loading.set(w);
|
||||||
|
},
|
||||||
|
|
||||||
|
currentSetting(){
|
||||||
|
return Announcements.findOne();
|
||||||
|
},
|
||||||
|
|
||||||
|
saveMessage() {
|
||||||
|
const message = $('#admin-announcement').val().trim();
|
||||||
|
Announcements.update(Announcements.findOne()._id, {
|
||||||
|
$set: { 'body': message },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleActive(){
|
||||||
|
this.setLoading(true);
|
||||||
|
const isActive = this.currentSetting().enabled;
|
||||||
|
Announcements.update(Announcements.findOne()._id, {
|
||||||
|
$set:{ 'enabled': !isActive},
|
||||||
|
});
|
||||||
|
this.setLoading(false);
|
||||||
|
if(isActive){
|
||||||
|
$('.admin-announcement').slideUp();
|
||||||
|
}else{
|
||||||
|
$('.admin-announcement').slideDown();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
events() {
|
||||||
|
return [{
|
||||||
|
'click a.js-toggle-activemessage': this.toggleActive,
|
||||||
|
'click button.js-announcement-save': this.saveMessage,
|
||||||
|
}];
|
||||||
|
},
|
||||||
|
}).register('announcementSettings');
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@
|
||||||
span
|
span
|
||||||
padding: 0 0.5rem
|
padding: 0 0.5rem
|
||||||
|
|
||||||
|
.admin-announcement,
|
||||||
.invite-people
|
.invite-people
|
||||||
padding-left 20px;
|
padding-left 20px;
|
||||||
li
|
li
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,9 @@
|
||||||
"addMemberPopup-title": "Members",
|
"addMemberPopup-title": "Members",
|
||||||
"admin": "Admin",
|
"admin": "Admin",
|
||||||
"admin-desc": "Can view and edit cards, remove members, and change settings for the board.",
|
"admin-desc": "Can view and edit cards, remove members, and change settings for the board.",
|
||||||
|
"admin-announcement": "Announcement",
|
||||||
|
"admin-announcement-active": "Active System-Wide Announcement",
|
||||||
|
"admin-announcement-title": "Announcement from Administrator",
|
||||||
"all-boards": "All boards",
|
"all-boards": "All boards",
|
||||||
"and-n-other-card": "And __count__ other card",
|
"and-n-other-card": "And __count__ other card",
|
||||||
"and-n-other-card_plural": "And __count__ other cards",
|
"and-n-other-card_plural": "And __count__ other cards",
|
||||||
|
|
|
||||||
36
models/announcements.js
Normal file
36
models/announcements.js
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
Announcements = new Mongo.Collection('announcements');
|
||||||
|
|
||||||
|
Announcements.attachSchema(new SimpleSchema({
|
||||||
|
enabled: {
|
||||||
|
type: Boolean,
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
Announcements.allow({
|
||||||
|
update(userId) {
|
||||||
|
const user = Users.findOne(userId);
|
||||||
|
return user && user.isAdmin;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Meteor.isServer) {
|
||||||
|
Meteor.startup(() => {
|
||||||
|
const announcements = Announcements.findOne({});
|
||||||
|
if(!announcements){
|
||||||
|
Announcements.insert({enabled: false, sort: 0});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
3
server/publications/announcements.js
Normal file
3
server/publications/announcements.js
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Meteor.publish('announcements', function() {
|
||||||
|
return Announcements.find();
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue