Implement data widget property

Fixes missing priority colors in Kanban
This commit is contained in:
nathan 2022-11-23 10:30:22 -07:00
parent bfc9588739
commit b31ce0922d

View File

@ -186,6 +186,15 @@ const Et2WidgetMixin = <T extends Constructor>(superClass : T) =>
align: {
type: String,
reflect: true
},
/**
* comma-separated name:value pairs set as data attributes on DOM node
* data="mime:${row}[mime]" would generate data-mime="..." in DOM, eg. to use it in CSS on a parent
*/
data: {
type: String,
reflect: false
}
};
}
@ -371,6 +380,40 @@ const Et2WidgetMixin = <T extends Constructor>(superClass : T) =>
return this._widget_id;
}
/**
* Set the dataset from a CSV
* @param {string} value
*/
set data(value : string)
{
// Clear existing
Object.keys(this.dataset).forEach(dataKey =>
{
delete this.dataset[dataKey];
});
let data = value.split(",");
data.forEach((field) =>
{
let f = field.split(":");
if(f[0] && typeof f[1] !== "undefined")
{
this.dataset[f[0]] = f[1];
}
});
}
get data() : string
{
let data = [];
Object.keys(this.dataset).forEach((k) =>
{
data.push(k + ":" + this.dataset[k]);
})
return data.join(",");
}
/**
* A property has changed, and we want to make adjustments to other things
* based on that