2019-03-13 13:53:40 +01:00
|
|
|
class RowState {
|
|
|
|
constructor(selectedIds) {
|
|
|
|
this.selectedIds = selectedIds || [];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param {RowBase} rowObject
|
|
|
|
*/
|
|
|
|
applyState(rowObject) {
|
|
|
|
rowObject.isSelected = this.selectedIds.includes(rowObject.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-12 09:08:37 +01:00
|
|
|
class RowBase {
|
|
|
|
constructor(underlyingObject) {
|
|
|
|
this.underlyingObject = underlyingObject;
|
|
|
|
this.isInitialized = false;
|
2019-03-13 13:53:40 +01:00
|
|
|
this.isVisible = true;
|
|
|
|
this.isSelected = false;
|
2019-02-12 09:08:37 +01:00
|
|
|
}
|
|
|
|
|
2019-03-13 13:53:40 +01:00
|
|
|
|
2019-02-12 09:08:37 +01:00
|
|
|
thenInit() {
|
2019-03-13 13:53:40 +01:00
|
|
|
return this._thenInitImpl()
|
|
|
|
.then(() => {
|
|
|
|
this.isInitialized = true
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
_thenInitImpl() {
|
2019-02-12 09:08:37 +01:00
|
|
|
return Promise.resolve();
|
|
|
|
}
|
|
|
|
|
|
|
|
getName() {
|
|
|
|
return this.underlyingObject.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
getId() {
|
|
|
|
return this.underlyingObject._id;
|
|
|
|
}
|
|
|
|
|
|
|
|
getProperties() {
|
|
|
|
return this.underlyingObject.properties;
|
|
|
|
}
|
|
|
|
|
|
|
|
getRowClasses() {
|
|
|
|
return {
|
|
|
|
"is-busy": !this.isInitialized
|
|
|
|
}
|
|
|
|
}
|
2019-03-13 13:53:40 +01:00
|
|
|
|
|
|
|
getChildObjects() {
|
|
|
|
return [];
|
|
|
|
}
|
2019-02-12 09:08:37 +01:00
|
|
|
}
|
|
|
|
|
2019-03-13 13:53:40 +01:00
|
|
|
export { RowBase, RowState }
|