@@ -2,8 +2,6 @@ import templateContent from "./template.html?raw";
2
2
import * as FilePondLib from "filepond" ;
3
3
import { FilePond , FilePondOptions } from "filepond" ;
4
4
import filepondCSS from "filepond/dist/filepond.min.css?inline" ;
5
- // import typeahead from "typeahead-standalone";
6
- import typeaheadCSS from "typeahead-standalone/dist/basic.css?inline" ;
7
5
import customCSS from './style.css?inline' ;
8
6
9
7
const ATTRIBUTES : string [ ] = [ "base-url" ] ;
@@ -23,7 +21,6 @@ class MappingInputProvider extends HTMLElement {
23
21
24
22
selectedMappingId : string | null = null ;
25
23
selectedMappingType : string | null = null ;
26
-
27
24
messageDisplayed : boolean | null = null ;
28
25
// --- Helper methods
29
26
addCssContent ( css : string ) : void {
@@ -48,7 +45,6 @@ class MappingInputProvider extends HTMLElement {
48
45
// Create Shadow DOM
49
46
this . shadowRoot = this . attachShadow ( { mode : "open" } ) ;
50
47
this . addCssContent ( filepondCSS ) ;
51
- this . addCssContent ( typeaheadCSS ) ;
52
48
this . addCssContent ( customCSS ) ;
53
49
54
50
// Apply HTML Template to shadow DOM
@@ -97,36 +93,20 @@ class MappingInputProvider extends HTMLElement {
97
93
this . testingFileChooser = FilePondLib . create ( filepondElement , options ) ;
98
94
}
99
95
100
- //Box of detailed contents like title , description
96
+ //Box of detailed contents like image , description of mapping
101
97
const mappingIdsEndpoint = this . baseUrl . toString ( ) + "api/v1/mappingAdministration/" ;
102
98
let optionsContainer : HTMLElement = < HTMLInputElement > (
103
99
this . shadowRoot . getElementById ( 'options-container' )
104
100
) ;
105
- optionsContainer . addEventListener ( "click" , ( event ) => {
106
- const selectedButton = event . target as HTMLElement ;
107
- console . log ( selectedButton ) ;
108
- // Remove the "selected" class from all buttons
109
- const buttons = optionsContainer . querySelectorAll ( ".selection-button" ) ;
110
- // console.log(buttons);
111
- buttons . forEach ( ( button ) => {
112
- button . classList . remove ( "selected-id" ) ;
113
-
114
- } ) ;
115
- // Add the "selected" class to the clicked button
116
- selectedButton . classList . add ( "selected-id" ) ;
101
+ // Remove any existing event listeners before adding a new one
102
+ optionsContainer . removeEventListener ( "click" , this . handleButtonClick . bind ( this ) ) ;
117
103
118
- // Get the selected mapping ID from the button's ID
119
- const selectedMappingId = selectedButton . id . replace ( "mapping-button-" , "" ) ;
120
- this . selectedMappingId = selectedMappingId ;
121
-
122
- // const selectedType=selectedButton
123
- console . log ( selectedButton ) ;
124
- } ) ;
104
+ // Add the event listener
105
+ optionsContainer . addEventListener ( "click" , this . handleButtonClick . bind ( this ) ) ;
125
106
126
107
fetch ( mappingIdsEndpoint ) . then ( response => response . json ( ) )
127
108
. then ( ( mappingIdsData : MappingItem [ ] ) => {
128
109
const mappingIds = mappingIdsData . map ( ( item : MappingItem ) => ( {
129
-
130
110
id : item . mappingId ,
131
111
title : item . title ,
132
112
description : item . description ,
@@ -135,63 +115,39 @@ class MappingInputProvider extends HTMLElement {
135
115
optionsContainer . innerHTML = '' ;
136
116
mappingIds . forEach ( mapping => {
137
117
const division = document . createElement ( "div" )
138
- // const button = document.createElement("button");
139
- // button.classList.add("xyz");
140
- division . classList . add ( "xyz" ) ;
141
- // button.setAttribute("data-test", "start-basics");
142
- // button.id = `${mapping.id}`;
143
- // button.innerText = "Select";
144
-
145
- //<span class="selected-type section-type">Type : ${mapping.type}</span>
146
- // <span class="home-price section-heading"> ${mapping.title}</span>
118
+ division . classList . add ( "cards" ) ;
147
119
division . innerHTML = `
120
+ <!-- Commenting out the image section -->
121
+ <!--
148
122
<img class="mapping-image" src="${ this . getImageByType ( mapping . type ) } " alt="Mapping Image" />
149
-
150
-
123
+ -->
124
+ <h3> ${ mapping . title } </h3>
151
125
<span class="home-text10 section-description">
152
126
<br>
153
127
<span style="display:inline-block; overflow: auto; height: 124px;">
154
128
${ mapping . description }
155
129
</span>
156
- <span></span>
157
130
</span>
158
131
<button class ="selection-button " id="mapping-button-${ mapping . id } " >Select</button>
159
-
160
-
161
132
` ;
162
-
163
133
const button = division . querySelector ( `#mapping-button-${ mapping . id } ` ) ;
164
-
165
134
if ( button ) {
166
135
button . addEventListener ( "click" , ( ) => {
167
136
this . selectedMappingId = mapping . id ;
168
-
169
- console . log ( this . selectedMappingId ) ;
170
137
if ( ! this . messageDisplayed ) {
171
138
const fileInput = this . shadowRoot . querySelector ( "#fileUpload" ) ;
172
-
173
139
const messageElement = document . createElement ( "div" ) ;
174
- // messageElement.style.display = "none";
175
140
messageElement . innerText = "Please upload file and then click on map document to extract metadata" ;
176
141
messageElement . style . marginBottom = "10px" ; // Add some bottom margin for spacing
177
142
messageElement . classList . add ( "message" ) ;
178
143
if ( fileInput != null && fileInput . parentNode != null ) {
179
144
fileInput . parentNode . insertBefore ( messageElement , fileInput ) ;
180
145
}
181
146
this . messageDisplayed = true ;
182
-
183
147
}
184
-
185
- // this.displayMessage("Please upload file and then click on map document to extract metadata");
186
- // this.executeMapping(selectedMappingId);
187
- const selectedMappingType = mapping . type ;
188
- console . log ( selectedMappingType ) ;
189
-
190
-
191
148
} ) ;
192
149
}
193
150
optionsContainer . appendChild ( division ) ;
194
-
195
151
} )
196
152
} ) . catch ( error => {
197
153
console . error ( 'Error while fetch Mapping Ids' + error )
@@ -203,7 +159,6 @@ class MappingInputProvider extends HTMLElement {
203
159
* Invoked each time the custom element is disconnected from the document's DOM.
204
160
*/
205
161
disconnectedCallback ( ) : void {
206
- return ;
207
162
}
208
163
209
164
/**
@@ -238,9 +193,6 @@ class MappingInputProvider extends HTMLElement {
238
193
async executeMapping ( download : boolean = false ) : Promise < any > {
239
194
document . body . style . cursor = 'wait' ;
240
195
const selectedMappingId = this . selectedMappingId ;
241
- // const selectedValue = inputElement?.value;
242
- // console.log('Selected Value ' +selectedValue)
243
- // const selectedMappingId = selectedValue?.split("-")[0].trim();
244
196
if ( selectedMappingId && this . testingFileChooser != null ) {
245
197
const uploadedFile = this . testingFileChooser . getFile ( ) ;
246
198
if ( uploadedFile != null ) {
@@ -291,17 +243,43 @@ class MappingInputProvider extends HTMLElement {
291
243
URL . revokeObjectURL ( element . href ) ;
292
244
}
293
245
246
+ /**
247
+ * In case if you want to show images according the the mappingType eg: SEM,TEM etc yu can use this method
248
+ */
294
249
getImageByType ( mappingType : string ) : string {
295
250
if ( mappingType . includes ( "GEMMA" ) ) {
296
- return "https://th.bing.com/th/id/R.13af2c708c50701c5c418f39f1032c4a?rik=Bhi%2fy8GZ%2fC%2b1%2bg&riu=http%3a%2f%2flogos.textgiraffe.com%2flogos%2flogo-name%2fGemma-designstyle-pastel-m.png&ehk=oiRKyC5Jg2VKEybuGyH%2f8q4l73rWTBZpvXw7hP69AOk%3d&risl=&pid=ImgRaw&r=0" ;
251
+ // Assuming gemma.png is in the assets/images folder
252
+ return "/images/gemma.png" ;
297
253
} else if ( mappingType . includes ( "SEM" ) ) {
298
- return "https://th.bing.com/th/id/R.aaebd43a8dc60519d02c93699d67fa33?rik=c9P%2bsFde%2bGc8gg&riu=http%3a%2f%2fwww.benspaintsupply.com%2fwp-content%2fuploads%2f2011%2f10%2fSEM-Logo.jpg&ehk=n3cCc0XCRDKt0XFslLWIafoPO6zFEMc91UZQJA6hxuA%3d&risl=&pid=ImgRaw&r=0" ;
254
+ // Assuming sem.png is in the assets/images folder
255
+ return "/images/tem.png" ;
299
256
} else if ( mappingType . includes ( "TEM" ) ) {
300
- return "https://en.tem.ch/wp-content/uploads/sites/2/2019/08/TEM_Logo_Ohne_Claim.jpg" ;
257
+ // Assuming tem.png is in the assets/images folder
258
+ return "/images/tem.png" ;
301
259
} else {
302
- return "https://th.bing.com/th/id/OIP.dDFaFWAAhofP-4yOMUOsCwHaD5?pid=ImgDet&rs=1" ;
260
+ // Default image path when no mapping type matches
261
+ return "/images/other.png" ;
303
262
}
304
263
}
264
+
265
+ /**
266
+ * We have used this method to capture mapping id which is later used to execute mapping
267
+ */
268
+ private handleButtonClick ( event : Event ) {
269
+ const selectedButton = event . target as HTMLElement ;
270
+ console . log ( selectedButton ) ;
271
+ // Remove the "selected" class from all buttons
272
+ const buttons = this . shadowRoot . querySelectorAll ( ".selection-button" ) ;
273
+ buttons . forEach ( ( button ) => {
274
+ button . classList . remove ( "selected-id" ) ;
275
+ } ) ;
276
+ // Add the "selected" class to the clicked button
277
+ selectedButton . classList . add ( "selected-id" ) ;
278
+
279
+ // Get the selected mapping ID from the button's ID
280
+ const selectedMappingId = selectedButton . id . replace ( "mapping-button-" , "" ) ;
281
+ this . selectedMappingId = selectedMappingId ;
282
+ }
305
283
}
306
284
307
285
// Custom Elements:
0 commit comments