Merge pull request #5652 from NadavTasher/feature/toggle-week-of-year-display

Feature - Add toggle for week-of-year in date displays (ISO 8601)
This commit is contained in:
Lauri Ojansivu 2025-01-02 12:07:23 +02:00 committed by GitHub
commit 3322d3b33d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 64 additions and 14 deletions

View file

@ -79,11 +79,12 @@ template(name="cardCustomField-currency")
template(name="cardCustomField-date") template(name="cardCustomField-date")
if canModifyCard if canModifyCard
a.js-edit-date(title="{{showTitle}} {{_ 'predicate-week'}} {{showWeek}}" class="{{classes}}") a.js-edit-date(title="{{showTitle}} {{_ 'predicate-week'}} {{#if showWeekOfYear}}{{showWeek}}{{/if}}" class="{{classes}}")
if value if value
div.card-date div.card-date
time(datetime="{{showISODate}}") time(datetime="{{showISODate}}")
| {{showDate}} | {{showDate}}
if showWeekOfYear
b b
| {{showWeek}} | {{showWeek}}
else else
@ -93,6 +94,7 @@ template(name="cardCustomField-date")
div.card-date div.card-date
time(datetime="{{showISODate}}") time(datetime="{{showISODate}}")
| {{showDate}} | {{showDate}}
if showWeekOfYear
b b
| {{showWeek}} | {{showWeek}}

View file

@ -148,6 +148,10 @@ CardCustomField.register('cardCustomField');
return this.date.get().week().toString(); return this.date.get().week().toString();
} }
showWeekOfYear() {
return ReactiveCache.getCurrentUser().isShowWeekOfYear();
}
showDate() { showDate() {
// this will start working once mquandalle:moment // this will start working once mquandalle:moment
// is updated to at least moment.js 2.10.5 // is updated to at least moment.js 2.10.5

View file

@ -1,20 +1,23 @@
template(name="dateBadge") template(name="dateBadge")
if canModifyCard if canModifyCard
a.js-edit-date.card-date(title="{{showTitle}} {{_ 'predicate-week'}} {{showWeek}}" class="{{classes}}") a.js-edit-date.card-date(title="{{showTitle}} {{_ 'predicate-week'}} {{#if showWeekOfYear}}{{showWeek}}{{/if}}" class="{{classes}}")
time(datetime="{{showISODate}}") time(datetime="{{showISODate}}")
| {{showDate}} | {{showDate}}
if showWeekOfYear
b b
| {{showWeek}} | {{showWeek}}
else else
a.card-date(title="{{showTitle}} {{_ 'predicate-week'}} {{showWeek}}" class="{{classes}}") a.card-date(title="{{showTitle}} {{_ 'predicate-week'}} {{#if showWeekOfYear}}{{showWeek}}{{/if}}" class="{{classes}}")
time(datetime="{{showISODate}}") time(datetime="{{showISODate}}")
| {{showDate}} | {{showDate}}
if showWeekOfYear
b b
| {{showWeek}} | {{showWeek}}
template(name="dateCustomField") template(name="dateCustomField")
a(title="{{showTitle}} {{_ 'predicate-week'}} {{showWeek}}" class="{{classes}}") a(title="{{showTitle}} {{_ 'predicate-week'}} {{#if showWeekOfYear}}{{showWeek}}{{/if}}" class="{{classes}}")
time(datetime="{{showISODate}}") time(datetime="{{showISODate}}")
| {{showDate}} | {{showDate}}
if showWeekOfYear
b b
| {{showWeek}} | {{showWeek}}

View file

@ -110,6 +110,10 @@ const CardDate = BlazeComponent.extendComponent({
return this.date.get().week().toString(); return this.date.get().week().toString();
}, },
showWeekOfYear() {
return ReactiveCache.getCurrentUser().isShowWeekOfYear();
},
showDate() { showDate() {
// this will start working once mquandalle:moment // this will start working once mquandalle:moment
// is updated to at least moment.js 2.10.5 // is updated to at least moment.js 2.10.5
@ -283,6 +287,10 @@ class CardCustomFieldDate extends CardDate {
return this.date.get().week().toString(); return this.date.get().week().toString();
} }
showWeekOfYear() {
return ReactiveCache.getCurrentUser().isShowWeekOfYear();
}
showDate() { showDate() {
// this will start working once mquandalle:moment // this will start working once mquandalle:moment
// is updated to at least moment.js 2.10.5 // is updated to at least moment.js 2.10.5

View file

@ -39,6 +39,11 @@ template(name='homeSidebar')
span {{_ 'enable-vertical-scrollbars'}} span {{_ 'enable-vertical-scrollbars'}}
b   b  
.materialCheckBox(class="{{#if isVerticalScrollbars}}is-checked{{/if}}") .materialCheckBox(class="{{#if isVerticalScrollbars}}is-checked{{/if}}")
ul#cards.show-week-of-year-toggle
a.flex.js-show-week-of-year-toggle(title="{{_ 'show-week-of-year'}}")
span {{_ 'show-week-of-year'}}
b  
.materialCheckBox(class="{{#if isShowWeekOfYear}}is-checked{{/if}}")
hr hr
unless currentUser.isNoComments unless currentUser.isNoComments
h3.activity-title h3.activity-title

View file

@ -142,6 +142,9 @@ BlazeComponent.extendComponent({
'click .js-vertical-scrollbars-toggle'() { 'click .js-vertical-scrollbars-toggle'() {
ReactiveCache.getCurrentUser().toggleVerticalScrollbars(); ReactiveCache.getCurrentUser().toggleVerticalScrollbars();
}, },
'click .js-show-week-of-year-toggle'() {
ReactiveCache.getCurrentUser().toggleShowWeekOfYear();
},
'click .js-close-sidebar'() { 'click .js-close-sidebar'() {
Sidebar.toggle() Sidebar.toggle()
}, },
@ -167,6 +170,10 @@ BlazeComponent.extendComponent({
const user = ReactiveCache.getCurrentUser(); const user = ReactiveCache.getCurrentUser();
return user && user.isVerticalScrollbars(); return user && user.isVerticalScrollbars();
}, },
isShowWeekOfYear() {
const user = ReactiveCache.getCurrentUser();
return user && user.isShowWeekOfYear();
},
showActivities() { showActivities() {
let ret = Utils.getCurrentBoard().showActivities ?? false; let ret = Utils.getCurrentBoard().showActivities ?? false;
return ret; return ret;

View file

@ -1257,6 +1257,7 @@
"text": "Text", "text": "Text",
"translation-text": "Translation text", "translation-text": "Translation text",
"show-subtasks-field": "Show subtasks field", "show-subtasks-field": "Show subtasks field",
"show-week-of-year": "Show week of year (ISO 8601)",
"convert-to-markdown": "Convert to markdown", "convert-to-markdown": "Convert to markdown",
"import-board-zip": "Add .zip file that has board JSON files, and board name subdirectories with attachments", "import-board-zip": "Add .zip file that has board JSON files, and board name subdirectories with attachments",
"collapse": "Collapse", "collapse": "Collapse",

View file

@ -458,6 +458,13 @@ Users.attachSchema(
type: Boolean, type: Boolean,
defaultValue: true, defaultValue: true,
}, },
'profile.showWeekOfYear': {
/**
* User-specified state of week-of-year in date displays.
*/
type: Boolean,
defaultValue: true,
},
services: { services: {
/** /**
* services field of the user * services field of the user
@ -978,6 +985,11 @@ Users.helpers({
return verticalScrollbars; return verticalScrollbars;
}, },
isShowWeekOfYear() {
const { showWeekOfYear = true } = this.profile || {};
return showWeekOfYear;
},
remove() { remove() {
User.remove({ User.remove({
_id: this._id, _id: this._id,
@ -1058,6 +1070,14 @@ Users.mutations({
}, },
}; };
}, },
toggleShowWeekOfYear() {
const { showWeekOfYear = true } = this.profile || {};
return {
$set: {
'profile.showWeekOfYear': !showWeekOfYear,
},
};
},
addInvite(boardId) { addInvite(boardId) {
return { return {