vtb-appit 0.1.0 → 0.1.2
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.
- package/appit.js +26 -7
- package/package.json +1 -1
package/appit.js
CHANGED
|
@@ -252,12 +252,14 @@ class Appit {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
if(this.history.hasOwnProperty('ships')) {
|
|
256
|
+
let nonExisting = this.difference(Object.values(this.history.ships), Object.values(shipsHistory));
|
|
257
|
+
for(let i = 0; i < nonExisting.length; i++) {
|
|
258
|
+
await this.deleteShips(nonExisting[i]);
|
|
259
|
+
}
|
|
259
260
|
|
|
260
|
-
|
|
261
|
+
this.history.ships = shipsHistory;
|
|
262
|
+
}
|
|
261
263
|
}
|
|
262
264
|
|
|
263
265
|
|
|
@@ -416,6 +418,7 @@ class Appit {
|
|
|
416
418
|
async documents()
|
|
417
419
|
{
|
|
418
420
|
const documents = this.transformer.documents();
|
|
421
|
+
let documentHistory = {};
|
|
419
422
|
if(documents) {
|
|
420
423
|
for(let i = 0; i < documents.length; i++) {
|
|
421
424
|
documents[i].excursion_id = this.history.excursionId;
|
|
@@ -424,12 +427,19 @@ class Appit {
|
|
|
424
427
|
let model = await this.createDocument(documents[i]);
|
|
425
428
|
console.log('documents', model);
|
|
426
429
|
if(typeof model === 'object' && model.data && model.data.id)
|
|
427
|
-
|
|
430
|
+
documentHistory[documents[i].object_id] = model.data.id;
|
|
428
431
|
} else {
|
|
429
|
-
|
|
432
|
+
documentHistory[documents[i].object_id] = id;
|
|
430
433
|
}
|
|
431
434
|
}
|
|
432
435
|
}
|
|
436
|
+
|
|
437
|
+
let nonExisting = this.difference(Object.values(this.history.documents), Object.values(documentHistory));
|
|
438
|
+
for(let i = 0; i < nonExisting.length; i++) {
|
|
439
|
+
await this.deleteDocuments(nonExisting[i]);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
this.history.documents = documentHistory;
|
|
433
443
|
}
|
|
434
444
|
|
|
435
445
|
async accommodations()
|
|
@@ -1068,6 +1078,15 @@ class Appit {
|
|
|
1068
1078
|
}
|
|
1069
1079
|
}
|
|
1070
1080
|
|
|
1081
|
+
async deleteDocuments(id, data)
|
|
1082
|
+
{
|
|
1083
|
+
try {
|
|
1084
|
+
return await this.request('DELETE', `documents/${id}`, data);
|
|
1085
|
+
} catch {
|
|
1086
|
+
console.log(`deleteDocument failed: ${id}`);
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1071
1090
|
async deletePlace(id)
|
|
1072
1091
|
{
|
|
1073
1092
|
try {
|