diff --git a/app/assets/javascripts/controllers/admin/calendar.js.erb b/app/assets/javascripts/controllers/admin/calendar.js.erb index 5b7979642..569d7a35d 100644 --- a/app/assets/javascripts/controllers/admin/calendar.js.erb +++ b/app/assets/javascripts/controllers/admin/calendar.js.erb @@ -755,3 +755,57 @@ Application.Controllers.controller('DeleteRecurrentAvailabilityController', ['$s } } ]); + + + +/** + * Controller used in the iCalendar (ICS) imports management page + */ + +Application.Controllers.controller('AdminICalendarController', ['$scope', + function ($scope) { + // list of ICS sources + $scope.calendars = []; + + // configuration of a new ICS source + $scope.newCalendar = { + color: undefined, + textColor: undefined, + url: undefined, + textHidden: false + }; + + /** + * Save the new iCalendar in database + */ + $scope.save = function () { + $scope.calendars.push(Object.assign({}, $scope.newCalendar)); + $scope.newCalendar.url = undefined; + $scope.newCalendar.color = null; + $scope.newCalendar.textColor = null; + $scope.newCalendar.textHidden = false; + } + + /** + * Return a CSS-like style of the given calendar configuration + * @param calendar + */ + $scope.calendarStyle = function (calendar) { + return { + 'border-color': calendar.color, + 'color': calendar.textColor, + 'width': calendar.textHidden ? '50px' : 'auto', + 'height': calendar.textHidden ? '21px' : 'auto' + }; + } + + /** + * Delete the given calendar from the database + * @param calendar + */ + $scope.delete = function (calendar) { + const idx = $scope.calendars.indexOf(calendar); + $scope.calendars.splice(idx, 1); + } + } +]); diff --git a/app/assets/javascripts/controllers/calendar.js b/app/assets/javascripts/controllers/calendar.js index 43f0542a3..e46eb8db1 100644 --- a/app/assets/javascripts/controllers/calendar.js +++ b/app/assets/javascripts/controllers/calendar.js @@ -170,7 +170,7 @@ Application.Controllers.controller('CalendarController', ['$scope', '$state', '$ }; const eventRenderCb = function (event, element) { - if (event.tags.length > 0) { + if (event.tags && event.tags.length > 0) { let html = ''; for (let tag of Array.from(event.tags)) { html += `${tag.name} `; diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb index 12cad9d20..f0476c79c 100644 --- a/app/assets/javascripts/router.js.erb +++ b/app/assets/javascripts/router.js.erb @@ -659,6 +659,18 @@ angular.module('application.router', ['ui.router']) translations: ['Translations', function (Translations) { return Translations.query('app.admin.calendar').$promise; }] } }) + .state('app.admin.calendar.icalendar', { + url: '/admin/calendar/icalendar', + views: { + 'main@': { + templateUrl: '<%= asset_path "admin/calendar/icalendar.html" %>', + controller: 'AdminICalendarController' + } + }, + resolve: { + translations: ['Translations', function (Translations) { return Translations.query('app.admin.icalendar').$promise; }] + } + }) // project's elements .state('app.admin.project_elements', { diff --git a/app/assets/stylesheets/app.components.scss b/app/assets/stylesheets/app.components.scss index 6a1659507..e550aa8ea 100644 --- a/app/assets/stylesheets/app.components.scss +++ b/app/assets/stylesheets/app.components.scss @@ -670,5 +670,6 @@ padding: 10px; font-size: 10px; padding: 2px; margin-left: 10px; + display: inline-block; } } diff --git a/app/assets/stylesheets/app.utilities.scss b/app/assets/stylesheets/app.utilities.scss index 7b6349c1d..ad1d4241c 100644 --- a/app/assets/stylesheets/app.utilities.scss +++ b/app/assets/stylesheets/app.utilities.scss @@ -102,6 +102,7 @@ p, .widget p { .text-italic { font-style: italic; } +.text-left { text-align: left !important; } .text-center { text-align: center; } .text-right { text-align: right; } diff --git a/app/assets/stylesheets/application.scss.erb b/app/assets/stylesheets/application.scss.erb index ada57aaa4..b87230fd9 100644 --- a/app/assets/stylesheets/application.scss.erb +++ b/app/assets/stylesheets/application.scss.erb @@ -32,11 +32,7 @@ @import "app.buttons"; @import "app.components"; @import "app.plugins"; -@import "modules/invoice"; -@import "modules/signup"; -@import "modules/abuses"; -@import "modules/cookies"; -@import "modules/stripe"; +@import "modules/*"; @import "app.responsive"; diff --git a/app/assets/stylesheets/modules/icalendar.scss b/app/assets/stylesheets/modules/icalendar.scss new file mode 100644 index 000000000..a36dafa74 --- /dev/null +++ b/app/assets/stylesheets/modules/icalendar.scss @@ -0,0 +1,10 @@ +.calendar-form { + margin : 2em; + border: 1px solid #ddd; + border-radius: 3px; + padding: 1em; + + & > .input-group, & > .minicolors { + margin-top: 1em; + } +} diff --git a/app/assets/templates/admin/calendar/calendar.html.erb b/app/assets/templates/admin/calendar/calendar.html.erb index f1666a628..ef3345004 100644 --- a/app/assets/templates/admin/calendar/calendar.html.erb +++ b/app/assets/templates/admin/calendar/calendar.html.erb @@ -5,15 +5,17 @@ -