summaryrefslogtreecommitdiffstats
path: root/client/components
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-10-01 09:59:57 +0300
committerLauri Ojansivu <x@xet7.org>2017-10-01 09:59:57 +0300
commitd213d37dabe352ededa836ce947b11279704e828 (patch)
tree4d454adf0f80032439ba5f20dc3775d499a1a11d /client/components
parenta003161fa74a52f8567be6238d6890a88d091d54 (diff)
parenta88ac6113e5f7f428d0f021bbcb213cc517c177e (diff)
downloadwekan-d213d37dabe352ededa836ce947b11279704e828.tar.gz
wekan-d213d37dabe352ededa836ce947b11279704e828.tar.bz2
wekan-d213d37dabe352ededa836ce947b11279704e828.zip
Merge branch 'improve-announcement' of https://github.com/nztqa/wekan into nztqa-improve-announcement
Diffstat (limited to 'client/components')
-rw-r--r--client/components/main/header.jade7
-rw-r--r--client/components/main/header.js14
-rw-r--r--client/components/main/header.styl1
-rw-r--r--client/components/settings/settingBody.jade20
-rw-r--r--client/components/settings/settingBody.js45
-rw-r--r--client/components/settings/settingBody.styl7
6 files changed, 91 insertions, 3 deletions
diff --git a/client/components/main/header.jade b/client/components/main/header.jade
index bd0af880..613dd736 100644
--- a/client/components/main/header.jade
+++ b/client/components/main/header.jade
@@ -49,6 +49,13 @@ template(name="header")
if appIsOffline
+offlineWarning
+ if hasAnnouncement
+ .announcement
+ p
+ i.fa.fa-bullhorn
+ | #{announcement}
+ i.fa.fa-times-circle.js-close-announcement
+
template(name="offlineWarning")
.offline-warning
p
diff --git a/client/components/main/header.js b/client/components/main/header.js
index 49acbfef..c8f415df 100644
--- a/client/components/main/header.js
+++ b/client/components/main/header.js
@@ -10,8 +10,22 @@ Template.header.helpers({
appIsOffline() {
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({
'click .js-create-board': Popup.open('headerBarCreateBoard'),
+ 'click .js-close-announcement'() {
+ $('.announcement').hide();
+ },
});
diff --git a/client/components/main/header.styl b/client/components/main/header.styl
index 0e35d38a..191e8893 100644
--- a/client/components/main/header.styl
+++ b/client/components/main/header.styl
@@ -197,6 +197,7 @@
li
height: 28px
+.announcement,
.offline-warning
width: 100%
text-align: center
diff --git a/client/components/settings/settingBody.jade b/client/components/settings/settingBody.jade
index 5864efd5..2152cc2c 100644
--- a/client/components/settings/settingBody.jade
+++ b/client/components/settings/settingBody.jade
@@ -14,6 +14,8 @@ template(name="setting")
a.js-setting-menu(data-id="email-setting") {{_ 'email'}}
li
a.js-setting-menu(data-id="account-setting") {{_ 'accounts'}}
+ li
+ a.js-setting-menu(data-id="announcement-setting") {{_ 'admin-announcement'}}
.main-body
if loading.get
+spinner
@@ -23,6 +25,8 @@ template(name="setting")
+email
else if accountSetting.get
+accountSettings
+ else if announcementSetting.get
+ +announcementSettings
template(name="general")
ul#registration-setting.setting-detail
@@ -96,3 +100,19 @@ template(name='accountSettings')
span {{_ 'no'}}
li
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'}}
diff --git a/client/components/settings/settingBody.js b/client/components/settings/settingBody.js
index a2993426..27f690ee 100644
--- a/client/components/settings/settingBody.js
+++ b/client/components/settings/settingBody.js
@@ -1,6 +1,7 @@
Meteor.subscribe('setting');
Meteor.subscribe('mailServer');
Meteor.subscribe('accountSettings');
+Meteor.subscribe('announcements');
BlazeComponent.extendComponent({
onCreated() {
@@ -9,6 +10,7 @@ BlazeComponent.extendComponent({
this.generalSetting = new ReactiveVar(true);
this.emailSetting = new ReactiveVar(false);
this.accountSetting = new ReactiveVar(false);
+ this.announcementSetting = new ReactiveVar(false);
},
setError(error) {
@@ -65,6 +67,7 @@ BlazeComponent.extendComponent({
this.generalSetting.set('registration-setting' === targetID);
this.emailSetting.set('email-setting' === targetID);
this.accountSetting.set('account-setting' === targetID);
+ this.announcementSetting.set('announcement-setting' === targetID);
}
},
@@ -152,3 +155,45 @@ BlazeComponent.extendComponent({
}];
},
}).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');
diff --git a/client/components/settings/settingBody.styl b/client/components/settings/settingBody.styl
index 118d364c..fec64cee 100644
--- a/client/components/settings/settingBody.styl
+++ b/client/components/settings/settingBody.styl
@@ -61,10 +61,11 @@
.is-checked
border-bottom: 2px solid #2980b9;
border-right: 2px solid #2980b9;
-
- span
+
+ span
padding: 0 0.5rem
-
+
+ .admin-announcement,
.invite-people
padding-left 20px;
li