@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.
@@ -622,7 +622,7 @@ const YooFormCaptureComponent = class {
622
622
  initTags() {
623
623
  if (this.multiple) {
624
624
  for (let i = 0; i < this.max; i++) {
625
- this.extraData = this.extraData || [];
625
+ this.extraData = this.extraData || {};
626
626
  this.extraData[i] = this.extraData[i] || {};
627
627
  this.extraData[i]['tags'] = this.extraData[i]['tags'] || [];
628
628
  }
@@ -1044,7 +1044,7 @@ const YooFormCaptureComponent = class {
1044
1044
  (data) => {
1045
1045
  return new Promise((resolve) => {
1046
1046
  if (this.shouldTagImage()) {
1047
- this.showPhotoTagDialog(data).then((tag) => {
1047
+ return this.showPhotoTagDialog(data).then((tag) => {
1048
1048
  if (!isNullOrUndefined(tag.data)) {
1049
1049
  this.updateTagData(tag, captureIndex);
1050
1050
  resolve(data);
@@ -1168,6 +1168,7 @@ const YooFormCaptureComponent = class {
1168
1168
  });
1169
1169
  }
1170
1170
  clearPhotoEdit(index) {
1171
+ let isExtraDataDeleted = false;
1171
1172
  if (!index && index !== 0) {
1172
1173
  if (this.extraData && (this.extraData.drawings || (this.extraData.annotations && this.extraData.annotations.length > 0))) {
1173
1174
  this.extraData = { drawings: null, annotations: [], stitch: null };
@@ -1181,32 +1182,33 @@ const YooFormCaptureComponent = class {
1181
1182
  Object.keys(this.extraData).forEach((item, i) => {
1182
1183
  newExtraData[i] = this.extraData[item];
1183
1184
  });
1184
- // Object.keys(obj).filter(k => obj[k]).sort((a,b) => a-b).reduce((acc, cur) => { acc[cur] = obj[cur]; return acc }, {})
1185
1185
  this.extraDataChanged.emit(newExtraData);
1186
+ isExtraDataDeleted = true;
1186
1187
  }
1187
1188
  }
1189
+ return isExtraDataDeleted;
1188
1190
  }
1189
- clearPhotoTag(index) {
1190
- if (this.onHasTag(index)) {
1191
- let newExtraData = {};
1192
- if (this.multiple) {
1191
+ clearPhotoTag(index, deleteExtraData = true) {
1192
+ let newExtraData = {};
1193
+ if (this.multiple) {
1194
+ if (deleteExtraData) {
1193
1195
  delete this.extraData[index];
1194
1196
  Object.keys(this.extraData).forEach((item, i) => {
1195
1197
  newExtraData[i] = this.extraData[item];
1196
1198
  });
1197
1199
  this.extraDataChanged.emit(newExtraData);
1198
1200
  }
1199
- else {
1200
- this.extraData['tags'] = [];
1201
- newExtraData = this.extraData;
1202
- }
1203
- this.extraDataChanged.emit(newExtraData);
1204
1201
  }
1202
+ else {
1203
+ this.extraData['tags'] = [];
1204
+ newExtraData = this.extraData;
1205
+ }
1206
+ this.extraDataChanged.emit(newExtraData);
1205
1207
  }
1206
1208
  openPhotoEditorPreview(index, forceReadonly = false) {
1207
1209
  var _a;
1208
1210
  const imgSrc = this.getFieldValue(index);
1209
- const isMultipleData = isFinite(index) && this.extraData && isArray(this.extraData) && !!this.extraData.length && this.extraData[index];
1211
+ const isMultipleData = isFinite(index) && this.extraData && ((isArray(this.extraData) && !!this.extraData.length) || !!Object.keys(this.extraData).length) && this.extraData[index];
1210
1212
  const extraActions = [
1211
1213
  {
1212
1214
  icon: 'download',
@@ -1298,6 +1300,7 @@ const YooFormCaptureComponent = class {
1298
1300
  }
1299
1301
  }
1300
1302
  deleteCapture(index) {
1303
+ let isExtraDataDeleted = false;
1301
1304
  if (this.multiple && isArray(this.value)) {
1302
1305
  this.value.splice(index, 1);
1303
1306
  this.value = this.value.filter((item) => item); // remove empty
@@ -1307,11 +1310,11 @@ const YooFormCaptureComponent = class {
1307
1310
  this.value = null;
1308
1311
  }
1309
1312
  if (this.type === 'photo') {
1310
- this.clearPhotoEdit(index === -1 ? undefined : index);
1313
+ isExtraDataDeleted = this.clearPhotoEdit(index === -1 ? undefined : index);
1311
1314
  this.clearImageRecognition();
1312
1315
  }
1313
1316
  setValueAndValidateInput(this.value, this);
1314
- this.clearPhotoTag(index);
1317
+ this.clearPhotoTag(index, !isExtraDataDeleted);
1315
1318
  }
1316
1319
  clearImageRecognition() {
1317
1320
  if (this.imageRecognitionKpiKeys && this.imageRecognitionKpiKeys.length > 0) {
@@ -1561,7 +1564,7 @@ const YooFormCaptureComponent = class {
1561
1564
  (data) => {
1562
1565
  return new Promise((resolve) => {
1563
1566
  if (this.shouldTagImage()) {
1564
- this.showPhotoTagDialog(data).then((tag) => {
1567
+ return this.showPhotoTagDialog(data).then((tag) => {
1565
1568
  if (!isNullOrUndefined(tag.data)) {
1566
1569
  this.updateTagData(tag, index);
1567
1570
  resolve(data);
@@ -147,8 +147,8 @@ export declare class YooFormCaptureComponent implements IFormCapture {
147
147
  getTargetElement(index: any): any;
148
148
  onFileSelect(index: number): Promise<void>;
149
149
  onOpenCropper(file: any): Promise<any>;
150
- clearPhotoEdit(index?: number): void;
151
- clearPhotoTag(index?: number): void;
150
+ clearPhotoEdit(index?: number): boolean;
151
+ clearPhotoTag(index?: number, deleteExtraData?: boolean): void;
152
152
  openPhotoEditorPreview(index?: number, forceReadonly?: boolean): void;
153
153
  /**
154
154
  * Need to handle this differently depending on whether we have are opening the preview from the image
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yoobic/yobi",
3
- "version": "7.7.113",
3
+ "version": "7.7.114",
4
4
  "description": "Yobi - Yoobic Design System",
5
5
  "module": "dist/index.js",
6
6
  "main": "dist/index.cjs.js",