(js) Add sg-category-stylesheet directive

Fixes #3816
pull/222/head
Francis Lachapelle 2016-09-28 12:02:49 -04:00
parent f0a0da28ae
commit 3a61903e7f
2 changed files with 45 additions and 1 deletions

View File

@ -27,7 +27,7 @@
<sg-folder-stylesheet
ng-repeat="calendar in app.service.$findAll()"
ng-model="calendar"><!-- stylesheet --></sg-folder-stylesheet>
<!-- calendars colors -->
<!-- categories colors -->
<sg-category-stylesheet
ng-repeat="category in app.categories"
ng-model="category"><!-- stylesheet --></sg-category-stylesheet>

View File

@ -0,0 +1,44 @@
/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
(function() {
/* jshint validthis: true */
'use strict';
/*
* sgCategoryStylesheet - Add CSS stylesheet for a category's color
* @memberof SOGo.SchedulerUI
* @restrict attribute
* @param {object} ngModel - the object literal describing the category
* @example:
<sg-category-stylesheet
ng-repeat="category in categories"
ng-model="category" />
*/
function sgCategoryStylesheet() {
return {
restrict: 'E',
require: 'ngModel',
scope: {
ngModel: '='
},
replace: true,
template: [
'<style type="text/css">',
/* Background color */
' .bg-category{{ ngModel.id }} {',
' background-color: {{ ngModel.color }} !important;',
' }',
/* Border color */
' .bdr-category{{ ngModel.id }} {',
' border-color: {{ ngModel.color }} !important;',
' }',
'</style>'
].join('')
};
}
angular
.module('SOGo.SchedulerUI')
.directive('sgCategoryStylesheet', sgCategoryStylesheet);
})();