Browse Source

fixed user settings editme; added cache convinence function

tags/0.1.2
Robin Thoni 4 years ago
parent
commit
1b10d7d387
4 changed files with 27 additions and 5 deletions
  1. 1
    1
      dist/luticate-auth.min.js
  2. 10
    0
      src/Business/cache.js
  3. 14
    2
      src/Business/settingsuser.js
  4. 2
    2
      src/DataAccess/settingsuser.js

+ 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,6 +75,16 @@
75 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 88
             return luticateAuthCache;
79 89
         }]);
80 90
 })();

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

@@ -5,8 +5,8 @@
5 5
 (function () {
6 6
     'use strict';
7 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 11
                 var luticateAuthSettingsUser = {
12 12
                     getAll: luticateAuthSettingsUserDataAccess.getAll,
@@ -15,6 +15,18 @@
15 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 30
                 return luticateAuthSettingsUser;
19 31
         }]);
20 32
 })();

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

@@ -29,8 +29,8 @@
29 29
 
30 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 36
                 return luticateAuthSettingsUser;

Loading…
Cancel
Save