mirror of
https://github.com/wekan/wekan.git
synced 2025-12-29 05:38:48 +01:00
Implement option to change the first day of week in user settings
Implements #2535.
This commit is contained in:
parent
3ac5dba243
commit
8e14459cff
7 changed files with 95 additions and 2 deletions
|
|
@ -135,6 +135,10 @@ $popupWidth = 300px
|
||||||
margin-bottom: 8px
|
margin-bottom: 8px
|
||||||
|
|
||||||
.pop-over-list
|
.pop-over-list
|
||||||
|
li
|
||||||
|
display: block
|
||||||
|
clear: both
|
||||||
|
|
||||||
li > a
|
li > a
|
||||||
clear: both
|
clear: both
|
||||||
cursor: pointer
|
cursor: pointer
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,17 @@ template(name="changeSettingsPopup")
|
||||||
| {{_ 'show-cards-minimum-count'}}
|
| {{_ 'show-cards-minimum-count'}}
|
||||||
input#show-cards-count-at.inline-input.left(type="number" value="#{showCardsCountAt}" min="0" max="99" onkeydown="return false")
|
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'}}")
|
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")
|
template(name="userDeletePopup")
|
||||||
unless currentUser.isWorker
|
unless currentUser.isWorker
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,27 @@ Template.changeSettingsPopup.helpers({
|
||||||
return cookies.get('limitToShowCardsCount');
|
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({
|
Template.changeSettingsPopup.events({
|
||||||
|
|
@ -263,4 +284,20 @@ Template.changeSettingsPopup.events({
|
||||||
Popup.back();
|
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();
|
||||||
|
}
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,22 @@ DatePicker = BlazeComponent.extendComponent({
|
||||||
this.defaultTime = defaultTime;
|
this.defaultTime = defaultTime;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startDayOfWeek() {
|
||||||
|
const currentUser = Meteor.user();
|
||||||
|
if (currentUser) {
|
||||||
|
return currentUser.getStartDayOfWeek();
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onRendered() {
|
onRendered() {
|
||||||
const $picker = this.$('.js-datepicker')
|
const $picker = this.$('.js-datepicker')
|
||||||
.datepicker({
|
.datepicker({
|
||||||
todayHighlight: true,
|
todayHighlight: true,
|
||||||
todayBtn: 'linked',
|
todayBtn: 'linked',
|
||||||
language: TAPi18n.getLanguage(),
|
language: TAPi18n.getLanguage(),
|
||||||
weekStart: 1,
|
weekStart: this.startDayOfWeek(),
|
||||||
})
|
})
|
||||||
.on(
|
.on(
|
||||||
'changeDate',
|
'changeDate',
|
||||||
|
|
|
||||||
|
|
@ -777,5 +777,13 @@
|
||||||
"mark-all-as-read": "Mark all as read",
|
"mark-all-as-read": "Mark all as read",
|
||||||
"remove-all-read": "Remove all read",
|
"remove-all-read": "Remove all read",
|
||||||
"allow-rename": "Allow Rename",
|
"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"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,13 @@ Users.attachSchema(
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
'profile.startDayOfWeek': {
|
||||||
|
/**
|
||||||
|
* startDayOfWeek field of the user
|
||||||
|
*/
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
'profile.starredBoards': {
|
'profile.starredBoards': {
|
||||||
/**
|
/**
|
||||||
* list of starred board IDs
|
* list of starred board IDs
|
||||||
|
|
@ -521,6 +528,11 @@ Users.helpers({
|
||||||
return profile.language || 'en';
|
return profile.language || 'en';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getStartDayOfWeek() {
|
||||||
|
const profile = this.profile || {};
|
||||||
|
return profile.startDayOfWeek || 1;
|
||||||
|
},
|
||||||
|
|
||||||
getTemplatesBoardId() {
|
getTemplatesBoardId() {
|
||||||
return (this.profile || {}).templatesBoardId;
|
return (this.profile || {}).templatesBoardId;
|
||||||
},
|
},
|
||||||
|
|
@ -652,6 +664,10 @@ Users.mutations({
|
||||||
return { $set: { 'profile.showCardsCountAt': limit } };
|
return { $set: { 'profile.showCardsCountAt': limit } };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setStartDayOfWeek(startDay) {
|
||||||
|
return { $set: { 'profile.startDayOfWeek': startDay } };
|
||||||
|
},
|
||||||
|
|
||||||
setBoardView(view) {
|
setBoardView(view) {
|
||||||
return {
|
return {
|
||||||
$set: {
|
$set: {
|
||||||
|
|
@ -682,6 +698,10 @@ Meteor.methods({
|
||||||
check(limit, Number);
|
check(limit, Number);
|
||||||
Meteor.user().setShowCardsCountAt(limit);
|
Meteor.user().setShowCardsCountAt(limit);
|
||||||
},
|
},
|
||||||
|
changeStartDayOfWeek(startDay) {
|
||||||
|
check(startDay, Number);
|
||||||
|
Meteor.user().setStartDayOfWeek(startDay);
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
|
|
|
||||||
|
|
@ -2544,6 +2544,10 @@ definitions:
|
||||||
description: |
|
description: |
|
||||||
showCardCountAt field of the user
|
showCardCountAt field of the user
|
||||||
type: number
|
type: number
|
||||||
|
startDayOfWeek:
|
||||||
|
description: |
|
||||||
|
startDayOfWeek field of the user
|
||||||
|
type: number
|
||||||
starredBoards:
|
starredBoards:
|
||||||
description: |
|
description: |
|
||||||
list of starred board IDs
|
list of starred board IDs
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue