|
2 | 2 | * |
3 | 3 | * Client-Side nosql Firebase Realtime Database save management. |
4 | 4 | * @link https://flatte.github.io/Flatte-Web/ |
5 | | - * @version v.1.0.1-beta.87 - Tue Sep 05 2017 17:07:42 GMT+0300 (Türkiye Standart Saati) |
| 5 | + * @version v.1.0.1-beta.88 - Tue Sep 05 2017 21:11:41 GMT+0300 (Türkiye Standart Saati) |
6 | 6 | * |
7 | 7 | * Copyright (c) 2017 Flatte - Sezer Ekinci <sezer@maxabab.com>, Kaan Ekinci <kaan@maxabab.com> |
8 | 8 | * @license MIT License, https://opensource.org/licenses/MIT |
|
252 | 252 |
|
253 | 253 | promises.push($q(function (resolve, reject) { |
254 | 254 | placeIDs(path,manifestPath,runRef.split('/'),"#").then(function(resRef){ |
255 | | - placeIDs(path,manifestPath,options.saveValue.split('/'),"#").then(function(resValue){ |
256 | | - commands.saveValue(ref, runData, resRef.join('/'), resValue.join('/'), action,manifestPath).then(function (res) { |
| 255 | + if (typeof saveValue === "string") { |
| 256 | + placeIDs(path,manifestPath,options.saveValue.split('/'),"#").then(function(resValue){ |
| 257 | + commands.saveValue(ref, runData, resRef.join('/'), resValue.join('/'), action,manifestPath).then(function (res) { |
| 258 | + angular.extend(results,res); |
| 259 | + resolve(); |
| 260 | + }).catch(function(err){ reject(err); return false; }); |
| 261 | + }); |
| 262 | + } else { |
| 263 | + commands.saveValue(ref, runData, resRef.join('/'), options.saveValue, action,manifestPath).then(function (res) { |
257 | 264 | angular.extend(results,res); |
258 | 265 | resolve(); |
259 | 266 | }).catch(function(err){ reject(err); return false; }); |
260 | | - }); |
| 267 | + } |
261 | 268 | }); |
262 | 269 | })); |
263 | 270 | promises.push($q(function (resolve, reject) { |
264 | 271 | placeIDs(path,manifestPath,runRef.split('/'),"#").then(function(resRef){ |
265 | | - placeIDs(path,manifestPath,options.deleteValue.split('/'),"#").then(function(resValue){ |
266 | | - commands.deleteValue(ref, runData, resRef.join('/'), resValue.join('/'), action,manifestPath).then(function (res) { |
| 272 | + if (typeof deleteValue === "string") { |
| 273 | + placeIDs(path,manifestPath,options.deleteValue.split('/'),"#").then(function(resValue){ |
| 274 | + commands.deleteValue(ref, runData, resRef.join('/'), resValue.join('/'), action,manifestPath).then(function (res) { |
| 275 | + angular.extend(results,res); |
| 276 | + resolve(); |
| 277 | + }).catch(function(err){ reject(err); return false; }); |
| 278 | + }); |
| 279 | + } else { |
| 280 | + commands.deleteValue(ref, runData, resRef.join('/'), options.deleteValue, action,manifestPath).then(function (res) { |
267 | 281 | angular.extend(results,res); |
268 | 282 | resolve(); |
269 | 283 | }).catch(function(err){ reject(err); return false; }); |
270 | | - }); |
| 284 | + } |
271 | 285 | }); |
272 | 286 | })); |
273 | 287 |
|
|
279 | 293 |
|
280 | 294 | if ( |
281 | 295 | ( |
282 | | - ((action === "save") && ((options.saveValue === null) || (options.saveValue === "$") || (options.saveValue.trim() === ""))) || |
283 | | - ((action !== "save") && ((options.deleteValue === null) || (options.deleteValue === "$") || (options.deleteValue.trim() === ""))) |
| 296 | + ((action === "save") && ((options.saveValue === null) || (options.saveValue === "$") || (typeof options.saveValue === "string" && options.saveValue.trim() === ""))) || |
| 297 | + ((action !== "save") && ((options.deleteValue === null) || (options.deleteValue === "$") || (typeof options.deleteValue === "string" && options.deleteValue.trim() === ""))) |
284 | 298 | ) && angular.isObject(loopData) |
285 | 299 | ) { |
286 | 300 | angular.forEach(loopData,function(value,key){ |
|
361 | 375 | if (options.save.value !== ".doNothing") { |
362 | 376 | if (action === "save") { |
363 | 377 | promises.push($q(function (resolve, reject) { |
364 | | - commands.saveValue(ref, "1", (path + "/" + options.save.key).split('/'), options.save.value, action,manifestPath).then(function (res) { |
| 378 | + commands.saveValue(ref, data, (path + "/" + options.save.key).split('/'), options.save.value, action,manifestPath).then(function (res) { |
365 | 379 | if (!angular.equals(data,res)) angular.extend(results, res); |
366 | 380 | resolve(); |
367 | 381 | }).catch(function (err) { |
|
0 commit comments