summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Hartmayer <hello@hartmayer.com>2020-04-22 14:44:08 +0200
committerMarc Hartmayer <hello@hartmayer.com>2020-04-22 19:16:05 +0200
commit8e14459cff4da1391f536dfbc6441abb21e9c215 (patch)
treec25c0eeb010635a9771754a067ab9c0f0d1c8997
parent3ac5dba243a9896adc5db6fdc586c8b1768f2df9 (diff)
downloadwekan-8e14459cff4da1391f536dfbc6441abb21e9c215.tar.gz
wekan-8e14459cff4da1391f536dfbc6441abb21e9c215.tar.bz2
wekan-8e14459cff4da1391f536dfbc6441abb21e9c215.zip
Implement option to change the first day of week in user settings
Implements #2535.
-rw-r--r--client/components/main/popup.styl4
-rw-r--r--client/components/users/userHeader.jade11
-rw-r--r--client/components/users/userHeader.js37
-rw-r--r--client/lib/datepicker.js11
-rw-r--r--i18n/en.i18n.json10
-rw-r--r--models/users.js20
-rw-r--r--public/api/wekan.yml4
7 files changed, 95 insertions, 2 deletions
diff --git a/client/components/main/popup.styl b/client/components/main/popup.styl
index 023cba3d..f1db3927 100644
--- a/client/components/main/popup.styl
+++ b/client/components/main/popup.styl
@@ -135,6 +135,10 @@ $popupWidth = 300px
margin-bottom: 8px
.pop-over-list
+ li
+ display: block
+ clear: both
+
li > a
clear: both
cursor: pointer
diff --git a/client/components/users/userHeader.jade b/client/components/users/userHeader.jade
index 1cd9da6b..3747d882 100644
--- a/client/components/users/userHeader.jade
+++ b/client/components/users/userHeader.jade
@@ -117,6 +117,17 @@ template(name="changeSettingsPopup")
| {{_ 'show-cards-minimum-count'}}
input#show-cards-count-at.inline-input.left(type="number" value="#{showCardsCountAt}" min="0" max="99" onkeydown="return false")
input.js-apply-show-cards-at.left(type="submit" value="{{_ 'apply'}}")
+ li
+ label.bold
+ i.fa.fa-calendar
+ | {{_ 'start-day-of-week'}}
+ select#start-day-of-week.inline-input.left
+ each day in weekDays startDayOfWeek
+ if day.isSelected
+ option(selected="true", value="#{day.value}") #{day.name}
+ else
+ option(value="#{day.value}") #{day.name}
+ input.js-apply-start-day-of-week.left(type="submit" value="{{_ 'apply'}}")
template(name="userDeletePopup")
unless currentUser.isWorker
diff --git a/client/components/users/userHeader.js b/client/components/users/userHeader.js
index cd315bd6..5298e99a 100644
--- a/client/components/users/userHeader.js
+++ b/client/components/users/userHeader.js
@@ -224,6 +224,27 @@ Template.changeSettingsPopup.helpers({
return cookies.get('limitToShowCardsCount');
}
},
+ weekDays(startDay) {
+ return [
+ TAPi18n.__('sunday'),
+ TAPi18n.__('monday'),
+ TAPi18n.__('tuesday'),
+ TAPi18n.__('wednesday'),
+ TAPi18n.__('thursday'),
+ TAPi18n.__('friday'),
+ TAPi18n.__('saturday'),
+ ].map(function(day, index) {
+ return { name: day, value: index, isSelected: index === startDay };
+ });
+ },
+ startDayOfWeek() {
+ currentUser = Meteor.user();
+ if (currentUser) {
+ return currentUser.getStartDayOfWeek();
+ } else {
+ return cookies.get('startDayOfWeek');
+ }
+ },
});
Template.changeSettingsPopup.events({
@@ -263,4 +284,20 @@ Template.changeSettingsPopup.events({
Popup.back();
}
},
+ 'click .js-apply-start-day-of-week'(event, templateInstance) {
+ event.preventDefault();
+ const startDay = parseInt(
+ templateInstance.$('#start-day-of-week').val(),
+ 10,
+ );
+ if (!isNaN(startDay)) {
+ currentUser = Meteor.user();
+ if (currentUser) {
+ Meteor.call('changeStartDayOfWeek', startDay);
+ } else {
+ cookies.set('startDayOfWeek', startDay);
+ }
+ Popup.back();
+ }
+ },
});
diff --git a/client/lib/datepicker.js b/client/lib/datepicker.js
index 1c02c2ff..aa05310c 100644
--- a/client/lib/datepicker.js
+++ b/client/lib/datepicker.js
@@ -10,13 +10,22 @@ DatePicker = BlazeComponent.extendComponent({
this.defaultTime = defaultTime;
},
+ startDayOfWeek() {
+ const currentUser = Meteor.user();
+ if (currentUser) {
+ return currentUser.getStartDayOfWeek();
+ } else {
+ return 1;
+ }
+ },
+
onRendered() {
const $picker = this.$('.js-datepicker')
.datepicker({
todayHighlight: true,
todayBtn: 'linked',
language: TAPi18n.getLanguage(),
- weekStart: 1,
+ weekStart: this.startDayOfWeek(),
})
.on(
'changeDate',
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index 18a0680b..864d60ce 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -777,5 +777,13 @@
"mark-all-as-read": "Mark all as read",
"remove-all-read": "Remove all read",
"allow-rename": "Allow Rename",
- "allowRenamePopup-title": "Allow Rename"
+ "allowRenamePopup-title": "Allow Rename",
+ "start-day-of-week": "Set day of the week start",
+ "monday": "Monday",
+ "tuesday": "Tuesday",
+ "wednesday": "Wednesday",
+ "thursday": "Thursday",
+ "friday": "Friday",
+ "saturday": "Saturday",
+ "sunday": "Sunday"
}
diff --git a/models/users.js b/models/users.js
index f4b7329a..f4f4f38e 100644
--- a/models/users.js
+++ b/models/users.js
@@ -190,6 +190,13 @@ Users.attachSchema(
type: Number,
optional: true,
},
+ 'profile.startDayOfWeek': {
+ /**
+ * startDayOfWeek field of the user
+ */
+ type: Number,
+ optional: true,
+ },
'profile.starredBoards': {
/**
* list of starred board IDs
@@ -521,6 +528,11 @@ Users.helpers({
return profile.language || 'en';
},
+ getStartDayOfWeek() {
+ const profile = this.profile || {};
+ return profile.startDayOfWeek || 1;
+ },
+
getTemplatesBoardId() {
return (this.profile || {}).templatesBoardId;
},
@@ -652,6 +664,10 @@ Users.mutations({
return { $set: { 'profile.showCardsCountAt': limit } };
},
+ setStartDayOfWeek(startDay) {
+ return { $set: { 'profile.startDayOfWeek': startDay } };
+ },
+
setBoardView(view) {
return {
$set: {
@@ -682,6 +698,10 @@ Meteor.methods({
check(limit, Number);
Meteor.user().setShowCardsCountAt(limit);
},
+ changeStartDayOfWeek(startDay) {
+ check(startDay, Number);
+ Meteor.user().setStartDayOfWeek(startDay);
+ },
});
if (Meteor.isServer) {
diff --git a/public/api/wekan.yml b/public/api/wekan.yml
index 6dccbe7f..8cd4acfa 100644
--- a/public/api/wekan.yml
+++ b/public/api/wekan.yml
@@ -2544,6 +2544,10 @@ definitions:
description: |
showCardCountAt field of the user
type: number
+ startDayOfWeek:
+ description: |
+ startDayOfWeek field of the user
+ type: number
starredBoards:
description: |
list of starred board IDs