2021-07-04 20:19:04 -07:00
|
|
|
import { get } from '../../_utils/lodash-lite.js'
|
2019-05-25 13:21:36 -07:00
|
|
|
|
2018-03-03 14:15:50 -08:00
|
|
|
export function instanceMixins (Store) {
|
2019-05-25 13:21:36 -07:00
|
|
|
Store.prototype.getInstanceSetting = function (instanceName, settingName, defaultValue) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const { instanceSettings } = this.get()
|
2019-05-25 13:21:36 -07:00
|
|
|
return get(instanceSettings, [instanceName, settingName], defaultValue)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Store.prototype.setInstanceSetting = function (instanceName, settingName, value) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const { instanceSettings } = this.get()
|
2019-05-25 13:21:36 -07:00
|
|
|
if (!instanceSettings[instanceName]) {
|
|
|
|
|
instanceSettings[instanceName] = {}
|
|
|
|
|
}
|
|
|
|
|
instanceSettings[instanceName][settingName] = value
|
|
|
|
|
this.set({ instanceSettings })
|
|
|
|
|
}
|
2019-06-19 23:00:27 -07:00
|
|
|
|
|
|
|
|
Store.prototype.setInstanceData = function (instanceName, key, value) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const instanceData = this.get()[key] || {}
|
2019-06-19 23:00:27 -07:00
|
|
|
instanceData[instanceName] = value
|
|
|
|
|
this.set({ [key]: instanceData })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Store.prototype.getInstanceData = function (instanceName, key) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const instanceData = this.get()[key] || {}
|
2019-06-19 23:00:27 -07:00
|
|
|
return instanceData[instanceName]
|
|
|
|
|
}
|
2018-03-03 14:15:50 -08:00
|
|
|
}
|