isobit-ui 0.0.335 → 0.0.338

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +52 -33
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * isobit-ui v0.0.335
2
+ * isobit-ui v0.0.338
3
3
  * (c) Erik Alarcon Pinedo
4
4
  * Released under the MIT License.
5
5
  */
@@ -6213,7 +6213,7 @@ window.ui = _$1.ui = function (cfg) {
6213
6213
  },
6214
6214
  getStoredList: function getStoredList(storage, tt) {
6215
6215
  try {
6216
- if (window.idb) {
6216
+ if (window._.db) {
6217
6217
  var p = new Promise(function (resolve) {
6218
6218
  var t = tt ? window._.db.transaction(storage, tt) : window._.db.transaction(storage),
6219
6219
  objectStore = t.objectStore(storage); //,d=[];
@@ -6382,6 +6382,7 @@ window.ui = _$1.ui = function (cfg) {
6382
6382
  save: function save() {
6383
6383
  try {
6384
6384
  var _exit2 = false;
6385
+ var objectStore;
6385
6386
 
6386
6387
  var _this4 = this;
6387
6388
 
@@ -6414,63 +6415,58 @@ window.ui = _$1.ui = function (cfg) {
6414
6415
 
6415
6416
  if (!(_typeof(o) === 'object' && !Array.isArray(o) && o !== null)) return;
6416
6417
  return _invoke(function () {
6417
- if (!action || !_this4.app.networkStatus.connected || o.tmpId) {
6418
+ if (!action || !_this4.app.networkStatus.connected) {
6418
6419
  var storage = me.$children[0].storage;
6419
- return _await(me.getStoredList(storage), function (datj) {
6420
- //console.log(datj);
6421
- if (!datj) datj = [];
6420
+ return _await(me.getStoredList(storage), function (storedList) {
6421
+ if (!storedList) storedList = [];
6422
6422
 
6423
6423
  if (o.id) {
6424
- //Si existe se actualiza el registro quitando el flag de sincronizado
6425
- //siempre existe tmpId een los temporales
6426
- for (var k = 0; k < datj.length; k++) {
6427
- if (datj[k].tmpId == o.tmpId) {
6424
+ for (var k = 0; k < storedList.length; k++) {
6425
+ if (storedList[k].tmpId == o.tmpId) {
6428
6426
  delete o.tmpSynchronized;
6429
- datj[k] = o;
6427
+ storedList[k] = o;
6430
6428
  return;
6431
6429
  }
6432
6430
  }
6433
6431
  }
6434
6432
 
6435
6433
  var db = window._.db;
6436
- var objectStore = db.transaction([storage], "readwrite").objectStore(storage);
6434
+ objectStore = db.transaction([storage], "readwrite").objectStore(storage);
6437
6435
 
6438
6436
  if (!o.id) {
6439
6437
  o.id = -new Date();
6440
- o.tmpId = +new Date();
6441
- datj.unshift(o);
6438
+ o.tmpId = +new Date(); //add new item to start to array
6439
+
6440
+ storedList.unshift(o);
6442
6441
  objectStore.add(o);
6443
- me.$emit('storage', datj);
6444
- if (me.close2) me.close2({
6442
+ me.$emit('storage', o, storedList);
6443
+ me.close({
6444
+ success: true,
6445
6445
  data: o
6446
- });else {
6447
- me.close(true);
6448
- }
6446
+ });
6449
6447
  } else {
6450
6448
  var item = objectStore.get(o.tmpId);
6451
6449
 
6452
6450
  item.onsuccess = function () {
6453
6451
  if (item.result) {
6454
- //Put see modifica
6455
- objectStore.put(o); //window._.MsgBox('Modificado');
6452
+ objectStore.put(o);
6456
6453
  } else {
6457
- datj.forEach(function (ee) {
6454
+ storedList.forEach(function (ee) {
6458
6455
  if (ee.tmpId == o.tmpId) {
6459
6456
  objectStore.put(o);
6460
6457
  }
6461
- }); //window._.MsgBox('Agregado');
6458
+ });
6462
6459
  }
6463
6460
 
6464
- me.$emit('storage', datj);
6465
- if (me.close2) me.close2({
6461
+ me.$emit('storage', o, storedList);
6462
+ me.close({
6463
+ success: true,
6466
6464
  data: o
6467
- });else {
6468
- me.close(true);
6469
- }
6465
+ });
6470
6466
  };
6471
6467
 
6472
6468
  item.onerror = function () {
6473
- me.MsgBox('error found ' + o.tmpId);
6469
+ me.MsgBox('Error getting temporal record ' + o.tmpId);
6474
6470
  };
6475
6471
  }
6476
6472
 
@@ -6479,11 +6475,34 @@ window.ui = _$1.ui = function (cfg) {
6479
6475
  }
6480
6476
  }, function (_result) {
6481
6477
  if (_exit2) return _result;
6482
- axios__default['default'].post(action, o).then(function (r) {
6478
+ axios__default['default'].post(action, o).then(function (result) {
6479
+ var data = result.data;
6480
+
6481
+ if (o.tmpId) {
6482
+ var item = objectStore.get(o.tmpId);
6483
+ o.tmpSynchronized = 1;
6484
+ if (data.id) o.id = data.id;
6485
+
6486
+ item.onsuccess = function () {
6487
+ if (item.result) {
6488
+ objectStore.put(o);
6489
+ } else {
6490
+ objectStore.add(o);
6491
+ }
6492
+
6493
+ me.$emit('sync', data, o);
6494
+ };
6495
+
6496
+ item.onerror = function () {
6497
+ me.MsgBox('Error getting temporal record ' + o.tmpId);
6498
+ };
6499
+ }
6500
+
6483
6501
  me.MsgBox('El registro fue grabado exitosamente!', function () {
6484
- if (me.close2) me.close2(r);else {
6485
- me.close(true);
6486
- }
6502
+ me.close({
6503
+ success: true,
6504
+ data: data
6505
+ });
6487
6506
  });
6488
6507
  })["catch"](function (r) {
6489
6508
  if (r.response) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isobit-ui",
3
- "version": "0.0.335",
3
+ "version": "0.0.338",
4
4
  "description": "Vue component to play videos",
5
5
  "keywords": [
6
6
  "ui",