projects
/
osm
/
UI.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b third try
[osm/UI.git]
/
skyquake
/
plugins
/
composer
/
src
/
src
/
libraries
/
model
/
DescriptorModel.js
diff --git
a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js
b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js
index
1a2ba4f
..
3db2a0d
100644
(file)
--- a/
skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js
+++ b/
skyquake/plugins/composer/src/src/libraries/model/DescriptorModel.js
@@
-1,6
+1,6
@@
/*
/*
- *
+ *
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Copyright 2016 RIFT.IO Inc
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@
-20,7
+20,9
@@
* Created by onvelocity on 8/23/15.
*/
* Created by onvelocity on 8/23/15.
*/
-import _ from 'lodash'
+import _isArray from 'lodash/isArray'
+import _set from 'lodash/set'
+import _get from 'lodash/get'
import guid from '../guid'
import Position from '../graph/Position'
import IconFactory from './IconFactory'
import guid from '../guid'
import Position from '../graph/Position'
import IconFactory from './IconFactory'
@@
-34,7
+36,7
@@
import DescriptorModelMetaFactory from './DescriptorModelMetaFactory'
*/
export default class DescriptorModel {
*/
export default class DescriptorModel {
- constructor(model = {uiState: {}}, parent = null) {
+ constructor(model = {uiState: {}}, parent = null
, readonly = false
) {
// when our instance has no more strong references
// then our properties will get garbage collected.
this._props_ = new WeakMap();
// when our instance has no more strong references
// then our properties will get garbage collected.
this._props_ = new WeakMap();
@@
-49,6
+51,7
@@
export default class DescriptorModel {
if (parent instanceof DescriptorModel) {
parent.addChild(this);
}
if (parent instanceof DescriptorModel) {
parent.addChild(this);
}
+ this.isReadOnly = readonly;
}
get fieldNames() {
}
get fieldNames() {
@@
-279,7
+282,7
@@
export default class DescriptorModel {
updateModelList(modelFieldName, modelFieldValue, descriptorClass = DescriptorModel, newItemAddedSuccessCallback = () => {}) {
// value can be Array of (DescriptorModel | json model), DescriptorModel, or json model
updateModelList(modelFieldName, modelFieldValue, descriptorClass = DescriptorModel, newItemAddedSuccessCallback = () => {}) {
// value can be Array of (DescriptorModel | json model), DescriptorModel, or json model
- if (_
.
isArray(modelFieldValue)) {
+ if (_isArray(modelFieldValue)) {
this.model[modelFieldName] = modelFieldValue.map(d => d instanceof descriptorClass ? d.model : d);
return true;
}
this.model[modelFieldName] = modelFieldValue.map(d => d instanceof descriptorClass ? d.model : d);
return true;
}
@@
-309,4
+312,12
@@
export default class DescriptorModel {
return length !== this[propertyName].length;
}
return length !== this[propertyName].length;
}
+ setUiState(setting, path, value){
+ _set(this.uiState, [setting].concat(path), value);
+ }
+
+ getUiState(setting, path, defaultValue){
+ return _get(this.uiState, [setting].concat(path), defaultValue);
+ }
+
}
}