@yoobic/yobi 7.7.113 → 7.7.114

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.
@@ -626,7 +626,7 @@ const YooFormCaptureComponent = class {
626
626
  initTags() {
627
627
  if (this.multiple) {
628
628
  for (let i = 0; i < this.max; i++) {
629
- this.extraData = this.extraData || [];
629
+ this.extraData = this.extraData || {};
630
630
  this.extraData[i] = this.extraData[i] || {};
631
631
  this.extraData[i]['tags'] = this.extraData[i]['tags'] || [];
632
632
  }
@@ -1048,7 +1048,7 @@ const YooFormCaptureComponent = class {
1048
1048
  (data) => {
1049
1049
  return new Promise((resolve) => {
1050
1050
  if (this.shouldTagImage()) {
1051
- this.showPhotoTagDialog(data).then((tag) => {
1051
+ return this.showPhotoTagDialog(data).then((tag) => {
1052
1052
  if (!rrule.isNullOrUndefined(tag.data)) {
1053
1053
  this.updateTagData(tag, captureIndex);
1054
1054
  resolve(data);
@@ -1172,6 +1172,7 @@ const YooFormCaptureComponent = class {
1172
1172
  });
1173
1173
  }
1174
1174
  clearPhotoEdit(index) {
1175
+ let isExtraDataDeleted = false;
1175
1176
  if (!index && index !== 0) {
1176
1177
  if (this.extraData && (this.extraData.drawings || (this.extraData.annotations && this.extraData.annotations.length > 0))) {
1177
1178
  this.extraData = { drawings: null, annotations: [], stitch: null };
@@ -1185,32 +1186,33 @@ const YooFormCaptureComponent = class {
1185
1186
  Object.keys(this.extraData).forEach((item, i) => {
1186
1187
  newExtraData[i] = this.extraData[item];
1187
1188
  });
1188
- // Object.keys(obj).filter(k => obj[k]).sort((a,b) => a-b).reduce((acc, cur) => { acc[cur] = obj[cur]; return acc }, {})
1189
1189
  this.extraDataChanged.emit(newExtraData);
1190
+ isExtraDataDeleted = true;
1190
1191
  }
1191
1192
  }
1193
+ return isExtraDataDeleted;
1192
1194
  }
1193
- clearPhotoTag(index) {
1194
- if (this.onHasTag(index)) {
1195
- let newExtraData = {};
1196
- if (this.multiple) {
1195
+ clearPhotoTag(index, deleteExtraData = true) {
1196
+ let newExtraData = {};
1197
+ if (this.multiple) {
1198
+ if (deleteExtraData) {
1197
1199
  delete this.extraData[index];
1198
1200
  Object.keys(this.extraData).forEach((item, i) => {
1199
1201
  newExtraData[i] = this.extraData[item];
1200
1202
  });
1201
1203
  this.extraDataChanged.emit(newExtraData);
1202
1204
  }
1203
- else {
1204
- this.extraData['tags'] = [];
1205
- newExtraData = this.extraData;
1206
- }
1207
- this.extraDataChanged.emit(newExtraData);
1208
1205
  }
1206
+ else {
1207
+ this.extraData['tags'] = [];
1208
+ newExtraData = this.extraData;
1209
+ }
1210
+ this.extraDataChanged.emit(newExtraData);
1209
1211
  }
1210
1212
  openPhotoEditorPreview(index, forceReadonly = false) {
1211
1213
  var _a;
1212
1214
  const imgSrc = this.getFieldValue(index);
1213
- const isMultipleData = isFinite(index) && this.extraData && rrule.isArray(this.extraData) && !!this.extraData.length && this.extraData[index];
1215
+ const isMultipleData = isFinite(index) && this.extraData && ((rrule.isArray(this.extraData) && !!this.extraData.length) || !!Object.keys(this.extraData).length) && this.extraData[index];
1214
1216
  const extraActions = [
1215
1217
  {
1216
1218
  icon: 'download',
@@ -1302,6 +1304,7 @@ const YooFormCaptureComponent = class {
1302
1304
  }
1303
1305
  }
1304
1306
  deleteCapture(index) {
1307
+ let isExtraDataDeleted = false;
1305
1308
  if (this.multiple && rrule.isArray(this.value)) {
1306
1309
  this.value.splice(index, 1);
1307
1310
  this.value = this.value.filter((item) => item); // remove empty
@@ -1311,11 +1314,11 @@ const YooFormCaptureComponent = class {
1311
1314
  this.value = null;
1312
1315
  }
1313
1316
  if (this.type === 'photo') {
1314
- this.clearPhotoEdit(index === -1 ? undefined : index);
1317
+ isExtraDataDeleted = this.clearPhotoEdit(index === -1 ? undefined : index);
1315
1318
  this.clearImageRecognition();
1316
1319
  }
1317
1320
  formInputHelpers.setValueAndValidateInput(this.value, this);
1318
- this.clearPhotoTag(index);
1321
+ this.clearPhotoTag(index, !isExtraDataDeleted);
1319
1322
  }
1320
1323
  clearImageRecognition() {
1321
1324
  if (this.imageRecognitionKpiKeys && this.imageRecognitionKpiKeys.length > 0) {
@@ -1565,7 +1568,7 @@ const YooFormCaptureComponent = class {
1565
1568
  (data) => {
1566
1569
  return new Promise((resolve) => {
1567
1570
  if (this.shouldTagImage()) {
1568
- this.showPhotoTagDialog(data).then((tag) => {
1571
+ return this.showPhotoTagDialog(data).then((tag) => {
1569
1572
  if (!rrule.isNullOrUndefined(tag.data)) {
1570
1573
  this.updateTagData(tag, index);
1571
1574
  resolve(data);
@@ -211,7 +211,7 @@ export class YooFormCaptureComponent {
211
211
  initTags() {
212
212
  if (this.multiple) {
213
213
  for (let i = 0; i < this.max; i++) {
214
- this.extraData = this.extraData || [];
214
+ this.extraData = this.extraData || {};
215
215
  this.extraData[i] = this.extraData[i] || {};
216
216
  this.extraData[i]['tags'] = this.extraData[i]['tags'] || [];
217
217
  }
@@ -639,7 +639,7 @@ export class YooFormCaptureComponent {
639
639
  (data) => {
640
640
  return new Promise((resolve) => {
641
641
  if (this.shouldTagImage()) {
642
- this.showPhotoTagDialog(data).then((tag) => {
642
+ return this.showPhotoTagDialog(data).then((tag) => {
643
643
  if (!isNullOrUndefined(tag.data)) {
644
644
  this.updateTagData(tag, captureIndex);
645
645
  resolve(data);
@@ -763,6 +763,7 @@ export class YooFormCaptureComponent {
763
763
  });
764
764
  }
765
765
  clearPhotoEdit(index) {
766
+ let isExtraDataDeleted = false;
766
767
  if (!index && index !== 0) {
767
768
  if (this.extraData && (this.extraData.drawings || (this.extraData.annotations && this.extraData.annotations.length > 0))) {
768
769
  this.extraData = { drawings: null, annotations: [], stitch: null };
@@ -776,32 +777,33 @@ export class YooFormCaptureComponent {
776
777
  Object.keys(this.extraData).forEach((item, i) => {
777
778
  newExtraData[i] = this.extraData[item];
778
779
  });
779
- // Object.keys(obj).filter(k => obj[k]).sort((a,b) => a-b).reduce((acc, cur) => { acc[cur] = obj[cur]; return acc }, {})
780
780
  this.extraDataChanged.emit(newExtraData);
781
+ isExtraDataDeleted = true;
781
782
  }
782
783
  }
784
+ return isExtraDataDeleted;
783
785
  }
784
- clearPhotoTag(index) {
785
- if (this.onHasTag(index)) {
786
- let newExtraData = {};
787
- if (this.multiple) {
786
+ clearPhotoTag(index, deleteExtraData = true) {
787
+ let newExtraData = {};
788
+ if (this.multiple) {
789
+ if (deleteExtraData) {
788
790
  delete this.extraData[index];
789
791
  Object.keys(this.extraData).forEach((item, i) => {
790
792
  newExtraData[i] = this.extraData[item];
791
793
  });
792
794
  this.extraDataChanged.emit(newExtraData);
793
795
  }
794
- else {
795
- this.extraData['tags'] = [];
796
- newExtraData = this.extraData;
797
- }
798
- this.extraDataChanged.emit(newExtraData);
799
796
  }
797
+ else {
798
+ this.extraData['tags'] = [];
799
+ newExtraData = this.extraData;
800
+ }
801
+ this.extraDataChanged.emit(newExtraData);
800
802
  }
801
803
  openPhotoEditorPreview(index, forceReadonly = false) {
802
804
  var _a;
803
805
  const imgSrc = this.getFieldValue(index);
804
- const isMultipleData = isFinite(index) && this.extraData && isArray(this.extraData) && !!this.extraData.length && this.extraData[index];
806
+ const isMultipleData = isFinite(index) && this.extraData && ((isArray(this.extraData) && !!this.extraData.length) || !!Object.keys(this.extraData).length) && this.extraData[index];
805
807
  const extraActions = [
806
808
  {
807
809
  icon: 'download',
@@ -893,6 +895,7 @@ export class YooFormCaptureComponent {
893
895
  }
894
896
  }
895
897
  deleteCapture(index) {
898
+ let isExtraDataDeleted = false;
896
899
  if (this.multiple && isArray(this.value)) {
897
900
  this.value.splice(index, 1);
898
901
  this.value = this.value.filter((item) => item); // remove empty
@@ -902,11 +905,11 @@ export class YooFormCaptureComponent {
902
905
  this.value = null;
903
906
  }
904
907
  if (this.type === 'photo') {
905
- this.clearPhotoEdit(index === -1 ? undefined : index);
908
+ isExtraDataDeleted = this.clearPhotoEdit(index === -1 ? undefined : index);
906
909
  this.clearImageRecognition();
907
910
  }
908
911
  setValueAndValidateInput(this.value, this);
909
- this.clearPhotoTag(index);
912
+ this.clearPhotoTag(index, !isExtraDataDeleted);
910
913
  }
911
914
  clearImageRecognition() {
912
915
  if (this.imageRecognitionKpiKeys && this.imageRecognitionKpiKeys.length > 0) {
@@ -1156,7 +1159,7 @@ export class YooFormCaptureComponent {
1156
1159
  (data) => {
1157
1160
  return new Promise((resolve) => {
1158
1161
  if (this.shouldTagImage()) {
1159
- this.showPhotoTagDialog(data).then((tag) => {
1162
+ return this.showPhotoTagDialog(data).then((tag) => {
1160
1163
  if (!isNullOrUndefined(tag.data)) {
1161
1164
  this.updateTagData(tag, index);
1162
1165
  resolve(data);