allow to pre-define colors to choose from (#2481)

This commit is contained in:
Kevin Papst
2021-04-06 00:45:54 +02:00
committed by GitHub
parent f4dbdbb427
commit 68bb01d064
28 changed files with 574 additions and 21 deletions

View File

@@ -109,7 +109,19 @@ export default class KimaiFormSelect extends KimaiPlugin {
theme: "bootstrap",
matcher: matcher
}};
jQuery(selector + ' ' + elementSelector).select2(options);
const templateResultFunc = function (state) {
console.log(state);
return jQuery('<span><span style="background-color:'+state.id+'; width: 20px; height: 20px; display: inline-block; margin-right: 10px;">&nbsp;</span>' + state.text + '</span>');
};
let optionsColor = {...options, ...{
templateSelection: templateResultFunc,
templateResult: templateResultFunc
}};
jQuery(selector + ' ' + elementSelector + ':not([data-renderer=color])').select2(options);
jQuery(selector + ' ' + elementSelector + '[data-renderer=color]').select2(optionsColor);
jQuery('body').on('reset', 'form', function(event){
setTimeout(function() {