sf-i-reporting 1.0.77 → 1.0.78

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.
@@ -60,7 +60,6 @@ export class SfIReporting extends LitElement {
60
60
  configjson: string = "[{\"type\":\"sf-i-uploader\",\"size\":\"large\",\"label\":\"Contract Document *\",\"hint\":\"Document of the contract\",\"id\":\"contractdocuments\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"1peg5170d3\",\"allowedextensions\":\"["jpg","png","pdf","xls","xlsx","doc","docx"]\",\"extract\":\"yes\",\"maxselect\":\"1\",\"maxsize\":\"5242880\",\"allowdownload\":\"yes\",\"mandatory\":\"\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Contract Reference No. *\",\"hint\":\"Contract reference number\",\"id\":\"refno\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"date\",\"size\":\"large\",\"label\":\"Date of Execution *\",\"hint\":\"The date of execution of the contract\",\"id\":\"dateofexecution\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"date\",\"size\":\"large\",\"label\":\"Date of Expiry *\",\"hint\":\"The date on which the contract expires.\",\"id\":\"dateofexpiry\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"date\",\"size\":\"large\",\"label\":\"Date of Renewal *\",\"hint\":\"The date on which the contract renews.\",\"id\":\"dateofrenewal\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"date\",\"size\":\"large\",\"label\":\"Due Date *\",\"hint\":\"The due date for the contract.\",\"id\":\"duedate\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Contract Term *\",\"hint\":\"Term / Tenure of the contract\",\"id\":\"tenure\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Party - 1 *\",\"hint\":\"Name of the Party - 1\",\"id\":\"party1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Party - 2 *\",\"hint\":\"Name of the Party - 2\",\"id\":\"party2\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Party - 3\",\"hint\":\"Name of the Party - 3\",\"id\":\"party3\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-bricks\",\"size\":\"large\",\"label\":\"Country *\",\"hint\":\"Country for contract\",\"id\":\"country\",\"mode\":\"select\",\"savenameseparate\":\"yes\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-bricks\",\"size\":\"large\",\"label\":\"Entity *\",\"hint\":\"Entity for contract\",\"id\":\"entity\",\"dependencies\":[\"country\"],\"mode\":\"select\",\"savenameseparate\":\"yes\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\"},{\"type\":\"sf-i-bricks\",\"size\":\"large\",\"label\":\"Locations *\",\"hint\":\"Locations for contract\",\"id\":\"locations\",\"dependencies\":[\"country\",\"entity\"],\"mode\":\"multiselect\",\"mandatory\":\"\",\"copytoreopen\":\"yes\"},{\"type\":\"sf-i-bricks\",\"size\":\"large\",\"label\":\"Tags *\",\"hint\":\"Tags applied to contract\",\"id\":\"tags\",\"mode\":\"multiselect\",\"dependencies\":[\"country\",\"entity\",\"locations\"],\"searchstring\":\"-Tags\",\"mandatory\":\"\",\"copytoreopen\":\"yes\"},{\"type\":\"sf-i-form\",\"size\":\"large\",\"label\":\"Reporter *\",\"hint\":\"Reporter for the contract\",\"id\":\"reporters\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"dnytrdlrmxgsy.cloudfront.net/userprofile\",\"searchstring\":\"\",\"selectprojection\":\"name\",\"ignoredprojections\":\"["usermap","designation","project","updatetype","userid","shortid","kra","role","trainingstatute","shortnumid","lastmodifiedby","lastmodifiedtime"]\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-form\",\"size\":\"large\",\"label\":\"Approver *\",\"hint\":\"Approver for the contract\",\"id\":\"approvers\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"dnytrdlrmxgsy.cloudfront.net/userprofile\",\"searchstring\":\"\",\"selectprojection\":\"name\",\"ignoredprojections\":\"["usermap","designation","project","updatetype","userid","shortid","kra","role","trainingstatute","shortnumid","lastmodifiedby","lastmodifiedtime"]\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-form\",\"size\":\"large\",\"label\":\"Function head *\",\"hint\":\"Function head for the Contract\",\"id\":\"functionheads\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"dnytrdlrmxgsy.cloudfront.net/userprofile\",\"searchstring\":\"\",\"selectprojection\":\"name\",\"ignoredprojections\":\"["usermap","designation","project","updatetype","userid","shortid","kra","role","trainingstatute","shortnumid","lastmodifiedby","lastmodifiedtime"]\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-form\",\"size\":\"large\",\"label\":\"Auditor *\",\"hint\":\"Auditor for the Contract\",\"id\":\"auditors\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"dnytrdlrmxgsy.cloudfront.net/userprofile\",\"searchstring\":\"\",\"selectprojection\":\"name\",\"ignoredprojections\":\"["usermap","designation","project","updatetype","userid","shortid","kra","role","trainingstatute","shortnumid","lastmodifiedby","lastmodifiedtime"]\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-form\",\"size\":\"large\",\"label\":\"Viewer *\",\"hint\":\"Viewer for the contract\",\"id\":\"viewers\",\"mode\":\"multiselect-dropdown\",\"apiid\":\"dnytrdlrmxgsy.cloudfront.net/userprofile\",\"searchstring\":\"\",\"selectprojection\":\"name\",\"ignoredprojections\":\"["usermap","designation","project","updatetype","userid","shortid","kra","role","trainingstatute","shortnumid","lastmodifiedby","lastmodifiedtime"]\",\"maxselect\":\"1\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-i-select\",\"size\":\"large\",\"label\":\"Contract Type *\",\"apiid\":\"dwqyez2puoxmu.cloudfront.net/contracttype\",\"hint\":\"Type of the Contract\",\"id\":\"contracttype\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Context\",\"hint\":\"Context of the contract\",\"id\":\"context\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"textarea\",\"size\":\"small\",\"label\":\"Remarks\",\"hint\":\"Remarks on the contract\",\"id\":\"remarks\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"},{\"type\":\"sf-checklist\",\"size\":\"small\",\"label\":\"Terms *\",\"hint\":\"Terms in the contract\",\"elementsjson\":\"[{\\\"name\\\":\\\"Term1\\\"},{\\\"name\\\":\\\"Term2\\\"},{\\\"name\\\":\\\"Term3\\\"},{\\\"name\\\":\\\"Term4\\\"}]\",\"id\":\"terms\",\"mandatory\":\"\",\"copytoreopen\":\"yes\",\"displayinhistory\":\"yes\"}]"
61
61
 
62
62
  getConfigJson = () => {
63
- console.log('configjson', this.configjson);
64
63
  return JSON.parse(this.configjson)
65
64
  }
66
65
 
@@ -495,6 +494,11 @@ export class SfIReporting extends LitElement {
495
494
  margin-right: auto;
496
495
  width: fit-content;
497
496
  }
497
+
498
+ .label-button {
499
+ padding-inline: 6px;
500
+ padding-block: 1px;
501
+ }
498
502
  `;
499
503
 
500
504
  @query('.div-row-error')
@@ -922,11 +926,15 @@ export class SfIReporting extends LitElement {
922
926
  <button class="mrl-5 material-icons hide" part="button-icon-light" id="button-submit-cancel">close</button>
923
927
  <button class="mrl-5 material-icons hide" part="button-icon" id="button-submit-confirm">check save</button>
924
928
  ` : (this.flow == "details" ? `
925
- <span class="mrl-5" part="span-icon${this.published ? '-light' : ''}" id="span-submit-publish" part="span-submit-publish">${this.published ? 'Published' : 'Unpublished'}</span>
929
+ <span class="mrl-5" part="span-icon${this.published ? '-light' : ''}" id="span-submit-publish">${this.published ? 'Published' : 'Unpublished'}</span>
926
930
  <button id="button-edit" part="button-icon" class="mrl-5 material-icons button-icon-click">edit</button>
927
- <button id="button-delete" part="button-icon" class="mrl-5 material-icons button-icon-click">delete</button>
931
+ <button part="button-icon" class="mrl-5 material-symbols-outlined button-icon-click button-reopen hide" id="button-reopen">reopen_window</button>
932
+ <button id="button-delete" part="button-icon" class="mrl-5 material-icons button-icon-click hide">delete</button>
928
933
  <button id="button-delete-cancel" part="button-icon-light" class="mrl-5 material-icons button-icon-click hide">close</button>
929
934
  <button id="button-delete-confirm" part="button-icon" class="mrl-5 button-icon-click hide"><span class="material-icons">delete</span><span class="material-icons">done</span></button>
935
+ <button part="button-icon" class="mrl-5 material-symbols-outlined button-icon-click button-more" id="button-more">more_vert</button>
936
+ <button part="button-icon" class="mrl-5 material-symbols-outlined button-icon-click hide" id="button-more-close">close</button>
937
+
930
938
  ` : `
931
939
  <button class="mrl-5" part="button-icon${this.published ? '-light' : ''}" id="button-submit-publish">${this.published ? 'Unpublish' : 'Publish'}</button>
932
940
  <button id="button-edit-cancel" part="button-icon-light" class="mrl-5 material-icons button-icon-click">edit_off</button>
@@ -1018,7 +1026,7 @@ export class SfIReporting extends LitElement {
1018
1026
  (this._SfReportingButtonSubmitCancel as HTMLButtonElement).style.display = 'none';
1019
1027
  }
1020
1028
  }
1021
- for (let element of this.dataModel) {
1029
+ for (let [i, element] of this.dataModel.entries()) {
1022
1030
  if (element.type == "sf-i-form") {
1023
1031
  let form: SfIForm = (this._SfReportingContainer as HTMLDivElement).querySelector('#' + element.id) as SfIForm;
1024
1032
  if (this.mode == "view" || this.flow == "details") {
@@ -1041,11 +1049,20 @@ export class SfIReporting extends LitElement {
1041
1049
  }
1042
1050
  }
1043
1051
  let values = this.getBricksValues(element, selectedDependedValues);
1044
- console.log('bricks selecteddependantvalues', element.id, selectedDependedValues, values[1]);
1052
+ console.log('bricks selecteddependantvalues', element.id, element.value, selectedDependedValues, values[0], values[1]);
1045
1053
  bricks.namesjson = JSON.stringify(values[0])
1046
1054
  bricks.idsjson = JSON.stringify(values[1])
1047
1055
  if (element.value != '') {
1048
- bricks.prepopulateValJson = JSON.stringify(element.value)
1056
+ let arr = []
1057
+ for(let tempVal of element.value){
1058
+ console.log('bricks selecteddependantvalues tempVal', tempVal, values[0].indexOf(tempVal.split(';')[0]), values[1][(values[1].indexOf(tempVal.split(';')[0]))]);
1059
+ if(values[1][(values[0].indexOf(tempVal.split(';')[0]))] == tempVal.split(';')[1]){
1060
+ arr.push(tempVal)
1061
+ }
1062
+ }
1063
+ console.log('bricks selecteddependantvalues value', arr, element.value, element.id);
1064
+ bricks.prepopulateValJson = JSON.stringify(arr)
1065
+ this.dataModel[i].value = arr
1049
1066
  } else {
1050
1067
  bricks.prepopulateValJson = JSON.stringify([])
1051
1068
  }
@@ -1065,7 +1082,7 @@ export class SfIReporting extends LitElement {
1065
1082
  if (uploader != null) {
1066
1083
  setTimeout(() => {
1067
1084
  uploader.loadMode()
1068
- },500)
1085
+ }, 500)
1069
1086
  }
1070
1087
  } else if (element.type == "sf-i-form-select") {
1071
1088
  let buttonEditForm = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-edit-form-' + element.id) as HTMLButtonElement
@@ -1146,7 +1163,7 @@ export class SfIReporting extends LitElement {
1146
1163
  let select: SfISelect = (this._SfReportingContainer as HTMLDivElement).querySelector('#' + element.id) as SfISelect
1147
1164
  select.flow = (this.mode == "view" || this.flow == "details") ? "read" : ""
1148
1165
  if (element.value != '') {
1149
- let valArr = [element.value[0].split(';')[1]]
1166
+ let valArr = [element.value[0].split(';')[1]]
1150
1167
  select.selectedId = valArr
1151
1168
  }
1152
1169
  select.loadMode()
@@ -1156,12 +1173,12 @@ export class SfIReporting extends LitElement {
1156
1173
  await customElements.whenDefined('sf-checklist');
1157
1174
  let checklist: SfChecklist = (this._SfReportingContainer as HTMLDivElement).querySelector('#' + element.id) as SfChecklist
1158
1175
  checklist.listelements = JSON.parse(element.elementsjson)
1159
- checklist.listselection = element.value
1176
+ checklist.listselection = element.value != '' ? element.value : {}
1160
1177
  checklist.readonly = (this.mode == "view" || this.flow == "details")
1161
1178
  console.log('sf-checklist', checklist, checklist.listelements, checklist.listselection, element.value);
1162
1179
  setTimeout(() => {
1163
1180
  checklist.loadMode()
1164
- },200)
1181
+ }, 200)
1165
1182
  }
1166
1183
  }
1167
1184
  if (this.mode != "view" && this.flow != 'details') {
@@ -1221,6 +1238,69 @@ export class SfIReporting extends LitElement {
1221
1238
 
1222
1239
  let buttonEdit = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-edit') as HTMLButtonElement
1223
1240
  buttonEdit?.addEventListener('click', this.editClick)
1241
+ let buttonMore = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-more') as HTMLButtonElement
1242
+ buttonMore?.addEventListener('click', () => {
1243
+ buttonMore.style.display = 'none'
1244
+ let buttonReopen = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-reopen') as HTMLButtonElement
1245
+ if (buttonReopen != null) {
1246
+ buttonReopen.style.display = 'block'
1247
+ buttonReopen.addEventListener('click', async () => {
1248
+ this.reopenedItem = this.getPrepopulateJson()
1249
+ let oldObj = this.reopenedItem
1250
+ this.showLoader();
1251
+ console.log('item selected', this.reopenedItem);
1252
+ await this.fetchSchema();
1253
+ this.published = this.published ?? false
1254
+ let copyVals: any = {}
1255
+ for (let obj of this.dataModel) {
1256
+ if (obj.copytoreopen) {
1257
+ console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
1258
+ if (obj.type == "sf-i-bricks" && obj.savenameseparate == "yes") {
1259
+ copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
1260
+ copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
1261
+ } else {
1262
+ copyVals[obj.id] = oldObj[obj.id];
1263
+ }
1264
+ console.log('copyVals copied', copyVals)
1265
+ }
1266
+ }
1267
+ console.log('copyVals', JSON.parse(JSON.stringify(copyVals)))
1268
+ this.prepopulateValJson = JSON.stringify(copyVals)
1269
+ this.flow = "edit"
1270
+ this.loadMode();
1271
+ })
1272
+ }
1273
+ let buttonDelete = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete') as HTMLButtonElement
1274
+ if (buttonDelete != null) {
1275
+ buttonDelete.style.display = 'block'
1276
+ buttonDelete?.addEventListener('click', this.deleteClick)
1277
+ }
1278
+ let buttonMoreClose = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-more-close') as HTMLButtonElement
1279
+ buttonMoreClose.style.display = 'block'
1280
+ buttonMoreClose?.addEventListener('click', () => {
1281
+ let buttonMore = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-more') as HTMLButtonElement
1282
+ if (buttonMore != null) {
1283
+ buttonMore.style.display = 'block'
1284
+ }
1285
+ buttonMoreClose.style.display = 'none'
1286
+ let buttonReopen = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-reopen') as HTMLButtonElement
1287
+ if (buttonReopen != null) {
1288
+ buttonReopen.style.display = 'none'
1289
+ }
1290
+ let buttonDelete = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete') as HTMLButtonElement
1291
+ if (buttonDelete != null) {
1292
+ buttonDelete.style.display = 'none'
1293
+ }
1294
+ let buttonDeleteCancel = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete-cancel') as HTMLButtonElement
1295
+ if (buttonDeleteCancel != null) {
1296
+ buttonDeleteCancel.style.display = 'none'
1297
+ }
1298
+ let buttonDeleteConfirm = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete-confirm') as HTMLButtonElement
1299
+ if (buttonDeleteConfirm != null) {
1300
+ buttonDeleteConfirm.style.display = 'none'
1301
+ }
1302
+ })
1303
+ })
1224
1304
  let buttonDelete = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete') as HTMLButtonElement
1225
1305
  buttonDelete?.addEventListener('click', this.deleteClick)
1226
1306
  let buttonDeleteCancel = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-delete-cancel') as HTMLButtonElement
@@ -1381,7 +1461,7 @@ export class SfIReporting extends LitElement {
1381
1461
  }
1382
1462
  }
1383
1463
 
1384
- prepopulateValues = () => {
1464
+ prepopulateValues = (showView: boolean = true) => {
1385
1465
  console.log('prepopulating', this.getPrepopulateJson());
1386
1466
  for (let [i, element] of this.dataModel.entries()) {
1387
1467
  if (isAddButtonObject(element)) {
@@ -1437,7 +1517,7 @@ export class SfIReporting extends LitElement {
1437
1517
  this.dataModel[i].value = this.getPrepopulateJson()[element.id]
1438
1518
  }
1439
1519
  } else if (element.type == "sf-checklist") {
1440
- this.dataModel[i].value = this.getPrepopulateJson()[element.id]
1520
+ this.dataModel[i].value = this.getPrepopulateJson()[element.id] ?? {}
1441
1521
  } else if (element.type == "sf-i-select") {
1442
1522
  this.dataModel[i].value = [this.getPrepopulateJson()[element.id + 'name'] + ';' + this.getPrepopulateJson()[element.id + 'id']]
1443
1523
  } else if (element.type == "sf-i-uploader") {
@@ -1447,13 +1527,15 @@ export class SfIReporting extends LitElement {
1447
1527
  }
1448
1528
  }
1449
1529
  }
1450
- if (this.evalTimeout != null) {
1451
- clearTimeout(this.evalTimeout)
1530
+ if(showView){
1531
+ if (this.evalTimeout != null) {
1532
+ clearTimeout(this.evalTimeout)
1533
+ }
1534
+ this.evalTimeout = setTimeout(() => {
1535
+ this.evalShowProgress()
1536
+ }, 2000)
1537
+ this.populateView();
1452
1538
  }
1453
- this.evalTimeout = setTimeout(() => {
1454
- this.evalShowProgress()
1455
- }, 2000)
1456
- this.populateView();
1457
1539
  }
1458
1540
 
1459
1541
  evalShowProgress = () => {
@@ -1464,8 +1546,8 @@ export class SfIReporting extends LitElement {
1464
1546
  let sectionId = "";
1465
1547
  let flagEval = true
1466
1548
  for (let element of this.dataModel) {
1467
- if(element.type == "sf-checklist") {
1468
- console.log('sf-checklist', element, element.id);
1549
+ if (element.type == "sf-checklist") {
1550
+ console.log('sf-checklist', element, element.id);
1469
1551
  }
1470
1552
  if (isAddButtonObject(element)) {
1471
1553
  for (let childElementsArr of element.children) {
@@ -1508,9 +1590,12 @@ export class SfIReporting extends LitElement {
1508
1590
  }
1509
1591
  } else if (element.type == "sf-i-form") {
1510
1592
  console.log('evalshowprogress sf-i-form value', element.value, element.value.length, element.mandatory, element.mandatory != null);
1511
- if (element.value.length > 0) {
1512
- filled++;
1513
- sectionChildFilledCount++;
1593
+ let form = (this._SfReportingContainer as HTMLDivElement).querySelector('#' + element.id) as SfIForm
1594
+ if (form != null && form.selectedValues().length > 0) {
1595
+ if (element.value.length > 0) {
1596
+ filled++;
1597
+ sectionChildFilledCount++;
1598
+ }
1514
1599
  }
1515
1600
  } else if (element.type == "sf-i-form-select") {
1516
1601
  console.log('evalshowprogress sf-i-form-select value', element.value, Object.keys(element.value).length, element.mandatory);
@@ -1532,22 +1617,21 @@ export class SfIReporting extends LitElement {
1532
1617
  }
1533
1618
  } else if (element.type == "sf-checklist") {
1534
1619
  console.log('evalshowprogress sf-checklist value', element.value, Object.keys(element.value).length, element.mandatory, element.mandatory != null);
1535
- for(let val of Object.keys(element.value)) {
1536
- if(element.value[val] == true) {
1620
+ for (let val of Object.keys(element.value)) {
1621
+ if (element.value[val] == true) {
1537
1622
  filled++;
1538
1623
  sectionChildFilledCount++;
1539
1624
  break;
1540
1625
  }
1541
1626
  }
1542
1627
  } else if (element.type == "sf-i-uploader") {
1543
- console.log('evalshowprogress sf-i-uploader value', element.value, element.value.length, element.mandatory, element.mandatory != null);
1544
- if (element.value.length > 0) {
1628
+ if (element.value != null && element.value.length > 0) {
1545
1629
  filled++;
1546
1630
  sectionChildFilledCount++;
1547
1631
  }
1548
1632
  }
1549
1633
  if (element.mandatory != null && flagEval) {
1550
- if (element.value == "" || element.value.length < 1) {
1634
+ if (element.value == "" || element.value == null || element.value.length < 1) {
1551
1635
  flagEval = false
1552
1636
  }
1553
1637
  }
@@ -2189,6 +2273,8 @@ export class SfIReporting extends LitElement {
2189
2273
  html += `<div part="calendar-date-container" class="d-flex flex-col align-start justify-center">${this.lastCalendarGenerated == "" ? "" : ("<div class=\"d-flex align-center justify-center\" part=\"last-calendar-date\" id=\"last-calendar-date\"><span class=\"material-symbols-outlined\">update</span>&nbsp;&nbsp;Calendar synced on \n" + (new Date(parseInt(this.lastCalendarGenerated)).toLocaleDateString('en-IN') + " - " + new Date(parseInt(this.lastCalendarGenerated)).toLocaleTimeString('en-IN'))) + '</div>'}${this.nextCalendarScheduled == "" ? "" : ("<div class=\"d-flex align-center justify-center\" part=\"next-calendar-date\" id=\"next-calendar-date\"><span class=\"material-symbols-outlined\">hourglass</span>&nbsp;&nbsp;Next update on \n" + (new Date(parseInt(this.nextCalendarScheduled)).toLocaleDateString('en-IN') + " - " + new Date(parseInt(this.nextCalendarScheduled)).toLocaleTimeString('en-IN'))) + '</div>'}</div>`
2190
2274
  html += `<div class="d-flex justify-end flex-grow">`
2191
2275
  // html += `<button id="button-publish" part="button-icon" class="material-icons hide">campaign</button>`
2276
+ html += `<input class="hide" id="input-import" type="file" accept=".csv" />`
2277
+ html += `<label id="button-upload" part="button-icon" for="input-import" class="material-icons label-button ml-10">upload</label>`
2192
2278
  html += `<button id="button-new" part="button-icon" class="material-icons button-icon-click ml-10">add</button>`
2193
2279
  html += `</div>`
2194
2280
  html += `</div>`
@@ -2197,7 +2283,7 @@ export class SfIReporting extends LitElement {
2197
2283
  html += '<tr class="tablerow">'
2198
2284
  let bgClass = i % 2 == 0 ? 'td-light' : 'td-dark'
2199
2285
  html += `<td part="td-body" class="td-body"><span class="mrl-5 material-icons" part="span-submit-${item.published ? 'published' : 'unpublished'}" >${item.published ? 'radio_button_checked' : 'edit_note'}</span></td>`
2200
- html += `<td part="td-action" class="td-action"><button part="button-icon" class="material-symbols-outlined button-reopen" id="button-reopen-${i}">reopen_window</button></td>`
2286
+ // html += `<td part="td-action" class="td-action"><button part="button-icon" class="material-symbols-outlined button-reopen" id="button-reopen-${i}">reopen_window</button></td>`
2201
2287
  html += `<td part="td-action" class="td-action"><button part="button-icon" class="material-icons button-details" id="button-details-${i}">open_in_new</button></td>`
2202
2288
  for (let property of Object.keys(item)) {
2203
2289
  if (this.getIgnoreProjections().indexOf(property) < 0) {
@@ -2216,36 +2302,36 @@ export class SfIReporting extends LitElement {
2216
2302
  (this._SfReportingContainer as HTMLDivElement).innerHTML = html;
2217
2303
  (this._SfReportingContainer as HTMLDivElement).style.display = 'block';
2218
2304
 
2219
- let reopenButtons = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.button-reopen') as NodeListOf<HTMLButtonElement>
2220
- for (let reopenButton of reopenButtons) {
2221
- reopenButton.addEventListener('click', async (ev: any) => {
2222
- let target = ev.target
2223
- let index = target.id.split('-')[2]
2224
- this.reopenedItem = this.list[index]
2225
- let oldObj = this.reopenedItem
2226
- this.showLoader();
2227
- console.log('item selected', this.reopenedItem);
2228
- await this.fetchSchema();
2229
- this.published = this.list[index].published ?? false
2230
- let copyVals: any = {}
2231
- for (let obj of this.dataModel) {
2232
- if (obj.copytoreopen) {
2233
- console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
2234
- if (obj.type == "sf-i-bricks" && obj.savenameseparate == "yes") {
2235
- copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
2236
- copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
2237
- } else {
2238
- copyVals[obj.id] = oldObj[obj.id];
2239
- }
2240
- console.log('copyVals copied', copyVals)
2241
- }
2242
- }
2243
- console.log('copyVals', JSON.parse(JSON.stringify(copyVals)))
2244
- this.prepopulateValJson = JSON.stringify(copyVals)
2245
- this.flow = "edit"
2246
- this.loadMode();
2247
- })
2248
- }
2305
+ // let reopenButtons = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.button-reopen') as NodeListOf<HTMLButtonElement>
2306
+ // for (let reopenButton of reopenButtons) {
2307
+ // reopenButton.addEventListener('click', async (ev: any) => {
2308
+ // let target = ev.target
2309
+ // let index = target.id.split('-')[2]
2310
+ // this.reopenedItem = this.list[index]
2311
+ // let oldObj = this.reopenedItem
2312
+ // this.showLoader();
2313
+ // console.log('item selected', this.reopenedItem);
2314
+ // await this.fetchSchema();
2315
+ // this.published = this.list[index].published ?? false
2316
+ // let copyVals: any = {}
2317
+ // for (let obj of this.dataModel) {
2318
+ // if (obj.copytoreopen) {
2319
+ // console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
2320
+ // if (obj.type == "sf-i-bricks" && obj.savenameseparate == "yes") {
2321
+ // copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
2322
+ // copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
2323
+ // } else {
2324
+ // copyVals[obj.id] = oldObj[obj.id];
2325
+ // }
2326
+ // console.log('copyVals copied', copyVals)
2327
+ // }
2328
+ // }
2329
+ // console.log('copyVals', JSON.parse(JSON.stringify(copyVals)))
2330
+ // this.prepopulateValJson = JSON.stringify(copyVals)
2331
+ // this.flow = "edit"
2332
+ // this.loadMode();
2333
+ // })
2334
+ // }
2249
2335
  let detailsButtons = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.button-details') as NodeListOf<HTMLButtonElement>
2250
2336
  for (let detailsButton of detailsButtons) {
2251
2337
  detailsButton.addEventListener('click', (ev: any) => {
@@ -2267,11 +2353,67 @@ export class SfIReporting extends LitElement {
2267
2353
  this.showLoader();
2268
2354
  this.newClick()
2269
2355
  })
2356
+
2357
+ let inputImport = ((this._SfReportingContainer as HTMLDivElement).querySelector('#input-import') as HTMLInputElement)
2358
+ inputImport.addEventListener('change', async (ev: any) => {
2359
+ let target = ev.target as HTMLInputElement;
2360
+ console.log('file selected', target.files);
2361
+ if (target.files != null && target.files.length > 0) {
2362
+ let file = target.files[0];
2363
+ console.log('file selected', file);
2364
+ this.showLoader();
2365
+ let jsonData = await this.csvToJson(file);
2366
+ console.log('jsonData', jsonData);
2367
+ for (let element of jsonData) {
2368
+ this.published = false
2369
+ // this.prepopulateValJson = JSON.stringify(element)
2370
+ // this.populateDataModel()
2371
+ // this.prepopulateValues(false)
2372
+ // console.log('dataModel', this.dataModel);
2373
+ await this.submitNew(element)
2374
+ }
2375
+ this.hideLoader();
2376
+ // this.dataModel = jsonData;
2377
+ // this.populateView();
2378
+ }
2379
+ })
2270
2380
  let customEvent = new CustomEvent('valueChanged');
2271
2381
  this.dispatchEvent(customEvent);
2272
2382
  this.hideLoader();
2273
2383
  }
2274
2384
 
2385
+ csvToJson = async (file: File): Promise<any> => {
2386
+ const text = await file.text();
2387
+ const lines = text.split(/\r?\n/).filter(line => line.trim() !== "");
2388
+ const headers = lines[0].split(",");
2389
+
2390
+ return lines.slice(1).map((line) => {
2391
+ const values = line.split(",");
2392
+ const obj: Record<string, any> = {};
2393
+
2394
+ headers.forEach((header, i) => {
2395
+ let value = values[i];
2396
+
2397
+ // Clean up wrapped quotes ("" to "), and trim outer quotes
2398
+ if (value?.startsWith('"') && value?.endsWith('"')) {
2399
+ value = value.slice(1, -1).replace(/""/g, '"');
2400
+ }
2401
+
2402
+ // Try to parse array-like fields (if it's valid JSON after cleaning)
2403
+ try {
2404
+ const parsed = JSON.parse(value);
2405
+ obj[header] = parsed;
2406
+ } catch {
2407
+ obj[header] = value;
2408
+ }
2409
+ });
2410
+
2411
+ return obj;
2412
+ });
2413
+ }
2414
+
2415
+
2416
+
2275
2417
  loadMode = async () => {
2276
2418
  console.log('loadmode', this.mode, this.flow);
2277
2419
  if (this.mode == "view") {
@@ -2466,13 +2608,13 @@ export class SfIReporting extends LitElement {
2466
2608
  }
2467
2609
  }
2468
2610
 
2469
- submitNew = async () => {
2470
- console.log('adding', this.selectedValues());
2611
+ submitNew = async (obj: any = this.selectedValues()) => {
2612
+ console.log('adding', obj);
2471
2613
  let url = "https://" + this.apiId + "/add";
2472
2614
 
2473
- let body: any = { projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published }
2615
+ let body: any = { projectid: this.projectid, object: obj, schema: this.getConfigJson(), published: this.published }
2474
2616
 
2475
- // console.log('adding', body, url);
2617
+ console.log('adding', body, url);
2476
2618
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
2477
2619
  const xhr: any = (await this.prepareXhr(body, url, this._SfLoader, authorization)) as any;
2478
2620
  this._SfLoader.innerHTML = '';