Compare commits

...

6 commits

Author SHA1 Message Date
DianaXWiki
479ff02b59 Add translation key #1371 2024-08-09 17:41:00 +03:00
DianaXWiki
0911413604 Add toggle visibility button for calendars on small screens #1371 2024-08-09 17:37:33 +03:00
DianaXWiki
4ff5f0f94b Enable toggle in and out of calendars #1371 2024-08-04 00:53:47 +03:00
David Benque
ca8e58b34a
Merge branch 'main' into staging 2024-07-25 15:24:01 +01:00
yflory
5b08caede2 Merge branch '2024.6.1' into staging 2024-07-24 15:26:11 +02:00
David Benque
11cf84a985 Update linter rules
Prevent line break errors on Windows
2024-07-18 15:42:56 +01:00
4 changed files with 79 additions and 31 deletions

View file

@ -35,7 +35,7 @@ module.exports = {
4 4
], ],
'linebreak-style': [ 'linebreak-style': [
'error', 'off', // git handles linebreak conversion for us
'unix' 'unix'
], ],
'quotes': [ 'quotes': [

View file

@ -135,7 +135,7 @@ define(req, function(AppConfig, Default, Language) {
return text; return text;
} }
}; };
Messages.calendar_show = 'Show calendars'; // XXX
return Messages; return Messages;
}); });

View file

@ -585,6 +585,18 @@
margin-top: 30px; margin-top: 30px;
} }
} }
@media screen and (max-width: @browser_media-medium-screen) {
.cp-calendar-entries {
display: none;
}
.cp-calendar-entries.visible {
display: block;
}
}
.cp-calendar-entries {
margin-bottom: 10px;
}
.cp-calendar-entry { .cp-calendar-entry {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -818,7 +818,17 @@ define([
}); });
} }
if (APP.$calendars) { APP.$calendars.append(calendar); } if (APP.$calendars) { APP.$calendars.append(calendar); }
return calendar; return $calendar; // return jQuery element
};
var appendCalendarEntries = function (teamId, filter) {
var calendars = filter(teamId);
var $entriesContainer = $('<div class="cp-calendar-entries"></div>');
calendars.forEach(function (id) {
var calendarEntry = makeCalendarEntry(id, teamId);
$entriesContainer.append(calendarEntry);
});
return $entriesContainer;
}; };
var makeLeftside = function (calendar, $container) { var makeLeftside = function (calendar, $container) {
// Show calendars // Show calendars
@ -847,10 +857,10 @@ define([
}; };
var tempCalendars = filter(0); var tempCalendars = filter(0);
if (tempCalendars.length && tempCalendars[0] === APP.currentCalendar) { if (tempCalendars.length && tempCalendars[0] === APP.currentCalendar) {
APP.$calendars.append(h('div.cp-calendar-team', [ var $tempCalendarTeam = $(h('div.cp-calendar-team', [
h('span', Messages.calendar_tempCalendar) h('span', Messages.calendar_tempCalendar)
])); ])).appendTo(APP.$calendars);
makeCalendarEntry(tempCalendars[0], 0); var $tempCalendarEntries = appendCalendarEntries(0, filter).appendTo(APP.$calendars);
var importTemp = h('button', [ var importTemp = h('button', [
h('i.fa.fa-calendar-plus-o'), h('i.fa.fa-calendar-plus-o'),
h('span', Messages.calendar_import_temp), h('span', Messages.calendar_import_temp),
@ -868,7 +878,7 @@ define([
}); });
}); });
if (APP.loggedIn) { if (APP.loggedIn) {
APP.$calendars.append(h('div.cp-calendar-entry.cp-ghost', importTemp)); $tempCalendarEntries.append(h('div.cp-calendar-entry.cp-ghost', importTemp));
} }
return; return;
} }
@ -878,27 +888,29 @@ define([
var avatar = h('span.cp-avatar'); var avatar = h('span.cp-avatar');
var uid = user.uid; var uid = user.uid;
var name = user.name || Messages.anonymous; var name = user.name || Messages.anonymous;
common.displayAvatar($(avatar), user.avatar, name, function(){}, uid); common.displayAvatar($(avatar), user.avatar, name, function () { }, uid);
APP.$calendars.append(h('div.cp-calendar-team', [ APP.$calendars.append(h('div.cp-calendar-team', [
avatar, avatar,
h('span.cp-name', {title: name}, name) h('span.cp-name', {title: name}, name)
])); ]));
if (window.innerWidth <= 600) {
var $showCalendarsContainer = $('<div class="cp-calendar-entry cp-ghost"></div>').appendTo($calendars);
var showCalendarsBtn = h('button.cp-calendar-showcalendars', [
h('i.fa.fa-eye'),
h('span', Messages.calendar_show),
h('span')
]);
var $myCalendarEntries = appendCalendarEntries(1, filter).appendTo(APP.$calendars);
$(showCalendarsBtn).click(function (e) {
e.preventDefault();
$myCalendarEntries.toggleClass('visible');
}).appendTo($showCalendarsContainer);
} else {
myCalendars.forEach(function (id) {
makeCalendarEntry(id, 1);
});
}
} }
myCalendars.forEach(function (id) {
makeCalendarEntry(id, 1);
});
// Add new button
var $newContainer = $(h('div.cp-calendar-entry.cp-ghost')).appendTo($calendars);
var newButton = h('button', [
h('i.fa.fa-calendar-plus-o'),
h('span', Messages.calendar_new),
h('span')
]);
$(newButton).click(function () {
editCalendar();
}).appendTo($newContainer);
Object.keys(privateData.teams).sort().forEach(function (teamId) { Object.keys(privateData.teams).sort().forEach(function (teamId) {
var calendars = filter(teamId); var calendars = filter(teamId);
if (!calendars.length) { return; } if (!calendars.length) { return; }
@ -909,13 +921,39 @@ define([
avatar, avatar,
h('span.cp-name', {title: team.name}, team.name) h('span.cp-name', {title: team.name}, team.name)
])); ]));
calendars.forEach(function (id) { if (window.innerWidth <= 600) {
makeCalendarEntry(id, teamId); // Add show calendars button for each team
}); var $showCalendarsContainer = $('<div class="cp-calendar-entry cp-ghost"></div>').appendTo($calendars);
}); var showCalendarsBtn = h('button.cp-calendar-showcalendars', [
}); h('i.fa.fa-eye'),
onCalendarsUpdate.fire(); h('span', Messages.calendar_show),
h('span')
]);
var $teamCalendarEntries = appendCalendarEntries(teamId, filter).appendTo(APP.$calendars);
$(showCalendarsBtn).click(function (e) {
e.preventDefault();
$teamCalendarEntries.toggleClass('visible');
}).appendTo($showCalendarsContainer);
} else {
calendars.forEach(function (id) {
makeCalendarEntry(id, 1);
});
}
});
// Add new button
var $newContainer = $('<div class="cp-calendar-entry cp-ghost"></div>').appendTo($calendars);
var newButton = h('button', [
h('i.fa.fa-calendar-plus-o'),
h('span', Messages.calendar_new),
h('span')
]);
$(newButton).click(function () {
editCalendar();
}).appendTo($newContainer);
});
onCalendarsUpdate.fire();
}; };
var _updateRecurring = function () { var _updateRecurring = function () {
@ -1275,7 +1313,6 @@ ICS ==> create a new event with the same UID and a RECURRENCE-ID field (with a v
store.put('calendarView', mode, function () {}); store.put('calendarView', mode, function () {});
}); });
APP.toolbar.$bottomR.append($block); APP.toolbar.$bottomR.append($block);
// New event button // New event button
var newEventBtn = h('button.cp-calendar-newevent', [ var newEventBtn = h('button.cp-calendar-newevent', [
h('i.fa.fa-plus'), h('i.fa.fa-plus'),
@ -1285,7 +1322,6 @@ ICS ==> create a new event with the same UID and a RECURRENCE-ID field (with a v
e.preventDefault(); e.preventDefault();
cal.openCreationPopup({isAllDay:false}); cal.openCreationPopup({isAllDay:false});
}).appendTo(APP.toolbar.$bottomL); }).appendTo(APP.toolbar.$bottomL);
// Change page // Change page
var goLeft = h('button.fa.fa-chevron-left',{'aria-label': Messages.goLeft}); var goLeft = h('button.fa.fa-chevron-left',{'aria-label': Messages.goLeft});
var goRight = h('button.fa.fa-chevron-right', {'aria-label': Messages.goRight}); var goRight = h('button.fa.fa-chevron-right', {'aria-label': Messages.goRight});