Skip to content
Merged
9 changes: 9 additions & 0 deletions src/css/map-view.css
Original file line number Diff line number Diff line change
Expand Up @@ -2808,3 +2808,12 @@ other class: .ui-slider-range */
);
}
}

/* Map Editor View */
.map-editor {
font-family: var(--map-body-font);
display: grid;
position: relative;
box-sizing: border-box;
background-color: var(--map-col-background);
}
23 changes: 23 additions & 0 deletions src/js/common/XMLUtilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,29 @@ define([], () => {
return element;
},

/**
* Append a child element containing CDATA. Split `]]>` across CDATA nodes
* because it cannot appear within a single CDATA section.
* @param {XMLDocument} doc XML document used to create elements.
* @param {Element} parent Parent element that receives the child.
* @param {string} name Child element name.
* @param {string} value Text value to append.
* @returns {Element} The appended child element.
*/
appendCdataElement(doc, parent, name, value) {
const element = doc.createElement(name);
const text = this.removeInvalidXmlCharacters(value);
const parts = text.split("]]>");

parts.forEach((part, index) => {
const content = `${index ? ">" : ""}${part}${index < parts.length - 1 ? "]]" : ""}`;
element.appendChild(doc.createCDATASection(content));
});

parent.appendChild(element);
return element;
},

/**
* Extract the XML declaration from raw XML text, if present.
* @param {string|null|undefined} xmlString XML text to inspect.
Expand Down
34 changes: 34 additions & 0 deletions src/js/models/maps/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ define([
*/
initialize(options = {}) {
const config = options;

// Keep a copy of the original configuration for reference.
this.set("originalConfig", JSON.stringify(config));

if (config && config instanceof Object) {
const visibilityState = parseLayerVisibilityStateFromUrl();
if (isNonEmptyArray(config.layerCategories)) {
Expand Down Expand Up @@ -1133,6 +1137,36 @@ define([
});
this.refreshAllLayers();
},

/**
* Validate the map model.
* @returns {object|null} Null if map is valid, otherwise errors keyed by
* attribute names.
*/
validate() {
// TODO: Minimum required validation logic.
return null;
},

/** @returns {boolean} True if map is valid, otherwise false. */
isValid() {
return this.validate() === null;
},

/**
* Serialize the map model to JSON for saving, for example, into a portal
* document.
* @returns {string} The JSON representation of the map model as a string.
* @since 0.0.0
*/
toConfig() {
// TODO: Build toConfig to convert map model abd sub models to a JSON
// representation suitable for saving.

// As an intermediate step in the iterative development, return the
// original, unchanged config
return JSON.parse(this.get("originalConfig"));
},
},
);

Expand Down
Loading