Skip to content

Commit

Permalink
#25 add button to show hide all calendars
Browse files Browse the repository at this point in the history
  • Loading branch information
asmaNode committed Dec 23, 2021
1 parent cd5ff55 commit d5e052f
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ require('../app.constants.js');
return {
getHiddenCalendars: getHiddenCalendars,
isHidden: isHidden,
toggle: toggle
toggle: toggle,
showCalendarHideOthers
};

////////////
Expand All @@ -23,6 +24,23 @@ require('../app.constants.js');
});
}

function showCalendarHideOthers(calendarToShow, calendarsToHide) {

$rootScope.$broadcast(CAL_EVENTS.CALENDARS.TOGGLE_VIEW, {
calendarUniqueId: calendarToShow,
hidden: false
});

calendarsToHide.forEach(function(calendar) {
const calId = calendar.getUniqueId();

$rootScope.$broadcast(CAL_EVENTS.CALENDARS.TOGGLE_VIEW, {
calendarUniqueId: calId,
hidden: true
});
});
}

function toggle(calendar) {
var calId = calendar.getUniqueId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const _ = require('lodash');

self.$onInit = $onInit;
self.activate = activate;

////////////

function $onInit() {
Expand All @@ -30,7 +29,7 @@ const _ = require('lodash');
self.sharedCalendars = [];
self.hiddenCalendars = {};
self.toggleCalendar = calendarVisibilityService.toggle;

self.selectAllCalendars = selectAllCalendars;
self.activate();
}

Expand All @@ -52,6 +51,14 @@ const _ = require('lodash');
});
}

function selectAllCalendars() {
const calendars = userAndExternalCalendars(self.calendars);

calendars.userCalendars.forEach(function(calendar) {
calendarVisibilityService.toggle(calendar);
});
}

function listCalendars() {
return calendarService.listPersonalAndAcceptedDelegationCalendars(session.user._id).then(function(calendars) {
self.calendars = _.clone(calendars);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
cal-user-calendars-list(
user-calendars="$ctrl.userCalendars",
toggle-calendar="$ctrl.toggleCalendar",
hidden-calendars="$ctrl.hiddenCalendars"
hidden-calendars="$ctrl.hiddenCalendars",
select-all-calendars="$ctrl.selectAllCalendars"

)

cal-external-calendars-list(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.lv-item.calendar-item.calendar-header-title.hidden-md
.media
.pull-left
i.mdi.mdi-calendar
i.mdi.mdi-checkbox-blank-circle.all-calendars-selected
.media-body
.lv-title {{ 'Shared calendars' | translate }}
.lv-item.calendar-item.calendar-header-title-desktop.visible-md.clickable.toggle-submenu.waves-classic(esn-toggle)
Expand All @@ -11,7 +11,7 @@
.caret-submenu
i.mdi.mdi-menu-down
.calendar-item-left
i.mdi.mdi-calendar
i.mdi.mdi-checkbox-blank-circle.all-calendars-selected(ng-click="$ctrl.selectAllCalendars()")
.media-body
.lv-title {{ 'Shared calendars' | translate }}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,22 @@
angular.module('esn.calendar')
.controller('CalendarsListItemConfigurationController', CalendarsListItemConfigurationController);

function CalendarsListItemConfigurationController($state) {
function CalendarsListItemConfigurationController($state, calendarVisibilityService) {
var self = this;

self.$onInit = $onInit;

function $onInit() {
self.onOptionClick = onOptionClick;
self.showAndHide = showAndHide;
}

function onOptionClick() {
$state.go('calendar.main.edit', { calendarUniqueId: self.calendarId });
}

function showAndHide() {
calendarVisibilityService.showCalendarHideOthers(self.calendarId);
}
}
})(angular);
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
md-menu-item
md-button(ng-click="$ctrl.onOptionClick()")
md-icon(md-menu-origin, md-svg-icon="settings", aria-label="settings open Icon")
| {{ 'Settings' | translate }}
| {{ 'Settings' | translate }}
md-menu-item
md-button(ng-click="$ctrl.showAndHide()")
md-icon(md-menu-origin, md-svg-icon="eye", aria-label="show calendar Icon")
| {{ 'Show only this calendar' | translate }}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
bindings: {
userCalendars: '=',
toggleCalendar: '=',
hiddenCalendars: '='
hiddenCalendars: '=',
selectAllCalendars: '='
}
});
})(angular);
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
.lv-item.calendar-item.calendar-header-title.hidden-md
.media
.pull-left
i.mdi.mdi-calendar
i.mdi.mdi-checkbox-blank-circle.all-calendars-selected
.media-body
.lv-title {{ 'My calendars' | translate }}
.lv-item.calendar-item.calendar-header-title-desktop.visible-md.clickable.toggle-submenu.waves-classic(esn-toggle)
.lv-item.calendar-item.calendar-header-title-desktop.visible-md.clickable.toggle-submenu.waves-classic
.media
.badge-container
.caret-submenu
i.mdi.mdi-menu-down
.calendar-item-left
i.mdi.mdi-calendar
i.mdi.mdi-checkbox-blank-circle.all-calendars-selected(ng-click="$ctrl.selectAllCalendars()")
.media-body
.lv-title {{ 'My calendars' | translate }}

Expand Down

0 comments on commit d5e052f

Please sign in to comment.