isobit-ui 0.0.334 → 0.0.337

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 +51 -35
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * isobit-ui v0.0.334
2
+ * isobit-ui v0.0.337
3
3
  * (c) Erik Alarcon Pinedo
4
4
  * Released under the MIT License.
5
5
  */
@@ -1937,13 +1937,10 @@ var script$d = {
1937
1937
  var datj;
1938
1938
  return _invoke$1(function () {
1939
1939
  if (window._.db) {
1940
- alert('SI IDB');
1941
1940
  return _await$1(me.getStoredList(storage), function (_me$getStoredList) {
1942
1941
  datj = _me$getStoredList;
1943
1942
  });
1944
1943
  } else {
1945
- alert('NO IDB');
1946
-
1947
1944
  try {
1948
1945
  var vvv = localStorage.getItem(storage);
1949
1946
  if (vvv) datj = JSON.parse(vvv);
@@ -6216,7 +6213,7 @@ window.ui = _$1.ui = function (cfg) {
6216
6213
  },
6217
6214
  getStoredList: function getStoredList(storage, tt) {
6218
6215
  try {
6219
- if (window.idb) {
6216
+ if (window._.db) {
6220
6217
  var p = new Promise(function (resolve) {
6221
6218
  var t = tt ? window._.db.transaction(storage, tt) : window._.db.transaction(storage),
6222
6219
  objectStore = t.objectStore(storage); //,d=[];
@@ -6385,6 +6382,7 @@ window.ui = _$1.ui = function (cfg) {
6385
6382
  save: function save() {
6386
6383
  try {
6387
6384
  var _exit2 = false;
6385
+ var objectStore;
6388
6386
 
6389
6387
  var _this4 = this;
6390
6388
 
@@ -6419,61 +6417,56 @@ window.ui = _$1.ui = function (cfg) {
6419
6417
  return _invoke(function () {
6420
6418
  if (!action || !_this4.app.networkStatus.connected || o.tmpId) {
6421
6419
  var storage = me.$children[0].storage;
6422
- return _await(me.getStoredList(storage), function (datj) {
6423
- //console.log(datj);
6424
- if (!datj) datj = [];
6420
+ return _await(me.getStoredList(storage), function (storedList) {
6421
+ if (!storedList) storedList = [];
6425
6422
 
6426
6423
  if (o.id) {
6427
- //Si existe se actualiza el registro quitando el flag de sincronizado
6428
- //siempre existe tmpId een los temporales
6429
- for (var k = 0; k < datj.length; k++) {
6430
- if (datj[k].tmpId == o.tmpId) {
6424
+ for (var k = 0; k < storedList.length; k++) {
6425
+ if (storedList[k].tmpId == o.tmpId) {
6431
6426
  delete o.tmpSynchronized;
6432
- datj[k] = o;
6427
+ storedList[k] = o;
6433
6428
  return;
6434
6429
  }
6435
6430
  }
6436
6431
  }
6437
6432
 
6438
6433
  var db = window._.db;
6439
- var objectStore = db.transaction([storage], "readwrite").objectStore(storage);
6434
+ objectStore = db.transaction([storage], "readwrite").objectStore(storage);
6440
6435
 
6441
6436
  if (!o.id) {
6442
6437
  o.id = -new Date();
6443
- o.tmpId = +new Date();
6444
- datj.unshift(o);
6438
+ o.tmpId = +new Date(); //add new item to start to array
6439
+
6440
+ storedList.unshift(o);
6445
6441
  objectStore.add(o);
6446
- me.$emit('storage', datj);
6447
- if (me.close2) me.close2({
6442
+ me.$emit('storage', o, storedList);
6443
+ me.close({
6444
+ success: true,
6448
6445
  data: o
6449
- });else {
6450
- me.close(true);
6451
- }
6446
+ });
6452
6447
  } else {
6453
6448
  var item = objectStore.get(o.tmpId);
6454
6449
 
6455
6450
  item.onsuccess = function () {
6456
6451
  if (item.result) {
6457
- //Put see modifica
6458
- objectStore.put(o); //window._.MsgBox('Modificado');
6452
+ objectStore.put(o);
6459
6453
  } else {
6460
- datj.forEach(function (ee) {
6454
+ storedList.forEach(function (ee) {
6461
6455
  if (ee.tmpId == o.tmpId) {
6462
6456
  objectStore.put(o);
6463
6457
  }
6464
- }); //window._.MsgBox('Agregado');
6458
+ });
6465
6459
  }
6466
6460
 
6467
- me.$emit('storage', datj);
6468
- if (me.close2) me.close2({
6461
+ me.$emit('storage', o, storedList);
6462
+ me.close({
6463
+ success: true,
6469
6464
  data: o
6470
- });else {
6471
- me.close(true);
6472
- }
6465
+ });
6473
6466
  };
6474
6467
 
6475
6468
  item.onerror = function () {
6476
- me.MsgBox('error found ' + o.tmpId);
6469
+ me.MsgBox('Error getting temporal record ' + o.tmpId);
6477
6470
  };
6478
6471
  }
6479
6472
 
@@ -6482,11 +6475,34 @@ window.ui = _$1.ui = function (cfg) {
6482
6475
  }
6483
6476
  }, function (_result) {
6484
6477
  if (_exit2) return _result;
6485
- 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
+
6486
6501
  me.MsgBox('El registro fue grabado exitosamente!', function () {
6487
- if (me.close2) me.close2(r);else {
6488
- me.close(true);
6489
- }
6502
+ me.close({
6503
+ success: true,
6504
+ data: data
6505
+ });
6490
6506
  });
6491
6507
  })["catch"](function (r) {
6492
6508
  if (r.response) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isobit-ui",
3
- "version": "0.0.334",
3
+ "version": "0.0.337",
4
4
  "description": "Vue component to play videos",
5
5
  "keywords": [
6
6
  "ui",