@abi-software/flatmap-viewer 2.3.0-a.5 → 2.3.0-a.6

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/README.rst CHANGED
@@ -38,7 +38,7 @@ The map server endpoint is specified as ``MAP_ENDPOINT`` in ``src/main.js``. It
38
38
  Package Installation
39
39
  ====================
40
40
 
41
- * ``npm install @abi-software/flatmap-viewer@2.3.0-a.5``
41
+ * ``npm install @abi-software/flatmap-viewer@2.3.0-a.6``
42
42
 
43
43
  Documentation
44
44
  -------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/flatmap-viewer",
3
- "version": "2.3.0-a.5",
3
+ "version": "2.3.0-a.6",
4
4
  "description": "Flatmap viewer using Maplibre GL",
5
5
  "repository": "https://github.com/AnatomicMaps/flatmap-viewer.git",
6
6
  "main": "src/main.js",
package/src/annotation.js CHANGED
@@ -245,15 +245,17 @@ export class Annotator
245
245
  for (const field of ANNOTATION_FIELDS) {
246
246
  html.push('<div class="flatmap-annotation-entry">');
247
247
  html.push(` <label for="${field.key}">${field.prompt}:</label>`);
248
- const value = field.update ? provenanceData[field.key] || '' : '';
249
248
  if (field.kind === 'textbox') {
249
+ const value = field.update ? provenanceData[field.key] || '' : '';
250
250
  html.push(` <textarea rows="5" cols="40" id="${field.key}" name="${field.key}">${value.trim()}</textarea>`)
251
251
  } else if (!('kind' in field) || field.kind !== 'list') {
252
+ const value = field.update ? provenanceData[field.key] || '' : '';
252
253
  html.push(` <input type="text" size="40" id="${field.key}" name="${field.key}" value="${value.trim()}"/>`)
253
254
  } else { // field.kind === 'list'
255
+ const listValues = field.update ? provenanceData[field.key] || [] : [];
254
256
  html.push(' <div class="multiple">')
255
257
  for (let n = 1; n <= field.size; n++) {
256
- const fieldValue = (n <= value.length) ? value[n-1].trim() : '';
258
+ const fieldValue = (n <= listValues.length) ? listValues[n-1].trim() : '';
257
259
  html.push(` <input type="text" size="40" id="${field.key}_${n}" name="${field.key}" value="${fieldValue}"/>`)
258
260
  }
259
261
  html.push(' </div>')
@@ -290,8 +292,8 @@ export class Annotator
290
292
  const newProperties = {};
291
293
  let propertiesChanged = false;
292
294
  for (const field of ANNOTATION_FIELDS) {
293
- const lastValue = field.update ? provenanceData[field.key] || '' : '';
294
295
  if (!('kind' in field) || field.kind !== 'list') {
296
+ const lastValue = field.update ? provenanceData[field.key] || '' : '';
295
297
  const inputField = document.getElementById(field.key);
296
298
  const newValue = inputField.value.trim();
297
299
  if (newValue !== lastValue.trim()) {
@@ -304,6 +306,7 @@ export class Annotator
304
306
  const inputField = document.getElementById(`${field.key}_${n}`);
305
307
  listValues.push(inputField.value.trim());
306
308
  }
309
+ const lastValue = field.update ? provenanceData[field.key] || [] : [];
307
310
  const oldValues = lastValue.map(v => v.trim()).filter(v => (v !== '')).sort();
308
311
  const newValues = listValues.map(v => v.trim()).filter(v => (v !== '')).sort();
309
312
  if (oldValues.length !== newValues.length