2018-05-22 12:15:54 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const Entity = require('./entity');
|
2018-05-22 12:22:43 +08:00
|
|
|
const dateUtils = require('../services/date_utils');
|
2018-05-22 12:15:54 +08:00
|
|
|
|
2018-08-23 05:37:06 +08:00
|
|
|
/**
|
|
|
|
* Option represents name-value pair, either directly configurable by the user or some system property.
|
|
|
|
*
|
|
|
|
* @param {string} name
|
|
|
|
* @param {string} value
|
|
|
|
* @param {boolean} isSynced
|
|
|
|
* @param {string} dateModified
|
|
|
|
* @param {string} dateCreated
|
|
|
|
*
|
|
|
|
* @extends Entity
|
|
|
|
*/
|
2018-05-22 12:15:54 +08:00
|
|
|
class Option extends Entity {
|
2018-08-17 05:00:04 +08:00
|
|
|
static get entityName() { return "options"; }
|
2018-06-14 07:10:28 +08:00
|
|
|
static get primaryKeyName() { return "name"; }
|
|
|
|
static get hashedProperties() { return ["name", "value"]; }
|
2018-05-22 12:22:43 +08:00
|
|
|
|
2018-08-07 17:38:00 +08:00
|
|
|
constructor(row) {
|
|
|
|
super(row);
|
|
|
|
|
|
|
|
this.isSynced = !!this.isSynced;
|
|
|
|
}
|
|
|
|
|
2018-05-22 12:22:43 +08:00
|
|
|
beforeSaving() {
|
2018-08-06 14:59:26 +08:00
|
|
|
super.beforeSaving();
|
2018-08-13 02:04:48 +08:00
|
|
|
|
|
|
|
if (this.isChanged) {
|
|
|
|
this.dateModified = dateUtils.nowDate();
|
|
|
|
}
|
2018-05-22 12:22:43 +08:00
|
|
|
}
|
2018-05-22 12:15:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Option;
|