Compare commits

...

2 Commits

Author SHA1 Message Date
philipp lang 868dc5cf02 Add description for condition blocks
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2024-04-25 22:49:07 +02:00
philipp lang 38ac195924 Add simple wrapper content for condition 2024-04-25 22:37:46 +02:00
1 changed files with 49 additions and 12 deletions

View File

@ -107,8 +107,20 @@ class ConditionTune {
wrap(blockContent) { wrap(blockContent) {
this.wrapper = document.createElement('div'); this.wrapper = document.createElement('div');
this.wrapper.appendChild(blockContent);
var tooltip = document.createElement('div');
tooltip.setAttribute('data-tooltip', '');
var content = document.createElement('div');
content.setAttribute('data-content', '');
content.appendChild(blockContent);
this.wrapper.appendChild(tooltip);
this.wrapper.appendChild(content);
this.styleWrapper(); this.styleWrapper();
return this.wrapper; return this.wrapper;
} }
@ -118,21 +130,46 @@ class ConditionTune {
styleWrapper() { styleWrapper() {
if (this.hasData()) { if (this.hasData()) {
this.wrapper.className = 'relative mt-6 mb-6 p-1 border border-blue-200 rounded'; this.wrapper.querySelector('[data-content]').className = 'p-1 border border-blue-100 rounded';
if (!this.wrapper.querySelector('.condition-description')) { this.wrapper.querySelector('[data-tooltip]').className =
var tooltip = document.createElement('div'); 'inline-block tracking-wider font-semibold ml-2 px-2 py-1 items-center text-xs leading-none bg-blue-100 text-blue-900 rounded-t-lg';
tooltip.className = 'condition-description absolute top-0 left-0 -mt-4 ml-1 h-4 flex px-2 items-center text-xs leading-none bg-blue-200 text-blue-900 rounded-t-lg'; this.wrapper.querySelector('[data-tooltip]').innerHTML = this.descriptionName();
tooltip.innerHTML = 'Bedingung';
this.wrapper.appendChild(tooltip);
}
} else { } else {
this.wrapper.className = ''; this.wrapper.querySelector('[data-content]').className = '';
if (this.wrapper.querySelector('.condition-description')) { this.wrapper.querySelector('[data-tooltip]').className = '';
this.wrapper.removeChild(this.wrapper.querySelector('.condition-description')); this.wrapper.querySelector('[data-tooltip]').innerHTML = '';
}
} }
} }
descriptionName() {
return (
'Bedingung ' +
this.data.ifs
.map((i) => {
var parts = [i.field];
if (i.comparator === 'isEqual' || i.comparator === 'isIn') {
parts.push('=');
}
if (i.comparator === 'isNotEqual' || i.comparator === 'isNotIn') {
parts.push('≠');
}
if (typeof i.value === 'string') {
parts.push(i.value);
}
if (Array.isArray(i.value)) {
parts.push(i.value.join(', '));
}
return parts.join(' ');
})
.join(', ')
);
}
render() { render() {
return { return {
label: 'Bedingungen', label: 'Bedingungen',