Browse Source

fixed user settings editme; added cache convinence function

tags/0.1.2
Robin Thoni 8 years ago
parent
commit
1b10d7d387

+ 1
- 1
dist/luticate-auth.min.js
File diff suppressed because it is too large
View File


+ 10
- 0
src/Business/cache.js View File

75
                 return setting == null ? null : setting.Value;
75
                 return setting == null ? null : setting.Value;
76
             };
76
             };
77
 
77
 
78
+            luticateAuthCache.setEffectiveSettingValue = function(setting_name, setting_value)
79
+            {
80
+                var settings = luticateAuthCacheDataAccess.getEffectiveSettings();
81
+                if (settings == null) {
82
+                    return;
83
+                }
84
+                settings[setting_name].Value = setting_value;
85
+                luticateAuthCacheDataAccess.setEffectiveSettings(settings);
86
+            };
87
+
78
             return luticateAuthCache;
88
             return luticateAuthCache;
79
         }]);
89
         }]);
80
 })();
90
 })();

+ 14
- 2
src/Business/settingsuser.js View File

5
 (function () {
5
 (function () {
6
     'use strict';
6
     'use strict';
7
     angular.module('luticateAuth')
7
     angular.module('luticateAuth')
8
-        .factory('luticateAuthSettingsUser', ['luticateAuthSettingsUserDataAccess',
9
-            function(luticateAuthSettingsUserDataAccess) {
8
+        .factory('luticateAuthSettingsUser', ['luticateAuthSettingsUserDataAccess', '$q', 'luticateAuthCache',
9
+            function(luticateAuthSettingsUserDataAccess, $q, luticateAuthCache) {
10
 
10
 
11
                 var luticateAuthSettingsUser = {
11
                 var luticateAuthSettingsUser = {
12
                     getAll: luticateAuthSettingsUserDataAccess.getAll,
12
                     getAll: luticateAuthSettingsUserDataAccess.getAll,
15
                     editMe: luticateAuthSettingsUserDataAccess.editMe
15
                     editMe: luticateAuthSettingsUserDataAccess.editMe
16
                 };
16
                 };
17
 
17
 
18
+                luticateAuthSettingsUser.editMe = function(data, promise)
19
+                {
20
+                    var defer = $q.defer();
21
+                    luticateAuthSettingsUserDataAccess.editMe(data, promise)
22
+                        .then(function(result)
23
+                        {
24
+                            luticateAuthCache.setEffectiveSettingValue(data.setting_name, data.setting_value);
25
+                            defer.resolve(result);
26
+                        }, defer.reject);
27
+                    return defer.promise;
28
+                };
29
+
18
                 return luticateAuthSettingsUser;
30
                 return luticateAuthSettingsUser;
19
         }]);
31
         }]);
20
 })();
32
 })();

+ 2
- 2
src/DataAccess/settingsuser.js View File

29
 
29
 
30
                 luticateAuthSettingsUser.editMe = function(data, promise)
30
                 luticateAuthSettingsUser.editMe = function(data, promise)
31
                 {
31
                 {
32
-                    data.user_id = "me";
33
-                    return luticateAuthSettingsUser.edit(data, promise);
32
+                    return luticateRequest.post(url + "me/" + data.setting_name + "/edit",
33
+                        {setting_value: JSON.stringify(data.setting_value)}, null, promise);
34
                 };
34
                 };
35
 
35
 
36
                 return luticateAuthSettingsUser;
36
                 return luticateAuthSettingsUser;

Loading…
Cancel
Save