-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
š Fix certain settings not being applied if they're created after genā¦
ā¦erating the main system setting object
- Loading branch information
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -452,6 +452,9 @@ const Group = Function.inherits('Alchemy.Setting.Base', function Group(name, con | |
|
||
// All the children | ||
this.children = new Map(); | ||
|
||
// Weak references to existing values | ||
this.weak_values = new Blast.Classes.WeakValueSet(); | ||
}); | ||
|
||
/** | ||
|
@@ -583,6 +586,14 @@ Group.setMethod(function createGroup(name) { | |
let group = new Group(name, this); | ||
this.children.set(name, group); | ||
|
||
if (this.weak_values.size) { | ||
let group_value = group.generateValue(); | ||
|
||
for (let existing of this.weak_values) { | ||
this.setDefaultValue(existing, {[name]: group_value}); | ||
} | ||
} | ||
|
||
return group; | ||
}); | ||
|
||
|
@@ -633,6 +644,8 @@ Group.setMethod(function generateValue() { | |
|
||
this.setDefaultValue(result, object); | ||
|
||
this.weak_values.add(result); | ||
|
||
return result; | ||
}); | ||
|
||
|
@@ -1344,6 +1357,38 @@ GroupValue.setMethod(function _setPath(silent, path, raw_value) { | |
return this.getPath(path); | ||
}); | ||
|
||
/** | ||
* Force a value at the given path | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.4.0 | ||
* @version 1.4.0 | ||
* | ||
* @param {string|Array} path | ||
* @param {Value} | ||
*/ | ||
GroupValue.setMethod(function forceValueInstanceAtPath(path, value) { | ||
|
||
if (typeof path == 'string') { | ||
path = path.split('.'); | ||
} | ||
|
||
if (this.definition.group == null && path[0] == this.definition.name) { | ||
path.shift(); | ||
} | ||
|
||
let last = path.pop(); | ||
|
||
let current = this; | ||
|
||
while (path.length && current) { | ||
let next = path.shift(); | ||
current = current.get(next); | ||
} | ||
|
||
current[VALUE][last] = value; | ||
}); | ||
|
||
/** | ||
* Convert to a datasource array | ||
* | ||
|
@@ -1584,6 +1629,20 @@ Value.setMethod(function getPath(path) { | |
return current; | ||
}); | ||
|
||
/** | ||
* Force a value at the given path | ||
* | ||
* @author Jelle De Loecker <[email protected]> | ||
* @since 1.4.0 | ||
* @version 1.4.0 | ||
* | ||
* @param {string|Array} path | ||
* @param {Value} | ||
*/ | ||
Value.setMethod(function forceValueInstanceAtPath(path, value) { | ||
throw new Error('Unable to perform on a simple Value instance'); | ||
}); | ||
|
||
if (Blast.isBrowser) { | ||
return; | ||
} | ||
|