@@ -110,7 +117,7 @@ class AdminPanelSystemPreferences extends React.Component {
- {i18n('UPDATE_SYSTEM')}
+ {i18n('UPDATE_SETTINGS')}
@@ -121,8 +128,37 @@ class AdminPanelSystemPreferences extends React.Component {
);
}
- onSubmit() {
- alert('WESA');
+ onSubmit(form) {
+ let fullList = Object.keys(languageList);
+ this.setState({loading: true});
+
+ API.call({
+ path: '/system/edit-settings',
+ data: {
+ 'language': fullList[form.language],
+ 'reCaptchaKey': form.reCaptchaKey,
+ 'reCaptchaPrivate': form.reCaptchaPrivate,
+ 'url': form['url'],
+ 'title': form['title'],
+ 'layout': form['layout'] == 1 ? 'Full width' : 'Boxed',
+ 'time-zone': form['time-zone'],
+ 'no-reply-email': form['no-reply-email'],
+ 'smtp-host': form['smtp-host'],
+ 'smtp-port': form['smtp-port'],
+ 'smtp-user': form['smtp-user'],
+ 'smtp-pass': form['smtp-password'],
+ 'maintenance-mode': form['maintenance-mode'],
+ 'file-attachments': form['file-attachments'],
+ 'max-size': form['max-size'],
+ 'allowedLanguages': form.allowedLanguages.map(index => fullList[index]),
+ 'supportedLanguages': form.supportedLanguages.map(index => fullList[index])
+ }
+ }).then(this.onSubmitSuccess.bind(this));
+ }
+
+ onSubmitSuccess() {
+ this.recoverSettings();
+
}
getLanguageList() {
@@ -140,9 +176,11 @@ class AdminPanelSystemPreferences extends React.Component {
onRecoverSettingsSuccess(result) {
let fullList = Object.keys(languageList);
+
this.setState({
+ loading: false,
values: {
- 'language': result.data.language,
+ 'language': _.indexOf(fullList, result.data.language),
'reCaptchaKey': result.data.reCaptchaKey,
'reCaptchaPrivate': result.data.reCaptchaPrivate,
'url': result.data['url'],
@@ -157,7 +195,6 @@ class AdminPanelSystemPreferences extends React.Component {
'maintenance-mode': result.data['maintenance-mode'],
'file-attachments': result.data['file-attachments'],
'max-size': result.data['max-size'],
- 'departments': result.data.departments,
'allowedLanguages': result.data.allowedLanguages.map(lang => (_.indexOf(fullList, lang))),
'supportedLanguages': result.data.supportedLanguages.map(lang => (_.indexOf(fullList, lang)))
}
diff --git a/client/src/data/fixtures/system-fixtures.js b/client/src/data/fixtures/system-fixtures.js
index c8f1ffd6..6ab473be 100644
--- a/client/src/data/fixtures/system-fixtures.js
+++ b/client/src/data/fixtures/system-fixtures.js
@@ -50,6 +50,16 @@ module.exports = [
}
}
},
+ {
+ path: '/system/edit-settings',
+ time: 50,
+ response: function() {
+ return {
+ status: 'success',
+ data: {}
+ }
+ }
+ },
{
path: '/staff/add-department',
time: 100,
diff --git a/client/src/data/languages/en.js b/client/src/data/languages/en.js
index 5ca8b107..1db093b1 100644
--- a/client/src/data/languages/en.js
+++ b/client/src/data/languages/en.js
@@ -131,7 +131,8 @@ export default {
'RECAPTCHA_PRIVATE_KEY': 'Recaptcha Private Key',
'ALLOW_FILE_ATTACHMENTS': 'Allow file attachments',
'MAX_SIZE_KB': 'Max Size (KB)',
- 'UPDATE_SYSTEM': 'Update system',
+ 'UPDATE_SETTINGS': 'Update settings',
+ 'DEFAULT_LANGUAGE': 'Default Language',
'SUPPORTED_LANGUAGES': 'Supported Languages',
'ALLOWED_LANGUAGES': 'Allowed Languages',
'ON': 'On',