sf-i-reporting 1.0.69 → 1.0.70

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/sf-i-reporting.js CHANGED
@@ -38,6 +38,7 @@ let SfIReporting = class SfIReporting extends LitElement {
38
38
  constructor() {
39
39
  super();
40
40
  this.apiId = "";
41
+ this.apiIdUploader = "";
41
42
  this.projectid = "";
42
43
  this.projectname = "";
43
44
  this.configjson = "[]";
@@ -76,6 +77,7 @@ let SfIReporting = class SfIReporting extends LitElement {
76
77
  // selectedItem: any = {};
77
78
  this.selectedItem = { id: "2b1d4da9-7cfe-4861-91f2-1727d0cc70b4" };
78
79
  this.selectedItemIds = [];
80
+ this.reopenedItem = {};
79
81
  this.decryptProjectId = "";
80
82
  this.decryptFileName = "";
81
83
  this.truncate = (str, n, useWordBoundary) => {
@@ -488,9 +490,6 @@ let SfIReporting = class SfIReporting extends LitElement {
488
490
  </div>
489
491
  `;
490
492
  }
491
- // <div class="d-flex w-100-m-0 justify-center align-center">
492
- // <button id="button-save-form" part="button-icon" class="button-icon-click"><span class="material-icons">check</span></button>
493
- // </div>
494
493
  this._SfReportingContainer.innerHTML = html;
495
494
  this._SfReportingContainer.style.display = 'block';
496
495
  this.initSectionListeners();
@@ -515,7 +514,7 @@ let SfIReporting = class SfIReporting extends LitElement {
515
514
  for (let element of this.dataModel) {
516
515
  if (element.type == "sf-i-form") {
517
516
  let form = this._SfReportingContainer.querySelector('#' + element.id);
518
- if (this.flow == "details") {
517
+ if (this.mode == "view" || this.flow == "details") {
519
518
  form.flow = "read";
520
519
  }
521
520
  if (element.value != '') {
@@ -545,7 +544,7 @@ let SfIReporting = class SfIReporting extends LitElement {
545
544
  bricks.prepopulateValJson = JSON.stringify([]);
546
545
  }
547
546
  console.log('bricks element values', bricks.prepopulateValJson, element.id);
548
- if (this.flow == "details") {
547
+ if (this.mode == "view" || this.flow == "details") {
549
548
  bricks.flow = "view";
550
549
  }
551
550
  else {
@@ -555,7 +554,7 @@ let SfIReporting = class SfIReporting extends LitElement {
555
554
  else if (element.type == "sf-i-uploader") {
556
555
  let uploader = this._SfReportingContainer.querySelector('#' + element.id);
557
556
  uploader.prepopulatedInputArr = JSON.stringify((_a = element.value) !== null && _a !== void 0 ? _a : []);
558
- uploader.readOnly = (this.flow == "details");
557
+ uploader.readOnly = (this.mode == "view" || this.flow == "details");
559
558
  uploader.loadMode();
560
559
  }
561
560
  else if (element.type == "sf-i-form-select") {
@@ -637,7 +636,7 @@ let SfIReporting = class SfIReporting extends LitElement {
637
636
  });
638
637
  }
639
638
  }
640
- if (this.flow != 'details') {
639
+ if (this.mode != "view" && this.flow != 'details') {
641
640
  let selectedOptions = this._SfReportingContainer.querySelectorAll('.selected-option');
642
641
  for (let selectedOption of selectedOptions) {
643
642
  selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.addEventListener('click', async (ev) => {
@@ -701,7 +700,99 @@ let SfIReporting = class SfIReporting extends LitElement {
701
700
  this.evalShowProgress();
702
701
  this._SfReportingContainer.querySelector('.form-container').scrollTo({ top: scrollTopTarget, left: 0 });
703
702
  this.hideLoader();
703
+ let customEvent = new CustomEvent('valueChanged');
704
+ this.dispatchEvent(customEvent);
704
705
  }, 500);
706
+ if (this.getPrepopulateJson().history != null && this.getPrepopulateJson().history.length > 0) {
707
+ this.populateHistory();
708
+ }
709
+ };
710
+ this.populateHistory = () => {
711
+ var _a;
712
+ let formContainer = this._SfReportingContainer.querySelector('.form-container');
713
+ if (formContainer != null) {
714
+ let html = '';
715
+ html += `
716
+ <div class="d-flex flex-col" part="section-container"><div id="history" class="section-head d-flex align-center justify-between" part="section-head-collapsed"><h3 part="section-title-collapsed" id="section-history-title">History</h3><div class="material-icons" id="section-history-icon">keyboard_arrow_down</div></div><div id="section-history-body" class="section-body d-flex ${this.formviewclass} hide" part="section-body">
717
+ `;
718
+ for (let [index, historyItem] of this.getPrepopulateJson().history.entries()) {
719
+ console.log('history', historyItem);
720
+ html += `<sf-i-reporting id="history-reporting-${index}" class="history-reporting" exportparts="uploader-extracted-text:reporting-uploader-extracted-text, uploader-sf-upload-message:reporting-uploader-sf-upload-message, uploader-sf-upload-submessage:reporting-uploader-sf-upload-submessage, uploader-extracted-text-chip:reporting-uploader-extracted-text-chip, uploader-extracted-text-chip-failed:reporting-uploader-extracted-text-chip-failed, uploader-doctype-verify-badge:reporting-uploader-doctype-verify-badge,span-submit-published:reporting-span-submit-published, span-submit-unpublished:reporting-span-submit-unpublished, reporting-container:reporting-reporting-container, button-icon:reporting-button-icon, uploader-button-icon:reporting-uploader-button-icon, sf-i-form-modal-container:reporting-sf-i-form-modal-container, next-calendar-date:reporting-next-calendar-date, last-calendar-date:reporting-last-calendar-date, input-publish-checkbox:reporting-input-publish-checkbox, button-icon-light:reporting-button-icon-light, button-icon-small:reporting-button-icon-small, uploader-input-label:reporting-uploader-input-label, input-radio:reporting-input-radio, radio-label:reporting-radio-label, input-textarea:reporting-input-textarea, input-date:reporting-input-date, input-select-single:reporting-input-select-single, textarea-container:reporting-textarea-container, section-body:reporting-section-body, section-container:reporting-section-container, date-container:reporting-date-container, input-sf-i-uploader:reporting-input-sf-i-uploader, published-container:reporting-published-container, selected-option:reporting-selected-option, input-select-multi-option:reporting-input-select-multi-option, select-option-label:reporting-select-option-label, input-sf-i-form:reporting-input-sf-i-form, input-sf-i-bricks:reporting-input-sf-i-bricks, uploader-input:reporting-uploader-input, form-container:reporting-form-container, published-container:reporting-published-container, form-container-published:reporting-form-container-published, subsection:reporting-subsection, results-title:reporting-results-title, td-head:reporting-td-head, td-action:reporting-td-action, td-body:reporting-td-body, td-body-2:reporting-td-body-2, add-button:reporting-add-button, uploader-button:reporting-uploader-button, section-head-collapsed:reporting-section-head-collapsed, section-title-expanded:reporting-section-title-expanded, section-title-collapsed:reporting-section-title-collapsed, section-head-expanded:reporting-section-head-expanded, progress-bar-finished:reporting-progress-bar-finished, progress-bar-complete:reporting-progress-bar-complete, progress-bar-incomplete:reporting-progress-bar-incomplete, section-success-icon:reporting-section-success-icon, section-body:reporting-section-body, title-section:reporting-title-section, button-lg:reporting-button-lg, uploader-detail-container:reporting-uploader-detail-container, textarea-label:reporting-textarea-label, date-label:reporting-date-label" name="Notice Details" mode="view" editdisable="true" formviewclass="flex-wrap" prepopulatevaljson="${JSON.stringify(historyItem.object).replace(/"/g, '&quot;')}"></sf-i-reporting>`;
721
+ let comments = (_a = historyItem.object.comments) !== null && _a !== void 0 ? _a : [];
722
+ if (historyItem.object.documents != null && historyItem.object.documents.length > 0) {
723
+ html += '<div class="d-flex justify-between m-20">';
724
+ html += '<h3 part="history-docs-title" class="m-0"><br />Documents</h3>';
725
+ html += '</div>';
726
+ html += `
727
+ <sf-i-uploader prepopulatedInputArr="${JSON.stringify(historyItem.object.documents).replace(/"/g, '&quot;')}" exportparts="detail-container:uploader-detail-container, errmsg:uploader-errmsg, successmsg:uploader-successmsg, sf-upload-message:uploader:sf-upload-message, sf-upload-submessage: uploader-sf-upload-submessage, doctype-verify-badge: uploader-doctype-verify-badge, details-controls-container: uploader-details-controls-container, button-icon: uploader-button-icon, pdf-controls-container: uploader-pdf-controls-container, pdf-pages: uploader-pdf-pages, pdf-page-num: uploader-pdf-page-num, pdf-page-count: uploader-pdf-page-count, pdf-canvas: uploader-pdf-canvas, image-container: uploader-image-container, image-component: uploader-image-component, pdf-thumbnail-container: uploader-pdf-thumbnail-container, pdf-canvas-thumbnail: uploader-pdf-canvas-thumbnail, sf-uploader-download-message: uploader-sf-uploader-download-message, input: uploader-input, upload-buttons-container: uploader-upload-buttons-container, doctype-badge: uploader-doctype-badge, upload-status: uploader-upload-status, ext-badge:uploader-ext-badge, extracted-meta: uploader-extracted-meta, extracted-text-chip: uploader-extracted-text-chip, extracted-text-chip-parsed: uploader-extracted-text-chip-parsed, extracted-text-chip-failed: uploader-extracted-text-chip-failed, matches-title: uploader-matches-title, matches:uploader-matches, extracted-title: uploader-extracted-title, extracted-text: uploader-extracted-text, disclaimer-message-container: uploader-disclaimer-message-container, message-container: uploader-message-container, button: uploader-button" class="reporting-sf-i-uploader" part="input-sf-i-uploader" id="history-doc-uploader-${index}" maximize="yes" max="${historyItem.object.documents.length}" apiid="${this.apiIdUploader}" projectid="${this.projectid}" mode="view"></sf-i-uploader>
728
+ `;
729
+ }
730
+ html += '<div class="d-flex justify-between m-20">';
731
+ html += '<h3 part="history-comments-title" class="m-0"><br />Comments</h3>';
732
+ html += '</div>';
733
+ html += '<div class="m-20">';
734
+ html += '<div class="d-flex flex-col">';
735
+ for (var i = 0; i < comments.length; i++) {
736
+ html += '<div part="commentbox" class="d-flex commentbox ' + (comments[i].author + "").toLowerCase() + 'box">';
737
+ html += '<div class="mr-20 d-flex flex-col align-end"><span part="comment-username">' + (comments[i].username != null ? comments[i].username : '') + '</span><span part="td-head">' + comments[i].author + '</span></div>';
738
+ const onlyCommentText = (comments[i].comment + "").replace(/ *\([^)]*\) */g, "").trim();
739
+ try {
740
+ const jsonComments = JSON.parse(onlyCommentText);
741
+ if (Util.isInteger(jsonComments)) {
742
+ html += '<div class="">' + comments[i].comment + '<br /><small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
743
+ }
744
+ else {
745
+ //console.log('json comments', jsonComments);
746
+ var htmlTable = '';
747
+ for (var j = 0; j < Object.keys(jsonComments).length; j++) {
748
+ htmlTable += '<div class="mb-20">';
749
+ htmlTable += ('<div part="detail-head">' + Object.keys(jsonComments)[j] + '</div>');
750
+ htmlTable += ('<sf-i-elastic-text text="' + jsonComments[Object.keys(jsonComments)[j]] + '" minLength="20"></sf-i-elastic-text>');
751
+ htmlTable += '</div>';
752
+ }
753
+ html += '<div class="">' + htmlTable + '<small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
754
+ }
755
+ }
756
+ catch (e) {
757
+ //console.log('json comments exception', comments[i]);
758
+ html += '<div class="">' + comments[i].comment + '<br /><small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
759
+ }
760
+ html += '</div>';
761
+ }
762
+ if (comments.length === 0) {
763
+ html += '<div><strong>No comments!</strong></div>';
764
+ }
765
+ html += '</div>';
766
+ html += '</div>';
767
+ }
768
+ html += '</div>';
769
+ formContainer.insertAdjacentHTML('beforeend', html);
770
+ let sectionHistory = formContainer.querySelector('#history');
771
+ sectionHistory.addEventListener('click', () => {
772
+ let sectionHistoryBody = formContainer.querySelector('#section-history-body');
773
+ let sectionHistoryTitle = formContainer.querySelector('#section-history-title');
774
+ let sectionHistoryIcon = formContainer.querySelector('#section-history-icon');
775
+ if (sectionHistoryBody.style.display == 'block') {
776
+ sectionHistory.setAttribute('part', 'section-head-collapsed');
777
+ sectionHistoryBody.style.display = 'none';
778
+ sectionHistoryTitle.setAttribute('part', 'section-title-collapsed');
779
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_down';
780
+ }
781
+ else {
782
+ sectionHistory.setAttribute('part', 'section-head-expanded');
783
+ sectionHistoryBody.style.display = 'block';
784
+ sectionHistoryTitle.setAttribute('part', 'section-title-expanded');
785
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_up';
786
+ }
787
+ });
788
+ let historyReportings = formContainer.querySelectorAll('.history-reporting');
789
+ for (let historyReporting of historyReportings) {
790
+ let id = historyReporting.id;
791
+ let index = id.split('-')[2];
792
+ historyReporting.configjson = JSON.stringify(this.getPrepopulateJson().history[index].schema);
793
+ // historyReporting.loadMode();
794
+ }
795
+ }
705
796
  };
706
797
  this.prepopulateValues = () => {
707
798
  var _a, _b, _c, _d, _e, _f, _g;
@@ -1309,9 +1400,13 @@ let SfIReporting = class SfIReporting extends LitElement {
1309
1400
  return elementHtml;
1310
1401
  };
1311
1402
  this.renderElement = (dataObj) => {
1312
- var _a, _b;
1403
+ var _a, _b, _c;
1313
1404
  let elementHtml = "";
1314
1405
  console.log('rendering obj', dataObj.type);
1406
+ let elementLabel = (_a = dataObj.label) !== null && _a !== void 0 ? _a : "";
1407
+ if (this.editdisable == "true") {
1408
+ elementLabel = elementLabel.replace(/ */g, '');
1409
+ }
1315
1410
  if (dataObj.type == "section") {
1316
1411
  elementHtml += `<div class="d-flex flex-col" part="section-container"><div id="${dataObj.id}" class="section-head d-flex align-center justify-between" part="${dataObj.collapse == "true" ? 'section-head-collapsed' : 'section-head-expanded'}"><h3 part="${dataObj.collapse == "true" ? 'section-title-collapsed' : 'section-title-expanded'}">${dataObj.name}</h3><div id="${dataObj.id}-success" part="section-success-icon"><div class="material-icons">${dataObj.collapse == "true" ? "keyboard_arrow_down" : "keyboard_arrow_up"}</div></div></div><div class="section-body d-flex ${this.formviewclass} ${dataObj.collapse == "true" ? 'hide' : ''}" part="section-body"> `;
1317
1412
  }
@@ -1320,33 +1415,33 @@ let SfIReporting = class SfIReporting extends LitElement {
1320
1415
  }
1321
1416
  else if (dataObj.type == "textarea") {
1322
1417
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1323
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1418
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1324
1419
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1325
- <textarea rows="${dataObj.size == "small" ? "4" : (dataObj.size == "smallest" ? "1" : "10")}" id="${dataObj.id}" type="text" class=" reporting-textarea" part="input-textarea" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""}>${dataObj.value}</textarea>
1420
+ <${this.editdisable == "true" ? 'div' : 'textarea'} rows="${dataObj.size == "small" ? "4" : (dataObj.size == "smallest" ? "1" : "10")}" id="${dataObj.id}" type="text" class=" reporting-textarea" part="input-textarea" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""}>${dataObj.value}</${this.editdisable == "true" ? 'div' : 'textarea'}>
1326
1421
  </div>`;
1327
1422
  }
1328
1423
  else if (dataObj.type == "yesno+textarea") {
1329
1424
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1330
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1425
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1331
1426
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1332
1427
  <div class="d-flex">`;
1333
1428
  for (let option of dataObj.options) {
1334
1429
  elementHtml += `<input type="radio" id="${dataObj.id}-${option.toLowerCase().replace(/ /g, '_')}" name="${dataObj.id}" class="reporting-radio" part="input-radio" value="${option}" ${this.mode == "view" || this.flow == "details" ? "disabled" : ""} ${dataObj.value[0] == option ? "checked" : ""}><label id="${dataObj.id}-${option.toLowerCase().replace(/ /g, '_')}-label" part="radio-label">${option}</label>`;
1335
1430
  }
1336
1431
  elementHtml += `</div>
1337
- <textarea rows="${dataObj.size == "small" ? "4" : "10"}" id="${dataObj.id}-textarea" type="text" class="reporting-textarea" part="input-textarea" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""}>${(_a = dataObj.value[1]) !== null && _a !== void 0 ? _a : ""}</textarea>
1432
+ <${this.editdisable == "true" ? 'div' : 'textarea'} rows="${dataObj.size == "small" ? "4" : "10"}" id="${dataObj.id}-textarea" type="text" class="reporting-textarea" part="input-textarea" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""}>${(_b = dataObj.value[1]) !== null && _b !== void 0 ? _b : ""}</${this.editdisable == "true" ? 'div' : 'textarea'}>
1338
1433
  </div>`;
1339
1434
  }
1340
1435
  else if (dataObj.type == "date") {
1341
1436
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1342
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1437
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1343
1438
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1344
1439
  <input class="reporting-date" id="${dataObj.id}" part="input-date" type="date" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""} value="${dataObj.value}"/>
1345
1440
  </div>`;
1346
1441
  }
1347
1442
  else if (dataObj.type == "sf-i-form") {
1348
1443
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1349
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1444
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1350
1445
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1351
1446
  <sf-i-form exportparts="td-action:form-td-action, td-body" id="${dataObj.id}" class="reporting-sf-i-form" part="input-sf-i-form" name="${dataObj.name}" label="" apiId="${dataObj.apiid}" mode="${dataObj.mode}" searchPhrase="${(dataObj.mode == "multiselect-dropdown" ? (this.projectname + "&") : "") + dataObj.searchstring}" selectProjection="${dataObj.selectprojection}" ignoreProjections="${dataObj.ignoredprojections}" ${parseInt(dataObj.maxselect) == 0 ? "" : `maxselect="${dataObj.maxselect}"`} ${dataObj.mandatory != null ? "mandatory=\"\"" : ""}></sf-i-form>
1352
1447
  </div>`;
@@ -1365,16 +1460,16 @@ let SfIReporting = class SfIReporting extends LitElement {
1365
1460
  valToBeShown = dataObj.value.reference;
1366
1461
  }
1367
1462
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1368
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1463
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1369
1464
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1370
1465
  <div class="d-flex flex-col align-start" part="form-select-container">
1371
1466
  <div class"d-flex align-center" part="form-selected-value">
1372
- ${((_b = Object.keys(dataObj.value)) !== null && _b !== void 0 ? _b : []).length > 0 ? (`
1467
+ ${((_c = Object.keys(dataObj.value)) !== null && _c !== void 0 ? _c : []).length > 0 ? (`
1373
1468
  <div class="selected-option d-flex justtify-center align-center" part="selected-option" id="selected-option-${dataObj.id}">
1374
- ${this.flow == "details" ? '' : '<span class="material-icons selected-option-icon mr-10">cancel</span>'}
1469
+ ${this.mode == "view" || this.flow == "details" ? '' : '<span class="material-icons selected-option-icon mr-10">cancel</span>'}
1375
1470
  <label class="selected-option-label" part="selected-option-label">${valToBeShown}</label>
1376
1471
  </div>`) : (`
1377
- ${(this.flow == "details") ? '' :
1472
+ ${(this.mode == "view" || this.flow == "details") ? '' :
1378
1473
  `<button id="button-edit-form-${dataObj.id}" part="button-icon" class="material-icons button-edit-form button-icon-click">edit</button>`}
1379
1474
  `)}
1380
1475
  </div>
@@ -1383,15 +1478,15 @@ let SfIReporting = class SfIReporting extends LitElement {
1383
1478
  }
1384
1479
  else if (dataObj.type == "sf-i-bricks") {
1385
1480
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1386
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1481
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1387
1482
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1388
1483
  <sf-i-bricks exportparts="input-select-single, selected-container, selected-option, input-select-multi-option, select-option-label, selected-option-label" id="${dataObj.id}" mode="${dataObj.mode}"
1389
- ${this.flow == 'details' ? 'flow="view"' : ''} class="reporting-sf-i-bricks" part="input-sf-i-bricks" name="${dataObj.name}" ${parseInt(dataObj.maxselect) == 0 ? "" : `maxselect="${dataObj.maxselect}"`} ${dataObj.mandatory != null ? "mandatory=\"\"" : ""}></sf-i-bricks>
1484
+ ${this.mode == "view" || this.flow == 'details' ? 'flow="view"' : ''} class="reporting-sf-i-bricks" part="input-sf-i-bricks" name="${dataObj.name}" ${parseInt(dataObj.maxselect) == 0 ? "" : `maxselect="${dataObj.maxselect}"`} ${dataObj.mandatory != null ? "mandatory=\"\"" : ""}></sf-i-bricks>
1390
1485
  </div>`;
1391
1486
  }
1392
1487
  else if (dataObj.type == "sf-i-uploader") {
1393
1488
  elementHtml += `<div part="uploader-container" class="d-flex flex-col flex-grow">
1394
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1489
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1395
1490
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1396
1491
  <sf-i-uploader exportparts="detail-container:uploader-detail-container, errmsg:uploader-errmsg, successmsg:uploader-successmsg, sf-upload-message:uploader:sf-upload-message, sf-upload-submessage: uploader-sf-upload-submessage, doctype-verify-badge: uploader-doctype-verify-badge, details-controls-container: uploader-details-controls-container, button-icon: uploader-button-icon, pdf-controls-container: uploader-pdf-controls-container, pdf-pages: uploader-pdf-pages, pdf-page-num: uploader-pdf-page-num, pdf-page-count: uploader-pdf-page-count, pdf-canvas: uploader-pdf-canvas, image-container: uploader-image-container, image-component: uploader-image-component, pdf-thumbnail-container: uploader-pdf-thumbnail-container, pdf-canvas-thumbnail: uploader-pdf-canvas-thumbnail, sf-uploader-download-message: uploader-sf-uploader-download-message, input: uploader-input, upload-buttons-container: uploader-upload-buttons-container, doctype-badge: uploader-doctype-badge, upload-status: uploader-upload-status, ext-badge:uploader-ext-badge, extracted-meta: uploader-extracted-meta, extracted-text-chip: uploader-extracted-text-chip, extracted-text-chip-parsed: uploader-extracted-text-chip-parsed, extracted-text-chip-failed: uploader-extracted-text-chip-failed, matches-title: uploader-matches-title, matches:uploader-matches, extracted-title: uploader-extracted-title, extracted-text: uploader-extracted-text, disclaimer-message-container: uploader-disclaimer-message-container, message-container: uploader-message-container, button: uploader-button" class="reporting-sf-i-uploader" part="input-sf-i-uploader" id="${dataObj.id}" max="${dataObj.maxselect}" apiid="${dataObj.apiid}" allowedextensions="${dataObj.allowedextensions}" extract="${dataObj.extract}" projectid="${this.projectid}" maxsize="${dataObj.maxsize}" allowdownload="${dataObj.allowdownload}"></sf-i-uploader>
1397
1492
  </div>`;
@@ -1433,6 +1528,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1433
1528
  html += '<tr class="tablerow">';
1434
1529
  let bgClass = i % 2 == 0 ? 'td-light' : 'td-dark';
1435
1530
  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>`;
1531
+ 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>`;
1436
1532
  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>`;
1437
1533
  for (let property of Object.keys(item)) {
1438
1534
  if (this.getIgnoreProjections().indexOf(property) < 0) {
@@ -1449,6 +1545,37 @@ let SfIReporting = class SfIReporting extends LitElement {
1449
1545
  html += '</table>';
1450
1546
  this._SfReportingContainer.innerHTML = html;
1451
1547
  this._SfReportingContainer.style.display = 'block';
1548
+ let reopenButtons = this._SfReportingContainer.querySelectorAll('.button-reopen');
1549
+ for (let reopenButton of reopenButtons) {
1550
+ reopenButton.addEventListener('click', async (ev) => {
1551
+ var _a;
1552
+ let target = ev.target;
1553
+ let index = target.id.split('-')[2];
1554
+ this.reopenedItem = this.list[index];
1555
+ let oldObj = this.reopenedItem;
1556
+ console.log('item selected', this.reopenedItem);
1557
+ await this.fetchSchema();
1558
+ this.published = (_a = this.list[index].published) !== null && _a !== void 0 ? _a : false;
1559
+ let copyVals = {};
1560
+ for (let obj of this.dataModel) {
1561
+ if (obj.copytoreopen) {
1562
+ console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
1563
+ if (obj.type == "sf-i-bricks" && obj.savenameseparate == "yes") {
1564
+ copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
1565
+ copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
1566
+ }
1567
+ else {
1568
+ copyVals[obj.id] = oldObj[obj.id];
1569
+ }
1570
+ console.log('copyVals copied', copyVals);
1571
+ }
1572
+ }
1573
+ console.log('copyVals', JSON.parse(JSON.stringify(copyVals)));
1574
+ this.prepopulateValJson = JSON.stringify(copyVals);
1575
+ this.flow = "edit";
1576
+ this.loadMode();
1577
+ });
1578
+ }
1452
1579
  let detailsButtons = this._SfReportingContainer.querySelectorAll('.button-details');
1453
1580
  for (let detailsButton of detailsButtons) {
1454
1581
  detailsButton.addEventListener('click', (ev) => {
@@ -1460,39 +1587,6 @@ let SfIReporting = class SfIReporting extends LitElement {
1460
1587
  this.loadMode();
1461
1588
  });
1462
1589
  }
1463
- // let selectInputs = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.input-select') as NodeListOf<HTMLInputElement>
1464
- // for(let selectInput of selectInputs){
1465
- // selectInput.addEventListener('change',(ev: any) => {
1466
- // let target = ev.target
1467
- // let index = target.id.split('-')[2]
1468
- // if(target.checked){
1469
- // if(this.selectedItemIds.indexOf(this.list[index].id) < 0){
1470
- // this.selectedItemIds.push(this.list[index].id)
1471
- // }
1472
- // }else{
1473
- // if(this.selectedItemIds.indexOf(this.list[index].id) >= 0){
1474
- // this.selectedItemIds.splice(this.selectedItemIds.indexOf(this.list[index].id), 1)
1475
- // }
1476
- // }
1477
- // if(this.selectedItemIds.length > 0){
1478
- // ((this._SfReportingContainer as HTMLDivElement).querySelector('#button-publish') as HTMLButtonElement).style.display = 'flex'
1479
- // }else{
1480
- // ((this._SfReportingContainer as HTMLDivElement).querySelector('#button-publish') as HTMLButtonElement).style.display = 'none'
1481
- // }
1482
- // })
1483
- // }
1484
- // let inputSelectAll = (this._SfReportingContainer as HTMLDivElement).querySelector('#input-select-all') as HTMLInputElement
1485
- // inputSelectAll.addEventListener('click',(ev: any)=>{
1486
- // let target = ev.target;
1487
- // let selectInputs = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.input-select') as NodeListOf<HTMLInputElement>
1488
- // for(let selectInput of selectInputs){
1489
- // selectInput.checked = target.checked
1490
- // var event = document.createEvent("HTMLEvents");
1491
- // event.initEvent('change', false, true);
1492
- // selectInput.dispatchEvent(event);
1493
- // }
1494
- // })
1495
- // inputSelectAll.style.display = this.list.length > 0 ? 'flex' : 'none';
1496
1590
  let buttonNew = this._SfReportingContainer.querySelector('#button-new');
1497
1591
  buttonNew.addEventListener('click', () => {
1498
1592
  this.newClick();
@@ -1628,8 +1722,10 @@ let SfIReporting = class SfIReporting extends LitElement {
1628
1722
  if (xhr.status == 200) {
1629
1723
  const jsonRespose = JSON.parse(xhr.responseText);
1630
1724
  this.configjson = JSON.stringify(jsonRespose.schema);
1725
+ // if(this.flow == "new"){
1631
1726
  this.populateDataModel();
1632
1727
  this.populateView();
1728
+ // }
1633
1729
  }
1634
1730
  else {
1635
1731
  const jsonRespose = JSON.parse(xhr.responseText);
@@ -1686,7 +1782,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1686
1782
  console.log('adding', this.selectedValues());
1687
1783
  let url = "https://" + this.apiId + "/add";
1688
1784
  let body = { projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published };
1689
- // console.log('adding', body);
1785
+ // console.log('adding', body, url);
1690
1786
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
1691
1787
  const xhr = (await this.prepareXhr(body, url, this._SfLoader, authorization));
1692
1788
  this._SfLoader.innerHTML = '';
@@ -1707,6 +1803,11 @@ let SfIReporting = class SfIReporting extends LitElement {
1707
1803
  this.submitEdit = async () => {
1708
1804
  let url = "https://" + this.apiId + "/update";
1709
1805
  let body = { projectid: this.projectid, noticeid: this.selectedItem.id, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published };
1806
+ if (Object.keys(this.reopenedItem).length > 0) {
1807
+ url = "https://" + this.apiId + "/reopen";
1808
+ body = { projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), noticeid: this.reopenedItem.id, published: this.published };
1809
+ }
1810
+ console.log('updating', body, url);
1710
1811
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
1711
1812
  const xhr = (await this.prepareXhr(body, url, this._SfLoader, authorization));
1712
1813
  this._SfLoader.innerHTML = '';
@@ -1787,9 +1888,10 @@ let SfIReporting = class SfIReporting extends LitElement {
1787
1888
  this.decryptFileName = this._SfDecryptFileInput.value;
1788
1889
  this.evalDecrypt();
1789
1890
  });
1790
- this._SfDecryptButton.addEventListener('click', () => {
1891
+ let decryptButton = this._SfDecryptContainer.querySelector("#button-decrypt");
1892
+ decryptButton === null || decryptButton === void 0 ? void 0 : decryptButton.addEventListener('click', () => {
1791
1893
  console.log('decrypt clicked', this.decryptProjectId, this.decryptFileName);
1792
- // this.submitDecrypt()
1894
+ this.submitDecrypt();
1793
1895
  });
1794
1896
  };
1795
1897
  this.evalDecrypt = () => {
@@ -1881,7 +1983,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1881
1983
  <label>Decrypt Utility</label>
1882
1984
  <div class="d-flex align-end">
1883
1985
  <input part="input" id="input-decrypt" type="text" placeholder="file key" />.json&nbsp;&nbsp;
1884
- <button id="button-decrypt" part="button-icon-small" class="material-icons button-icon">download</button>
1986
+ <button id="button-decrypt">download</button>
1885
1987
  </div>
1886
1988
  <div class="loader-element"></div>
1887
1989
  </div>
@@ -2362,6 +2464,9 @@ SfIReporting.styles = css `
2362
2464
  __decorate([
2363
2465
  property()
2364
2466
  ], SfIReporting.prototype, "apiId", void 0);
2467
+ __decorate([
2468
+ property()
2469
+ ], SfIReporting.prototype, "apiIdUploader", void 0);
2365
2470
  __decorate([
2366
2471
  property()
2367
2472
  ], SfIReporting.prototype, "projectid", void 0);