summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-05-12 11:15:13 +0200
committerSamy Pessé <samypesse@gmail.com>2016-05-12 11:15:13 +0200
commit8aa2f3075c81161746cd63a388ce0eddc536ac15 (patch)
treea33ac0df67023a69b985b650e3b33af7e12ae117 /lib/models
parent839ee0385af2e6a9917826b07dd61c851244e6e0 (diff)
downloadgitbook-8aa2f3075c81161746cd63a388ce0eddc536ac15.zip
gitbook-8aa2f3075c81161746cd63a388ce0eddc536ac15.tar.gz
gitbook-8aa2f3075c81161746cd63a388ce0eddc536ac15.tar.bz2
Fix #1294: multilingual book should extend the book's config
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/config.js54
1 files changed, 40 insertions, 14 deletions
diff --git a/lib/models/config.js b/lib/models/config.js
index 070fe92..99b0f1a 100644
--- a/lib/models/config.js
+++ b/lib/models/config.js
@@ -19,6 +19,16 @@ Config.prototype.getValues = function() {
};
/**
+ Change the file for the configuration
+
+ @param {File} file
+ @return {Config}
+*/
+Config.prototype.setFile = function(file) {
+ return this.set('file', file);
+};
+
+/**
Return a configuration value by its key path
@param {String} key
@@ -40,7 +50,7 @@ Config.prototype.getValue = function(keyPath, def) {
@param {String} key
@param {Mixed} value
- @return {Mixed}
+ @return {Config}
*/
Config.prototype.setValue = function(keyPath, value) {
keyPath = Config.keyToKeyPath(keyPath);
@@ -94,6 +104,35 @@ Config.prototype.setPluginDependencies = function(deps) {
return this.setValue('plugins', plugins);
};
+
+/**
+ Update values for an existing configuration
+
+ @param {Object} values
+ @returns {Config}
+*/
+Config.prototype.updateValues = function(values) {
+ values = Immutable.fromJS(values);
+
+ return this.set('values', values);
+};
+
+/**
+ Update values for an existing configuration
+
+ @param {Config} config
+ @param {Object} values
+ @returns {Config}
+*/
+Config.prototype.mergeValues = function(values) {
+ var currentValues = this.getValues();
+ values = Immutable.fromJS(values);
+
+ currentValues = currentValues.mergeDeep(values);
+
+ return this.set('values', currentValues);
+};
+
/**
Create a new config for a file
@@ -120,19 +159,6 @@ Config.createWithValues = function(values) {
});
};
-/**
- Update values for an existing configuration
-
- @param {Config} config
- @param {Object} values
- @returns {Config}
-*/
-Config.updateValues = function(config, values) {
- values = Immutable.fromJS(values);
-
- return config.set('values', values);
-};
-
/**
Convert a keyPath to an array of keys