2021-04-30 23:10:25 +02:00
|
|
|
"use strict";
|
|
|
|
|
2022-01-10 17:09:20 +01:00
|
|
|
const dateUtils = require('../../services/date_utils');
|
2023-01-03 13:52:37 +01:00
|
|
|
const AbstractBeccaEntity = require("./abstract_becca_entity");
|
2021-04-30 23:10:25 +02:00
|
|
|
|
|
|
|
/**
|
2023-06-30 11:18:34 +02:00
|
|
|
* Option represents a name-value pair, either directly configurable by the user or some system property.
|
2022-04-16 00:17:32 +02:00
|
|
|
*
|
2023-01-03 13:52:37 +01:00
|
|
|
* @extends AbstractBeccaEntity
|
2021-04-30 23:10:25 +02:00
|
|
|
*/
|
2023-01-03 13:52:37 +01:00
|
|
|
class BOption extends AbstractBeccaEntity {
|
2021-04-30 23:10:25 +02:00
|
|
|
static get entityName() { return "options"; }
|
|
|
|
static get primaryKeyName() { return "name"; }
|
|
|
|
static get hashedProperties() { return ["name", "value"]; }
|
|
|
|
|
|
|
|
constructor(row) {
|
|
|
|
super();
|
|
|
|
|
2023-02-22 22:10:41 +01:00
|
|
|
this.updateFromRow(row);
|
|
|
|
this.becca.options[this.name] = this;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateFromRow(row) {
|
2021-11-10 21:30:54 +01:00
|
|
|
/** @type {string} */
|
2021-04-30 23:10:25 +02:00
|
|
|
this.name = row.name;
|
2021-11-10 21:30:54 +01:00
|
|
|
/** @type {string} */
|
2021-04-30 23:10:25 +02:00
|
|
|
this.value = row.value;
|
2021-11-10 21:30:54 +01:00
|
|
|
/** @type {boolean} */
|
2021-04-30 23:10:25 +02:00
|
|
|
this.isSynced = !!row.isSynced;
|
2021-11-10 21:30:54 +01:00
|
|
|
/** @type {string} */
|
2021-04-30 23:10:25 +02:00
|
|
|
this.utcDateModified = row.utcDateModified;
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeSaving() {
|
|
|
|
super.beforeSaving();
|
|
|
|
|
|
|
|
this.utcDateModified = dateUtils.utcNowDateTime();
|
2021-05-08 22:13:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
getPojo() {
|
|
|
|
return {
|
|
|
|
name: this.name,
|
|
|
|
value: this.value,
|
|
|
|
isSynced: this.isSynced,
|
2021-11-18 22:39:12 +01:00
|
|
|
utcDateModified: this.utcDateModified
|
2021-05-08 22:13:08 +02:00
|
|
|
}
|
2021-04-30 23:10:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-03 13:52:37 +01:00
|
|
|
module.exports = BOption;
|