sf-i-reporting 1.0.69 → 1.0.71

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) => {
@@ -384,6 +386,9 @@ let SfIReporting = class SfIReporting extends LitElement {
384
386
  else {
385
387
  if (element.type == "section") {
386
388
  let dataObj = createDataObject({ id: 'section-' + sectionCount, name: element.name, type: element.type });
389
+ if (this.editdisable == "true") {
390
+ dataObj.collapse = "true";
391
+ }
387
392
  this.dataModel.push(dataObj);
388
393
  sectionCount++;
389
394
  }
@@ -404,7 +409,7 @@ let SfIReporting = class SfIReporting extends LitElement {
404
409
  // <h3 part="results-title" class="m-0">${this.name}</h3>
405
410
  // <button id="button-detail-close" part="button-icon" class="material-icons">close</button>
406
411
  // </div>`
407
- html += `<div class="d-flex flex-col md-20-ml-10" part="title-section">
412
+ html += `${this.name.length > 1 ? `<div class="d-flex flex-col md-20-ml-10" part="title-section">
408
413
  <div class="d-flex w-100-m-0 justify-between align-center">
409
414
  ${this.editdisable != "true" ? `
410
415
  <button id="button-back" part="button-icon" class="button-icon-click"><span class="material-icons">keyboard_backspace</span></button>` : ''}
@@ -434,7 +439,7 @@ let SfIReporting = class SfIReporting extends LitElement {
434
439
  <div class="progress-bar-finished" part="progress-bar-finished"></div>
435
440
  <div class="progress-bar-incomplete" part="progress-bar-incomplete"></div>
436
441
  </div>
437
- </div>
442
+ </div>` : ``}
438
443
  <div class="d-flex ${this.formviewclass} form-container align-stretch p-10" part="${this.published ? "form-container-published" : "form-container"}">`;
439
444
  let firstFlag = true;
440
445
  for (let element of this.dataModel) {
@@ -488,9 +493,6 @@ let SfIReporting = class SfIReporting extends LitElement {
488
493
  </div>
489
494
  `;
490
495
  }
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
496
  this._SfReportingContainer.innerHTML = html;
495
497
  this._SfReportingContainer.style.display = 'block';
496
498
  this.initSectionListeners();
@@ -515,7 +517,7 @@ let SfIReporting = class SfIReporting extends LitElement {
515
517
  for (let element of this.dataModel) {
516
518
  if (element.type == "sf-i-form") {
517
519
  let form = this._SfReportingContainer.querySelector('#' + element.id);
518
- if (this.flow == "details") {
520
+ if (this.mode == "view" || this.flow == "details") {
519
521
  form.flow = "read";
520
522
  }
521
523
  if (element.value != '') {
@@ -545,7 +547,7 @@ let SfIReporting = class SfIReporting extends LitElement {
545
547
  bricks.prepopulateValJson = JSON.stringify([]);
546
548
  }
547
549
  console.log('bricks element values', bricks.prepopulateValJson, element.id);
548
- if (this.flow == "details") {
550
+ if (this.mode == "view" || this.flow == "details") {
549
551
  bricks.flow = "view";
550
552
  }
551
553
  else {
@@ -555,7 +557,7 @@ let SfIReporting = class SfIReporting extends LitElement {
555
557
  else if (element.type == "sf-i-uploader") {
556
558
  let uploader = this._SfReportingContainer.querySelector('#' + element.id);
557
559
  uploader.prepopulatedInputArr = JSON.stringify((_a = element.value) !== null && _a !== void 0 ? _a : []);
558
- uploader.readOnly = (this.flow == "details");
560
+ uploader.readOnly = (this.mode == "view" || this.flow == "details");
559
561
  uploader.loadMode();
560
562
  }
561
563
  else if (element.type == "sf-i-form-select") {
@@ -637,7 +639,7 @@ let SfIReporting = class SfIReporting extends LitElement {
637
639
  });
638
640
  }
639
641
  }
640
- if (this.flow != 'details') {
642
+ if (this.mode != "view" && this.flow != 'details') {
641
643
  let selectedOptions = this._SfReportingContainer.querySelectorAll('.selected-option');
642
644
  for (let selectedOption of selectedOptions) {
643
645
  selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.addEventListener('click', async (ev) => {
@@ -701,7 +703,129 @@ let SfIReporting = class SfIReporting extends LitElement {
701
703
  this.evalShowProgress();
702
704
  this._SfReportingContainer.querySelector('.form-container').scrollTo({ top: scrollTopTarget, left: 0 });
703
705
  this.hideLoader();
706
+ let customEvent = new CustomEvent('valueChanged');
707
+ this.dispatchEvent(customEvent);
704
708
  }, 500);
709
+ if (this.getPrepopulateJson().history != null && Object.keys(this.getPrepopulateJson().history).length > 0) {
710
+ this.populateHistory();
711
+ }
712
+ };
713
+ this.populateHistory = () => {
714
+ var _a;
715
+ let formContainer = this._SfReportingContainer.querySelector('.form-container');
716
+ if (formContainer != null) {
717
+ let html = '';
718
+ html += `
719
+ <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">
720
+ `;
721
+ for (let [indexDate, historyDate] of Object.keys(this.getPrepopulateJson().history).entries()) {
722
+ console.log('history', historyDate);
723
+ html += `
724
+ <div class="d-flex flex-col" part="section-container"><div id="history-date-${indexDate}" class="history-section-head section-head d-flex align-center justify-between" part="section-head-collapsed"><h3 part="section-title-collapsed" id="section-history-title-${indexDate}">${historyDate}</h3><div class="material-icons" id="section-history-icon-${indexDate}">keyboard_arrow_down</div></div><div id="section-history-body-${indexDate}" class="section-body d-flex ${this.formviewclass} hide" part="section-body">
725
+ `;
726
+ for (let [index, historyItem] of this.getPrepopulateJson().history[historyDate].entries()) {
727
+ html += `<sf-i-reporting name="" id="history-reporting-${historyDate}-${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, commentbox:reporting-commentbox, comment-username:reporting-comment-username, detail-head:reporting-detail-head" name="Notice Details" mode="view" editdisable="true" formviewclass="flex-wrap" prepopulatevaljson="${JSON.stringify(historyItem.object).replace(/"/g, '&quot;')}"></sf-i-reporting>`;
728
+ let comments = (_a = historyItem.object.comments) !== null && _a !== void 0 ? _a : [];
729
+ if (historyItem.object.documents != null && historyItem.object.documents.length > 0) {
730
+ html += '<div class="d-flex justify-between m-20">';
731
+ html += '<h3 part="history-docs-title" class="m-0"><br />Documents</h3>';
732
+ html += '</div>';
733
+ html += `
734
+ <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>
735
+ `;
736
+ }
737
+ html += '<div class="d-flex justify-between m-20">';
738
+ html += '<h3 part="history-comments-title" class="m-0"><br />Comments</h3>';
739
+ html += '</div>';
740
+ html += '<div class="m-20">';
741
+ html += '<div class="d-flex flex-col">';
742
+ for (var i = 0; i < comments.length; i++) {
743
+ html += '<div part="commentbox" class="d-flex commentbox ' + (comments[i].author + "").toLowerCase() + 'box">';
744
+ 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>';
745
+ const onlyCommentText = (comments[i].comment + "").replace(/ *\([^)]*\) */g, "").trim();
746
+ try {
747
+ const jsonComments = JSON.parse(onlyCommentText);
748
+ if (Util.isInteger(jsonComments)) {
749
+ html += '<div class="">' + comments[i].comment + '<br /><small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
750
+ }
751
+ else {
752
+ //console.log('json comments', jsonComments);
753
+ var htmlTable = '';
754
+ for (var j = 0; j < Object.keys(jsonComments).length; j++) {
755
+ htmlTable += '<div class="mb-20">';
756
+ htmlTable += ('<div part="detail-head">' + Object.keys(jsonComments)[j] + '</div>');
757
+ htmlTable += ('<sf-i-elastic-text text="' + jsonComments[Object.keys(jsonComments)[j]] + '" minLength="20"></sf-i-elastic-text>');
758
+ htmlTable += '</div>';
759
+ }
760
+ html += '<div class="">' + htmlTable + '<small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
761
+ }
762
+ }
763
+ catch (e) {
764
+ //console.log('json comments exception', comments[i]);
765
+ html += '<div class="">' + comments[i].comment + '<br /><small><span class="muted">' + comments[i].timestamp + '</span></small></div>';
766
+ }
767
+ html += '</div>';
768
+ }
769
+ if (comments.length === 0) {
770
+ html += '<div><strong>No comments!</strong></div>';
771
+ }
772
+ html += '</div>';
773
+ html += '</div>';
774
+ }
775
+ html += '</div>';
776
+ }
777
+ html += '</div>';
778
+ formContainer.insertAdjacentHTML('beforeend', html);
779
+ let sectionHistory = formContainer.querySelector('#history');
780
+ sectionHistory.addEventListener('click', () => {
781
+ let sectionHistoryBody = formContainer.querySelector('#section-history-body');
782
+ let sectionHistoryTitle = formContainer.querySelector('#section-history-title');
783
+ let sectionHistoryIcon = formContainer.querySelector('#section-history-icon');
784
+ if (sectionHistoryBody.style.display == 'block') {
785
+ sectionHistory.setAttribute('part', 'section-head-collapsed');
786
+ sectionHistoryBody.style.display = 'none';
787
+ sectionHistoryTitle.setAttribute('part', 'section-title-collapsed');
788
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_down';
789
+ }
790
+ else {
791
+ sectionHistory.setAttribute('part', 'section-head-expanded');
792
+ sectionHistoryBody.style.display = 'block';
793
+ sectionHistoryTitle.setAttribute('part', 'section-title-expanded');
794
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_up';
795
+ }
796
+ });
797
+ let sectionHistoryDates = formContainer.querySelectorAll('.history-section-head');
798
+ for (let sectionHistoryDate of sectionHistoryDates) {
799
+ sectionHistoryDate.addEventListener('click', () => {
800
+ let id = sectionHistoryDate.id;
801
+ let dateIndex = id.split('-')[2];
802
+ let sectionHistoryDateBody = formContainer.querySelector('#section-history-body-' + dateIndex);
803
+ let sectionHistoryDateTitle = formContainer.querySelector('#section-history-title-' + dateIndex);
804
+ let sectionHistoryDateIcon = formContainer.querySelector('#section-history-icon-' + dateIndex);
805
+ if (sectionHistoryDateBody.style.display == 'block') {
806
+ sectionHistory.setAttribute('part', 'section-head-collapsed');
807
+ sectionHistoryDateBody.style.display = 'none';
808
+ sectionHistoryDateTitle.setAttribute('part', 'section-title-collapsed');
809
+ sectionHistoryDateIcon.innerHTML = 'keyboard_arrow_down';
810
+ }
811
+ else {
812
+ sectionHistory.setAttribute('part', 'section-head-expanded');
813
+ sectionHistoryDateBody.style.display = 'block';
814
+ sectionHistoryDateTitle.setAttribute('part', 'section-title-expanded');
815
+ sectionHistoryDateIcon.innerHTML = 'keyboard_arrow_up';
816
+ }
817
+ });
818
+ }
819
+ let historyReportings = formContainer.querySelectorAll('.history-reporting');
820
+ for (let historyReporting of historyReportings) {
821
+ let id = historyReporting.id;
822
+ let date = id.split('-')[2] + '-' + id.split('-')[3] + '-' + id.split('-')[4];
823
+ let index = id.split('-')[5];
824
+ console.log('historyConfigJSON', this.getPrepopulateJson().history[date][index].schema);
825
+ historyReporting.configjson = JSON.stringify(this.getPrepopulateJson().history[date][index].schema);
826
+ // historyReporting.loadMode();
827
+ }
828
+ }
705
829
  };
706
830
  this.prepopulateValues = () => {
707
831
  var _a, _b, _c, _d, _e, _f, _g;
@@ -722,7 +846,7 @@ let SfIReporting = class SfIReporting extends LitElement {
722
846
  }
723
847
  }
724
848
  else {
725
- if (element.type == "section") {
849
+ if (element.type == "section" && this.editdisable != "true") {
726
850
  this.dataModel[i].collapse = "false";
727
851
  }
728
852
  else {
@@ -1309,10 +1433,15 @@ let SfIReporting = class SfIReporting extends LitElement {
1309
1433
  return elementHtml;
1310
1434
  };
1311
1435
  this.renderElement = (dataObj) => {
1312
- var _a, _b;
1436
+ var _a, _b, _c;
1313
1437
  let elementHtml = "";
1314
1438
  console.log('rendering obj', dataObj.type);
1439
+ let elementLabel = (_a = dataObj.label) !== null && _a !== void 0 ? _a : "";
1440
+ if (this.editdisable == "true") {
1441
+ elementLabel = elementLabel.replace(/ */g, '');
1442
+ }
1315
1443
  if (dataObj.type == "section") {
1444
+ console.log('renderingSection', dataObj);
1316
1445
  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
1446
  }
1318
1447
  else if (dataObj.type == "subsection") {
@@ -1320,33 +1449,33 @@ let SfIReporting = class SfIReporting extends LitElement {
1320
1449
  }
1321
1450
  else if (dataObj.type == "textarea") {
1322
1451
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1323
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1452
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1324
1453
  <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>
1454
+ <${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
1455
  </div>`;
1327
1456
  }
1328
1457
  else if (dataObj.type == "yesno+textarea") {
1329
1458
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1330
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1459
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1331
1460
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1332
1461
  <div class="d-flex">`;
1333
1462
  for (let option of dataObj.options) {
1334
1463
  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
1464
  }
1336
1465
  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>
1466
+ <${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
1467
  </div>`;
1339
1468
  }
1340
1469
  else if (dataObj.type == "date") {
1341
1470
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1342
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1471
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1343
1472
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1344
1473
  <input class="reporting-date" id="${dataObj.id}" part="input-date" type="date" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""} value="${dataObj.value}"/>
1345
1474
  </div>`;
1346
1475
  }
1347
1476
  else if (dataObj.type == "sf-i-form") {
1348
1477
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1349
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1478
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1350
1479
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1351
1480
  <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
1481
  </div>`;
@@ -1365,16 +1494,16 @@ let SfIReporting = class SfIReporting extends LitElement {
1365
1494
  valToBeShown = dataObj.value.reference;
1366
1495
  }
1367
1496
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1368
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1497
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1369
1498
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1370
1499
  <div class="d-flex flex-col align-start" part="form-select-container">
1371
1500
  <div class"d-flex align-center" part="form-selected-value">
1372
- ${((_b = Object.keys(dataObj.value)) !== null && _b !== void 0 ? _b : []).length > 0 ? (`
1501
+ ${((_c = Object.keys(dataObj.value)) !== null && _c !== void 0 ? _c : []).length > 0 ? (`
1373
1502
  <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>'}
1503
+ ${this.mode == "view" || this.flow == "details" ? '' : '<span class="material-icons selected-option-icon mr-10">cancel</span>'}
1375
1504
  <label class="selected-option-label" part="selected-option-label">${valToBeShown}</label>
1376
1505
  </div>`) : (`
1377
- ${(this.flow == "details") ? '' :
1506
+ ${(this.mode == "view" || this.flow == "details") ? '' :
1378
1507
  `<button id="button-edit-form-${dataObj.id}" part="button-icon" class="material-icons button-edit-form button-icon-click">edit</button>`}
1379
1508
  `)}
1380
1509
  </div>
@@ -1383,15 +1512,15 @@ let SfIReporting = class SfIReporting extends LitElement {
1383
1512
  }
1384
1513
  else if (dataObj.type == "sf-i-bricks") {
1385
1514
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1386
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1515
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1387
1516
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1388
1517
  <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>
1518
+ ${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
1519
  </div>`;
1391
1520
  }
1392
1521
  else if (dataObj.type == "sf-i-uploader") {
1393
1522
  elementHtml += `<div part="uploader-container" class="d-flex flex-col flex-grow">
1394
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1523
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1395
1524
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1396
1525
  <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
1526
  </div>`;
@@ -1433,6 +1562,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1433
1562
  html += '<tr class="tablerow">';
1434
1563
  let bgClass = i % 2 == 0 ? 'td-light' : 'td-dark';
1435
1564
  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>`;
1565
+ 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
1566
  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
1567
  for (let property of Object.keys(item)) {
1438
1568
  if (this.getIgnoreProjections().indexOf(property) < 0) {
@@ -1449,6 +1579,37 @@ let SfIReporting = class SfIReporting extends LitElement {
1449
1579
  html += '</table>';
1450
1580
  this._SfReportingContainer.innerHTML = html;
1451
1581
  this._SfReportingContainer.style.display = 'block';
1582
+ let reopenButtons = this._SfReportingContainer.querySelectorAll('.button-reopen');
1583
+ for (let reopenButton of reopenButtons) {
1584
+ reopenButton.addEventListener('click', async (ev) => {
1585
+ var _a;
1586
+ let target = ev.target;
1587
+ let index = target.id.split('-')[2];
1588
+ this.reopenedItem = this.list[index];
1589
+ let oldObj = this.reopenedItem;
1590
+ console.log('item selected', this.reopenedItem);
1591
+ await this.fetchSchema();
1592
+ this.published = (_a = this.list[index].published) !== null && _a !== void 0 ? _a : false;
1593
+ let copyVals = {};
1594
+ for (let obj of this.dataModel) {
1595
+ if (obj.copytoreopen) {
1596
+ console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
1597
+ if (obj.type == "sf-i-bricks" && obj.savenameseparate == "yes") {
1598
+ copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
1599
+ copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
1600
+ }
1601
+ else {
1602
+ copyVals[obj.id] = oldObj[obj.id];
1603
+ }
1604
+ console.log('copyVals copied', copyVals);
1605
+ }
1606
+ }
1607
+ console.log('copyVals', JSON.parse(JSON.stringify(copyVals)));
1608
+ this.prepopulateValJson = JSON.stringify(copyVals);
1609
+ this.flow = "edit";
1610
+ this.loadMode();
1611
+ });
1612
+ }
1452
1613
  let detailsButtons = this._SfReportingContainer.querySelectorAll('.button-details');
1453
1614
  for (let detailsButton of detailsButtons) {
1454
1615
  detailsButton.addEventListener('click', (ev) => {
@@ -1460,39 +1621,6 @@ let SfIReporting = class SfIReporting extends LitElement {
1460
1621
  this.loadMode();
1461
1622
  });
1462
1623
  }
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
1624
  let buttonNew = this._SfReportingContainer.querySelector('#button-new');
1497
1625
  buttonNew.addEventListener('click', () => {
1498
1626
  this.newClick();
@@ -1628,8 +1756,10 @@ let SfIReporting = class SfIReporting extends LitElement {
1628
1756
  if (xhr.status == 200) {
1629
1757
  const jsonRespose = JSON.parse(xhr.responseText);
1630
1758
  this.configjson = JSON.stringify(jsonRespose.schema);
1759
+ // if(this.flow == "new"){
1631
1760
  this.populateDataModel();
1632
1761
  this.populateView();
1762
+ // }
1633
1763
  }
1634
1764
  else {
1635
1765
  const jsonRespose = JSON.parse(xhr.responseText);
@@ -1686,7 +1816,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1686
1816
  console.log('adding', this.selectedValues());
1687
1817
  let url = "https://" + this.apiId + "/add";
1688
1818
  let body = { projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published };
1689
- // console.log('adding', body);
1819
+ // console.log('adding', body, url);
1690
1820
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
1691
1821
  const xhr = (await this.prepareXhr(body, url, this._SfLoader, authorization));
1692
1822
  this._SfLoader.innerHTML = '';
@@ -1707,6 +1837,11 @@ let SfIReporting = class SfIReporting extends LitElement {
1707
1837
  this.submitEdit = async () => {
1708
1838
  let url = "https://" + this.apiId + "/update";
1709
1839
  let body = { projectid: this.projectid, noticeid: this.selectedItem.id, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published };
1840
+ if (Object.keys(this.reopenedItem).length > 0) {
1841
+ url = "https://" + this.apiId + "/reopen";
1842
+ body = { projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), noticeid: this.reopenedItem.id, published: this.published };
1843
+ }
1844
+ console.log('updating', body, url);
1710
1845
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
1711
1846
  const xhr = (await this.prepareXhr(body, url, this._SfLoader, authorization));
1712
1847
  this._SfLoader.innerHTML = '';
@@ -1787,9 +1922,10 @@ let SfIReporting = class SfIReporting extends LitElement {
1787
1922
  this.decryptFileName = this._SfDecryptFileInput.value;
1788
1923
  this.evalDecrypt();
1789
1924
  });
1790
- this._SfDecryptButton.addEventListener('click', () => {
1925
+ let decryptButton = this._SfDecryptContainer.querySelector("#button-decrypt");
1926
+ decryptButton === null || decryptButton === void 0 ? void 0 : decryptButton.addEventListener('click', () => {
1791
1927
  console.log('decrypt clicked', this.decryptProjectId, this.decryptFileName);
1792
- // this.submitDecrypt()
1928
+ this.submitDecrypt();
1793
1929
  });
1794
1930
  };
1795
1931
  this.evalDecrypt = () => {
@@ -1881,7 +2017,7 @@ let SfIReporting = class SfIReporting extends LitElement {
1881
2017
  <label>Decrypt Utility</label>
1882
2018
  <div class="d-flex align-end">
1883
2019
  <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>
2020
+ <button id="button-decrypt">download</button>
1885
2021
  </div>
1886
2022
  <div class="loader-element"></div>
1887
2023
  </div>
@@ -2362,6 +2498,9 @@ SfIReporting.styles = css `
2362
2498
  __decorate([
2363
2499
  property()
2364
2500
  ], SfIReporting.prototype, "apiId", void 0);
2501
+ __decorate([
2502
+ property()
2503
+ ], SfIReporting.prototype, "apiIdUploader", void 0);
2365
2504
  __decorate([
2366
2505
  property()
2367
2506
  ], SfIReporting.prototype, "projectid", void 0);