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.
@@ -21,7 +21,9 @@ export interface DataObject {
21
21
  maxsize: string,
22
22
  allowdownload: string,
23
23
  selectfields: string[]
24
- mandatory: any
24
+ mandatory: any,
25
+ copytoreopen: boolean,
26
+ displayinhistory: boolean
25
27
  }
26
28
 
27
29
  export function createDataObject(element: any, iter?: number): DataObject {
@@ -49,7 +51,9 @@ export function createDataObject(element: any, iter?: number): DataObject {
49
51
  maxsize: element.maxsize ?? "",
50
52
  allowdownload: element.allowdownload ?? "",
51
53
  selectfields: element.selectfields ?? [],
52
- mandatory: element.mandatory
54
+ mandatory: element.mandatory,
55
+ copytoreopen: (element.copytoreopen ?? "") == "yes",
56
+ displayinhistory: (element.displayinhistory ?? "") == "yes"
53
57
  }
54
58
  }else{
55
59
  return{
@@ -75,7 +79,9 @@ export function createDataObject(element: any, iter?: number): DataObject {
75
79
  maxsize: element.maxsize ?? "",
76
80
  allowdownload: element.allowdownload ?? "",
77
81
  selectfields: element.selectfields ?? [],
78
- mandatory: element.mandatory
82
+ mandatory: element.mandatory,
83
+ copytoreopen: (element.copytoreopen ?? "") == "yes",
84
+ displayinhistory: (element.displayinhistory ?? "") == "yes"
79
85
  }
80
86
  }
81
87
  }
@@ -39,6 +39,9 @@ export class SfIReporting extends LitElement {
39
39
  @property()
40
40
  apiId: string = "";
41
41
 
42
+ @property()
43
+ apiIdUploader: string = "";
44
+
42
45
  @property()
43
46
  projectid: string = "";
44
47
 
@@ -108,6 +111,8 @@ export class SfIReporting extends LitElement {
108
111
 
109
112
  selectedItemIds: any = [];
110
113
 
114
+ reopenedItem: any = {};
115
+
111
116
  static override styles = css`
112
117
 
113
118
 
@@ -819,6 +824,9 @@ export class SfIReporting extends LitElement {
819
824
  }else{
820
825
  if(element.type == "section"){
821
826
  let dataObj: DataObject = createDataObject({id: 'section-' + sectionCount, name: element.name, type: element.type})
827
+ if(this.editdisable == "true"){
828
+ dataObj.collapse = "true"
829
+ }
822
830
  this.dataModel.push(dataObj)
823
831
  sectionCount ++;
824
832
  }else{
@@ -838,7 +846,7 @@ export class SfIReporting extends LitElement {
838
846
  // <h3 part="results-title" class="m-0">${this.name}</h3>
839
847
  // <button id="button-detail-close" part="button-icon" class="material-icons">close</button>
840
848
  // </div>`
841
- html += `<div class="d-flex flex-col md-20-ml-10" part="title-section">
849
+ html += `${this.name.length > 1 ? `<div class="d-flex flex-col md-20-ml-10" part="title-section">
842
850
  <div class="d-flex w-100-m-0 justify-between align-center">
843
851
  ${this.editdisable != "true" ? `
844
852
  <button id="button-back" part="button-icon" class="button-icon-click"><span class="material-icons">keyboard_backspace</span></button>` : ''}
@@ -869,7 +877,7 @@ export class SfIReporting extends LitElement {
869
877
  <div class="progress-bar-finished" part="progress-bar-finished"></div>
870
878
  <div class="progress-bar-incomplete" part="progress-bar-incomplete"></div>
871
879
  </div>
872
- </div>
880
+ </div>` : ``}
873
881
  <div class="d-flex ${this.formviewclass} form-container align-stretch p-10" part="${this.published ? "form-container-published" : "form-container"}">`
874
882
 
875
883
  let firstFlag = true
@@ -924,9 +932,7 @@ export class SfIReporting extends LitElement {
924
932
  </div>
925
933
  `;
926
934
  }
927
- // <div class="d-flex w-100-m-0 justify-center align-center">
928
- // <button id="button-save-form" part="button-icon" class="button-icon-click"><span class="material-icons">check</span></button>
929
- // </div>
935
+
930
936
  (this._SfReportingContainer as HTMLDivElement).innerHTML = html;
931
937
  (this._SfReportingContainer as HTMLDivElement).style.display = 'block';
932
938
  this.initSectionListeners();
@@ -950,7 +956,7 @@ export class SfIReporting extends LitElement {
950
956
  for(let element of this.dataModel){
951
957
  if(element.type == "sf-i-form"){
952
958
  let form: SfIForm = (this._SfReportingContainer as HTMLDivElement).querySelector('#'+element.id) as SfIForm;
953
- if(this.flow == "details"){
959
+ if(this.mode == "view" || this.flow == "details"){
954
960
  form.flow = "read"
955
961
  }
956
962
  if(element.value != ''){
@@ -979,7 +985,7 @@ export class SfIReporting extends LitElement {
979
985
  bricks.prepopulateValJson = JSON.stringify([])
980
986
  }
981
987
  console.log('bricks element values', bricks.prepopulateValJson, element.id);
982
- if(this.flow == "details"){
988
+ if(this.mode == "view" || this.flow == "details"){
983
989
  bricks.flow = "view"
984
990
  }else{
985
991
  bricks.flow = "edit"
@@ -987,7 +993,7 @@ export class SfIReporting extends LitElement {
987
993
  }else if(element.type == "sf-i-uploader"){
988
994
  let uploader: SfIUploader = (this._SfReportingContainer as HTMLDivElement).querySelector('#'+element.id) as SfIUploader
989
995
  uploader.prepopulatedInputArr = JSON.stringify(element.value ?? []);
990
- uploader.readOnly = (this.flow == "details")
996
+ uploader.readOnly = (this.mode == "view" || this.flow == "details")
991
997
  uploader.loadMode()
992
998
  }else if(element.type == "sf-i-form-select"){
993
999
  let buttonEditForm = (this._SfReportingContainer as HTMLDivElement).querySelector('#button-edit-form-'+element.id) as HTMLButtonElement
@@ -1064,7 +1070,7 @@ export class SfIReporting extends LitElement {
1064
1070
  })
1065
1071
  }
1066
1072
  }
1067
- if(this.flow != 'details'){
1073
+ if(this.mode != "view" && this.flow != 'details'){
1068
1074
  let selectedOptions = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.selected-option') as NodeListOf<HTMLDivElement>
1069
1075
  for(let selectedOption of selectedOptions){
1070
1076
  selectedOption?.addEventListener('click',async (ev: any) => {
@@ -1086,15 +1092,15 @@ export class SfIReporting extends LitElement {
1086
1092
  }
1087
1093
  let checkboxPublish = (this._SfReportingContainer as HTMLDivElement).querySelector('#input-publish-checkbox') as HTMLInputElement
1088
1094
  checkboxPublish?.addEventListener('click',(ev:any) => {
1089
- let target = ev.target as HTMLInputElement
1090
- this.published = target.checked
1091
- let publishedContainer = (this._SfReportingContainer as HTMLDivElement).querySelector('#published-container') as HTMLDivElement
1092
- publishedContainer.setAttribute('part', this.published ? "published-container-published" : "published-container-unpublished")
1093
- let formContainer = this._SfReportingContainer.querySelector('.form-container') as HTMLDivElement
1094
- formContainer.setAttribute('part',this.published ? "form-container-published" : "form-container")
1095
- console.log('publish checked', this.published);
1096
- }
1097
- )
1095
+ let target = ev.target as HTMLInputElement
1096
+ this.published = target.checked
1097
+ let publishedContainer = (this._SfReportingContainer as HTMLDivElement).querySelector('#published-container') as HTMLDivElement
1098
+ publishedContainer.setAttribute('part', this.published ? "published-container-published" : "published-container-unpublished")
1099
+ let formContainer = this._SfReportingContainer.querySelector('.form-container') as HTMLDivElement
1100
+ formContainer.setAttribute('part',this.published ? "form-container-published" : "form-container")
1101
+ console.log('publish checked', this.published);
1102
+ }
1103
+ )
1098
1104
  let checkboxPublishLabel = (this._SfReportingContainer as HTMLDivElement).querySelector('#input-publish-checkbox-label') as HTMLLabelElement
1099
1105
  checkboxPublishLabel?.addEventListener('click',() => {
1100
1106
  checkboxPublish.click()
@@ -1135,8 +1141,135 @@ export class SfIReporting extends LitElement {
1135
1141
  this.evalShowProgress();
1136
1142
  (this._SfReportingContainer.querySelector('.form-container') as HTMLDivElement).scrollTo({top: scrollTopTarget, left:0});
1137
1143
  this.hideLoader();
1144
+ let customEvent = new CustomEvent('valueChanged');
1145
+ this.dispatchEvent(customEvent);
1138
1146
  },500)
1139
-
1147
+ if(this.getPrepopulateJson().history != null && Object.keys(this.getPrepopulateJson().history).length > 0){
1148
+ this.populateHistory()
1149
+ }
1150
+ }
1151
+
1152
+ populateHistory = () => {
1153
+ let formContainer = (this._SfReportingContainer.querySelector('.form-container') as HTMLElement)
1154
+ if(formContainer != null){
1155
+ let html = ''
1156
+ html += `
1157
+ <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">
1158
+ `
1159
+ for(let [indexDate, historyDate] of Object.keys(this.getPrepopulateJson().history).entries()){
1160
+ console.log('history', historyDate);
1161
+ html += `
1162
+ <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">
1163
+ `
1164
+ for(let [index,historyItem] of this.getPrepopulateJson().history[historyDate].entries()){
1165
+ 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>`
1166
+ let comments = historyItem.object.comments ?? []
1167
+ if(historyItem.object.documents != null && historyItem.object.documents.length > 0){
1168
+ html += '<div class="d-flex justify-between m-20">';
1169
+ html += '<h3 part="history-docs-title" class="m-0"><br />Documents</h3>';
1170
+ html += '</div>';
1171
+ html += `
1172
+ <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>
1173
+ `
1174
+ }
1175
+ html += '<div class="d-flex justify-between m-20">';
1176
+ html += '<h3 part="history-comments-title" class="m-0"><br />Comments</h3>';
1177
+ html += '</div>';
1178
+
1179
+ html += '<div class="m-20">';
1180
+
1181
+ html += '<div class="d-flex flex-col">';
1182
+
1183
+ for(var i = 0; i < comments.length; i++) {
1184
+ html += '<div part="commentbox" class="d-flex commentbox '+(comments[i].author + "").toLowerCase()+'box">';
1185
+ 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>';
1186
+
1187
+ const onlyCommentText = (comments[i].comment + "").replace(/ *\([^)]*\) */g, "").trim();
1188
+ try {
1189
+
1190
+ const jsonComments = JSON.parse(onlyCommentText);
1191
+
1192
+ if(Util.isInteger(jsonComments)) {
1193
+ html += '<div class="">'+comments[i].comment+'<br /><small><span class="muted">'+comments[i].timestamp+'</span></small></div>';
1194
+ } else {
1195
+ //console.log('json comments', jsonComments);
1196
+ var htmlTable = '';
1197
+ for(var j = 0; j < Object.keys(jsonComments).length; j++) {
1198
+ htmlTable += '<div class="mb-20">';
1199
+ htmlTable += ('<div part="detail-head">' + Object.keys(jsonComments)[j] + '</div>');
1200
+ htmlTable += ('<sf-i-elastic-text text="'+jsonComments[Object.keys(jsonComments)[j]]+'" minLength="20"></sf-i-elastic-text>');
1201
+ htmlTable += '</div>';
1202
+ }
1203
+ html += '<div class="">'+htmlTable+'<small><span class="muted">'+comments[i].timestamp+'</span></small></div>';
1204
+ }
1205
+
1206
+ } catch (e: any) {
1207
+ //console.log('json comments exception', comments[i]);
1208
+ html += '<div class="">'+comments[i].comment+'<br /><small><span class="muted">'+comments[i].timestamp+'</span></small></div>';
1209
+ }
1210
+
1211
+ html += '</div>';
1212
+ }
1213
+ if(comments.length === 0) {
1214
+ html += '<div><strong>No comments!</strong></div>';
1215
+ }
1216
+
1217
+ html += '</div>';
1218
+
1219
+ html += '</div>';
1220
+ }
1221
+ html += '</div>'
1222
+ }
1223
+ html += '</div>'
1224
+ formContainer.insertAdjacentHTML('beforeend',html);
1225
+ let sectionHistory = formContainer.querySelector('#history') as HTMLDivElement
1226
+ sectionHistory.addEventListener('click',() => {
1227
+ let sectionHistoryBody = formContainer.querySelector('#section-history-body') as HTMLDivElement
1228
+ let sectionHistoryTitle = formContainer.querySelector('#section-history-title') as HTMLHeadingElement
1229
+ let sectionHistoryIcon = formContainer.querySelector('#section-history-icon') as HTMLHeadingElement
1230
+ if(sectionHistoryBody.style.display == 'block'){
1231
+ sectionHistory.setAttribute('part','section-head-collapsed')
1232
+ sectionHistoryBody.style.display = 'none'
1233
+ sectionHistoryTitle.setAttribute('part','section-title-collapsed')
1234
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_down'
1235
+ }else{
1236
+ sectionHistory.setAttribute('part','section-head-expanded')
1237
+ sectionHistoryBody.style.display = 'block'
1238
+ sectionHistoryTitle.setAttribute('part','section-title-expanded')
1239
+ sectionHistoryIcon.innerHTML = 'keyboard_arrow_up'
1240
+ }
1241
+ })
1242
+ let sectionHistoryDates = formContainer.querySelectorAll('.history-section-head') as NodeListOf<HTMLDivElement>
1243
+ for(let sectionHistoryDate of sectionHistoryDates){
1244
+ sectionHistoryDate.addEventListener('click',() => {
1245
+ let id = sectionHistoryDate.id
1246
+ let dateIndex = id.split('-')[2]
1247
+ let sectionHistoryDateBody = formContainer.querySelector('#section-history-body-' + dateIndex) as HTMLDivElement
1248
+ let sectionHistoryDateTitle = formContainer.querySelector('#section-history-title-' + dateIndex) as HTMLHeadingElement
1249
+ let sectionHistoryDateIcon = formContainer.querySelector('#section-history-icon-' + dateIndex) as HTMLHeadingElement
1250
+ if(sectionHistoryDateBody.style.display == 'block'){
1251
+ sectionHistory.setAttribute('part','section-head-collapsed')
1252
+ sectionHistoryDateBody.style.display = 'none'
1253
+ sectionHistoryDateTitle.setAttribute('part','section-title-collapsed')
1254
+ sectionHistoryDateIcon.innerHTML = 'keyboard_arrow_down'
1255
+ }else{
1256
+ sectionHistory.setAttribute('part','section-head-expanded')
1257
+ sectionHistoryDateBody.style.display = 'block'
1258
+ sectionHistoryDateTitle.setAttribute('part','section-title-expanded')
1259
+ sectionHistoryDateIcon.innerHTML = 'keyboard_arrow_up'
1260
+ }
1261
+ })
1262
+ }
1263
+ let historyReportings = formContainer.querySelectorAll('.history-reporting') as NodeListOf<SfIReporting>
1264
+ for(let historyReporting of historyReportings){
1265
+ let id = historyReporting.id;
1266
+ let date = id.split('-')[2] + '-' + id.split('-')[3] + '-' + id.split('-')[4]
1267
+ let index = id.split('-')[5]
1268
+ console.log('historyConfigJSON', this.getPrepopulateJson().history[date][index].schema)
1269
+ historyReporting.configjson = JSON.stringify(this.getPrepopulateJson().history[date][index].schema)
1270
+ // historyReporting.loadMode();
1271
+ }
1272
+ }
1140
1273
  }
1141
1274
 
1142
1275
  prepopulateValues = () => {
@@ -1156,7 +1289,7 @@ export class SfIReporting extends LitElement {
1156
1289
  }
1157
1290
  }
1158
1291
  }else{
1159
- if(element.type == "section"){
1292
+ if(element.type == "section" && this.editdisable != "true"){
1160
1293
  this.dataModel[i].collapse = "false"
1161
1294
  }else{
1162
1295
  if(this.dataModel[i].type == "textarea"){
@@ -1731,36 +1864,41 @@ export class SfIReporting extends LitElement {
1731
1864
  renderElement = (dataObj: DataObject) => {
1732
1865
  let elementHtml = ""
1733
1866
  console.log('rendering obj',dataObj.type)
1867
+ let elementLabel = dataObj.label ?? ""
1868
+ if(this.editdisable == "true"){
1869
+ elementLabel = elementLabel.replace(/ */g,'')
1870
+ }
1734
1871
  if(dataObj.type == "section"){
1872
+ console.log('renderingSection', dataObj)
1735
1873
  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"> `
1736
1874
  }else if(dataObj.type == "subsection"){
1737
1875
  elementHtml += `<div class="d-flex align-center" part="subsection-container"><h4 part="subsection">${dataObj.name}</h4></div>`
1738
1876
  }else if(dataObj.type == "textarea"){
1739
1877
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1740
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1878
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1741
1879
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1742
- <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>
1880
+ <${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'}>
1743
1881
  </div>`
1744
1882
  }else if(dataObj.type == "yesno+textarea"){
1745
1883
  elementHtml += `<div part="textarea-container" class="d-flex flex-col flex-grow">
1746
- <label id="${dataObj.id}-label" part="textarea-label">${dataObj.label}</label>
1884
+ <label id="${dataObj.id}-label" part="textarea-label">${elementLabel}</label>
1747
1885
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1748
1886
  <div class="d-flex">`
1749
1887
  for(let option of dataObj.options){
1750
1888
  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>`
1751
1889
  }
1752
1890
  elementHtml += `</div>
1753
- <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" : ""}>${dataObj.value[1] ?? ""}</textarea>
1891
+ <${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" : ""}>${dataObj.value[1] ?? ""}</${this.editdisable == "true" ? 'div' : 'textarea'}>
1754
1892
  </div>`
1755
1893
  }else if(dataObj.type == "date"){
1756
1894
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1757
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1895
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1758
1896
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1759
1897
  <input class="reporting-date" id="${dataObj.id}" part="input-date" type="date" ${this.mode == "view" || this.flow == "details" ? "readonly" : ""} value="${dataObj.value}"/>
1760
1898
  </div>`
1761
1899
  }else if(dataObj.type == "sf-i-form"){
1762
1900
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1763
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1901
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1764
1902
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1765
1903
  <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>
1766
1904
  </div>`
@@ -1776,16 +1914,16 @@ export class SfIReporting extends LitElement {
1776
1914
  valToBeShown = dataObj.value.reference
1777
1915
  }
1778
1916
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1779
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1917
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1780
1918
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1781
1919
  <div class="d-flex flex-col align-start" part="form-select-container">
1782
1920
  <div class"d-flex align-center" part="form-selected-value">
1783
1921
  ${(Object.keys(dataObj.value) ?? []).length > 0 ? (`
1784
1922
  <div class="selected-option d-flex justtify-center align-center" part="selected-option" id="selected-option-${dataObj.id}">
1785
- ${this.flow == "details" ? '' : '<span class="material-icons selected-option-icon mr-10">cancel</span>'}
1923
+ ${this.mode == "view" || this.flow == "details" ? '' : '<span class="material-icons selected-option-icon mr-10">cancel</span>'}
1786
1924
  <label class="selected-option-label" part="selected-option-label">${valToBeShown}</label>
1787
1925
  </div>`): (`
1788
- ${(this.flow == "details") ? '' :
1926
+ ${(this.mode == "view" || this.flow == "details" ) ? '' :
1789
1927
  `<button id="button-edit-form-${dataObj.id}" part="button-icon" class="material-icons button-edit-form button-icon-click">edit</button>`
1790
1928
  }
1791
1929
  `)
@@ -1795,14 +1933,14 @@ export class SfIReporting extends LitElement {
1795
1933
  </div>`
1796
1934
  }else if(dataObj.type == "sf-i-bricks"){
1797
1935
  elementHtml += `<div part="date-container" class="d-flex flex-col flex-grow">
1798
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1936
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1799
1937
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1800
1938
  <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}"
1801
- ${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>
1939
+ ${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>
1802
1940
  </div>`
1803
1941
  }else if(dataObj.type == "sf-i-uploader"){
1804
1942
  elementHtml += `<div part="uploader-container" class="d-flex flex-col flex-grow">
1805
- <label id="${dataObj.id}-label" part="date-label">${dataObj.label}</label>
1943
+ <label id="${dataObj.id}-label" part="date-label">${elementLabel}</label>
1806
1944
  <div part="td-body-2"><sf-i-elastic-text text="${dataObj.hint}" minLength="50"></sf-i-elastic-text></div>
1807
1945
  <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>
1808
1946
  </div>`
@@ -1847,6 +1985,7 @@ export class SfIReporting extends LitElement {
1847
1985
  html += '<tr class="tablerow">'
1848
1986
  let bgClass = i % 2 == 0 ? 'td-light' : 'td-dark'
1849
1987
  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>`
1988
+ 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>`
1850
1989
  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>`
1851
1990
  for(let property of Object.keys(item)){
1852
1991
  if(this.getIgnoreProjections().indexOf(property) < 0){
@@ -1865,6 +2004,35 @@ export class SfIReporting extends LitElement {
1865
2004
  (this._SfReportingContainer as HTMLDivElement).innerHTML = html;
1866
2005
  (this._SfReportingContainer as HTMLDivElement).style.display = 'block';
1867
2006
 
2007
+ let reopenButtons = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.button-reopen') as NodeListOf<HTMLButtonElement>
2008
+ for(let reopenButton of reopenButtons){
2009
+ reopenButton.addEventListener('click', async (ev: any) => {
2010
+ let target = ev.target
2011
+ let index = target.id.split('-')[2]
2012
+ this.reopenedItem = this.list[index]
2013
+ let oldObj = this.reopenedItem
2014
+ console.log('item selected', this.reopenedItem);
2015
+ await this.fetchSchema();
2016
+ this.published = this.list[index].published ?? false
2017
+ let copyVals: any = {}
2018
+ for(let obj of this.dataModel){
2019
+ if(obj.copytoreopen){
2020
+ console.log('copyVals copying', obj.id, obj.type, oldObj[obj.id]);
2021
+ if(obj.type == "sf-i-bricks" && obj.savenameseparate == "yes"){
2022
+ copyVals[obj.id + 'id'] = oldObj[obj.id + 'id'];
2023
+ copyVals[obj.id + 'name'] = oldObj[obj.id + 'name'];
2024
+ }else{
2025
+ copyVals[obj.id] = oldObj[obj.id];
2026
+ }
2027
+ console.log('copyVals copied',copyVals)
2028
+ }
2029
+ }
2030
+ console.log('copyVals', JSON.parse(JSON.stringify(copyVals)))
2031
+ this.prepopulateValJson = JSON.stringify(copyVals)
2032
+ this.flow = "edit"
2033
+ this.loadMode();
2034
+ })
2035
+ }
1868
2036
  let detailsButtons = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.button-details') as NodeListOf<HTMLButtonElement>
1869
2037
  for(let detailsButton of detailsButtons){
1870
2038
  detailsButton.addEventListener('click',(ev: any) => {
@@ -1876,40 +2044,6 @@ export class SfIReporting extends LitElement {
1876
2044
  this.loadMode();
1877
2045
  })
1878
2046
  }
1879
- // let selectInputs = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.input-select') as NodeListOf<HTMLInputElement>
1880
- // for(let selectInput of selectInputs){
1881
- // selectInput.addEventListener('change',(ev: any) => {
1882
- // let target = ev.target
1883
- // let index = target.id.split('-')[2]
1884
- // if(target.checked){
1885
- // if(this.selectedItemIds.indexOf(this.list[index].id) < 0){
1886
- // this.selectedItemIds.push(this.list[index].id)
1887
- // }
1888
- // }else{
1889
- // if(this.selectedItemIds.indexOf(this.list[index].id) >= 0){
1890
- // this.selectedItemIds.splice(this.selectedItemIds.indexOf(this.list[index].id), 1)
1891
- // }
1892
- // }
1893
-
1894
- // if(this.selectedItemIds.length > 0){
1895
- // ((this._SfReportingContainer as HTMLDivElement).querySelector('#button-publish') as HTMLButtonElement).style.display = 'flex'
1896
- // }else{
1897
- // ((this._SfReportingContainer as HTMLDivElement).querySelector('#button-publish') as HTMLButtonElement).style.display = 'none'
1898
- // }
1899
- // })
1900
- // }
1901
- // let inputSelectAll = (this._SfReportingContainer as HTMLDivElement).querySelector('#input-select-all') as HTMLInputElement
1902
- // inputSelectAll.addEventListener('click',(ev: any)=>{
1903
- // let target = ev.target;
1904
- // let selectInputs = (this._SfReportingContainer as HTMLDivElement).querySelectorAll('.input-select') as NodeListOf<HTMLInputElement>
1905
- // for(let selectInput of selectInputs){
1906
- // selectInput.checked = target.checked
1907
- // var event = document.createEvent("HTMLEvents");
1908
- // event.initEvent('change', false, true);
1909
- // selectInput.dispatchEvent(event);
1910
- // }
1911
- // })
1912
- // inputSelectAll.style.display = this.list.length > 0 ? 'flex' : 'none';
1913
2047
 
1914
2048
  let buttonNew = ((this._SfReportingContainer as HTMLDivElement).querySelector('#button-new') as HTMLButtonElement)
1915
2049
  buttonNew.addEventListener('click',()=>{
@@ -2059,8 +2193,10 @@ export class SfIReporting extends LitElement {
2059
2193
  if(xhr.status == 200) {
2060
2194
  const jsonRespose = JSON.parse(xhr.responseText);
2061
2195
  this.configjson = JSON.stringify(jsonRespose.schema);
2062
- this.populateDataModel();
2063
- this.populateView();
2196
+ // if(this.flow == "new"){
2197
+ this.populateDataModel();
2198
+ this.populateView();
2199
+ // }
2064
2200
  } else {
2065
2201
  const jsonRespose = JSON.parse(xhr.responseText);
2066
2202
  this.setError(jsonRespose.error);
@@ -2114,8 +2250,10 @@ export class SfIReporting extends LitElement {
2114
2250
  submitNew = async () => {
2115
2251
  console.log('adding', this.selectedValues());
2116
2252
  let url = "https://"+this.apiId+"/add";
2117
- let body = {projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published}
2118
- // console.log('adding', body);
2253
+
2254
+ let body:any = {projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published}
2255
+
2256
+ // console.log('adding', body, url);
2119
2257
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
2120
2258
  const xhr : any = (await this.prepareXhr(body, url, this._SfLoader, authorization)) as any;
2121
2259
  this._SfLoader.innerHTML = '';
@@ -2136,6 +2274,11 @@ export class SfIReporting extends LitElement {
2136
2274
  submitEdit = async () => {
2137
2275
  let url = "https://"+this.apiId+"/update";
2138
2276
  let body = {projectid: this.projectid, noticeid: this.selectedItem.id, object: this.selectedValues(), schema: this.getConfigJson(), published: this.published}
2277
+ if(Object.keys(this.reopenedItem).length > 0){
2278
+ url = "https://"+this.apiId+"/reopen"
2279
+ body = {projectid: this.projectid, object: this.selectedValues(), schema: this.getConfigJson(), noticeid: this.reopenedItem.id, published: this.published}
2280
+ }
2281
+ console.log('updating', body, url)
2139
2282
  const authorization = btoa(Util.readCookie('email') + ":" + Util.readCookie('accessToken'));
2140
2283
  const xhr : any = (await this.prepareXhr(body, url, this._SfLoader, authorization)) as any;
2141
2284
  this._SfLoader.innerHTML = '';
@@ -2217,9 +2360,10 @@ export class SfIReporting extends LitElement {
2217
2360
  this.decryptFileName = (this._SfDecryptFileInput as HTMLInputElement).value;
2218
2361
  this.evalDecrypt()
2219
2362
  });
2220
- (this._SfDecryptButton as HTMLButtonElement).addEventListener('click', () => {
2363
+ let decryptButton = this._SfDecryptContainer.querySelector("#button-decrypt") as HTMLButtonElement
2364
+ decryptButton?.addEventListener('click', () => {
2221
2365
  console.log('decrypt clicked', this.decryptProjectId, this.decryptFileName);
2222
- // this.submitDecrypt()
2366
+ this.submitDecrypt()
2223
2367
  })
2224
2368
  }
2225
2369
 
@@ -2325,7 +2469,7 @@ export class SfIReporting extends LitElement {
2325
2469
  <label>Decrypt Utility</label>
2326
2470
  <div class="d-flex align-end">
2327
2471
  <input part="input" id="input-decrypt" type="text" placeholder="file key" />.json&nbsp;&nbsp;
2328
- <button id="button-decrypt" part="button-icon-small" class="material-icons button-icon">download</button>
2472
+ <button id="button-decrypt">download</button>
2329
2473
  </div>
2330
2474
  <div class="loader-element"></div>
2331
2475
  </div>
package/src/util.ts CHANGED
@@ -167,8 +167,12 @@ const timeSince = (date: number) => {
167
167
  }
168
168
  }
169
169
 
170
+ function isInteger(value: string) {
171
+ return /^-?\d+$/.test(value);
172
+ }
173
+
170
174
  const exportFunctions = {
171
- callApi, callApiPresignedDelete, callApiPresignedGet, validateName, readCookie, delay, timeSince
175
+ callApi, callApiPresignedDelete, callApiPresignedGet, validateName, readCookie, delay, timeSince, isInteger
172
176
  };
173
177
 
174
178
  export default exportFunctions;
package/util.d.ts CHANGED
@@ -2,6 +2,7 @@ declare function readCookie(key: string): string;
2
2
  declare function callApi(url: string, data: string, authorization: any): Promise<unknown>;
3
3
  declare function callApiPresignedDelete(url: string): Promise<unknown>;
4
4
  declare function callApiPresignedGet(url: string): Promise<unknown>;
5
+ declare function isInteger(value: string): boolean;
5
6
  declare const exportFunctions: {
6
7
  callApi: typeof callApi;
7
8
  callApiPresignedDelete: typeof callApiPresignedDelete;
@@ -10,6 +11,7 @@ declare const exportFunctions: {
10
11
  readCookie: typeof readCookie;
11
12
  delay: (delayInms: number) => Promise<unknown>;
12
13
  timeSince: (date: number) => string;
14
+ isInteger: typeof isInteger;
13
15
  };
14
16
  export default exportFunctions;
15
17
  //# sourceMappingURL=util.d.ts.map
package/util.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["src/util.ts"],"names":[],"mappings":"AAQA,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAc9B;AAED,iBAAe,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,oBAyBnE;AAED,iBAAe,sBAAsB,CAAC,GAAG,EAAE,MAAM,oBAsBhD;AAED,iBAAe,mBAAmB,CAAC,GAAG,EAAE,MAAM,oBAsB7C;AAwED,QAAA,MAAM,eAAe;;;;yBAxKO,MAAM;;uBAiGR,MAAM;sBAIP,MAAM;CAqE9B,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["src/util.ts"],"names":[],"mappings":"AAQA,iBAAS,UAAU,CAAC,GAAG,EAAE,MAAM,UAc9B;AAED,iBAAe,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,oBAyBnE;AAED,iBAAe,sBAAsB,CAAC,GAAG,EAAE,MAAM,oBAsBhD;AAED,iBAAe,mBAAmB,CAAC,GAAG,EAAE,MAAM,oBAsB7C;AAwED,iBAAS,SAAS,CAAC,KAAK,EAAE,MAAM,WAE/B;AAED,QAAA,MAAM,eAAe;;;;yBA5KO,MAAM;;uBAiGR,MAAM;sBAIP,MAAM;;CAyE9B,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/util.js CHANGED
@@ -133,8 +133,11 @@ const timeSince = (date) => {
133
133
  return Math.floor(Math.abs(seconds)) + " seconds";
134
134
  }
135
135
  };
136
+ function isInteger(value) {
137
+ return /^-?\d+$/.test(value);
138
+ }
136
139
  const exportFunctions = {
137
- callApi, callApiPresignedDelete, callApiPresignedGet, validateName, readCookie, delay, timeSince
140
+ callApi, callApiPresignedDelete, callApiPresignedGet, validateName, readCookie, delay, timeSince, isInteger
138
141
  };
139
142
  export default exportFunctions;
140
143
  //# sourceMappingURL=util.js.map