Przeglądaj źródła

fixed user settings editme; added cache convinence function

tags/0.1.2
Robin Thoni 8 lat temu
rodzic
commit
1b10d7d387

+ 1
- 1
dist/luticate-auth.min.js
Plik diff jest za duży
Wyświetl plik


+ 10
- 0
src/Business/cache.js Wyświetl plik

@@ -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 Wyświetl plik

@@ -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 Wyświetl plik

@@ -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;

Ładowanie…
Anuluj
Zapisz