vtb-appit 0.1.1 → 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 +19 -2
- package/package.json +1 -1
package/appit.js
CHANGED
|
@@ -418,6 +418,7 @@ class Appit {
|
|
|
418
418
|
async documents()
|
|
419
419
|
{
|
|
420
420
|
const documents = this.transformer.documents();
|
|
421
|
+
let documentHistory = {};
|
|
421
422
|
if(documents) {
|
|
422
423
|
for(let i = 0; i < documents.length; i++) {
|
|
423
424
|
documents[i].excursion_id = this.history.excursionId;
|
|
@@ -426,12 +427,19 @@ class Appit {
|
|
|
426
427
|
let model = await this.createDocument(documents[i]);
|
|
427
428
|
console.log('documents', model);
|
|
428
429
|
if(typeof model === 'object' && model.data && model.data.id)
|
|
429
|
-
|
|
430
|
+
documentHistory[documents[i].object_id] = model.data.id;
|
|
430
431
|
} else {
|
|
431
|
-
|
|
432
|
+
documentHistory[documents[i].object_id] = id;
|
|
432
433
|
}
|
|
433
434
|
}
|
|
434
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;
|
|
435
443
|
}
|
|
436
444
|
|
|
437
445
|
async accommodations()
|
|
@@ -1070,6 +1078,15 @@ class Appit {
|
|
|
1070
1078
|
}
|
|
1071
1079
|
}
|
|
1072
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
|
+
|
|
1073
1090
|
async deletePlace(id)
|
|
1074
1091
|
{
|
|
1075
1092
|
try {
|