Skip to content

Commit

Permalink
minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reed-tom committed Nov 30, 2023
1 parent 4626594 commit 0e03167
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
16 changes: 9 additions & 7 deletions src/helpers/Popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ export default class Popup extends Overlay {
}

if (this.contentIndex + 1 >= this.contentArray.length) {
this.contentNextButtonContainer.className = "sc-popup-content-next-button disabled";
this.contentNextButtonContainer.className = "sc-popup-content-next-button sc-disabled";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button";
} else if (this.contentIndex - 1 < 0) {
this.contentNextButtonContainer.className = "sc-popup-content-next-button";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled";
} else {
this.contentNextButtonContainer.className = "sc-popup-content-next-button";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button";
Expand All @@ -103,9 +103,9 @@ export default class Popup extends Overlay {
}
if (this.contentIndex - 1 < 0) {
this.contentNextButtonContainer.className = "sc-popup-content-next-button";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled";
} else if (this.contentIndex + 1 >= this.contentArray.length) {
this.contentNextButtonContainer.className = "sc-popup-content-next-button disabled";
this.contentNextButtonContainer.className = "sc-popup-content-next-button sc-disabled";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button";
} else {
this.contentNextButtonContainer.className = "sc-popup-content-next-button";
Expand Down Expand Up @@ -209,7 +209,7 @@ export default class Popup extends Overlay {
if (this.contentIndex <= 0) {
// this.contentPrevButton.style.display = "none";
this.contentNextButtonContainer.className = "sc-popup-content-next-button";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button disabled";
this.contentPrevButtonContainer.className = "sc-popup-content-prev-button sc-disabled";
}
if (callback) callback();
return;
Expand Down Expand Up @@ -249,8 +249,10 @@ export default class Popup extends Overlay {
if (header)
header.addEventListener("mousedown", (evt) => {
// IGNORE CLOSE BUTTON OR MOBILE
var isCloser = evt.target.classList.contains("ol-popup-closer");
if (isClosing || isCloser || helpers.isMobile()) {
console.log(evt.target.classList);
var isHeaderButton = evt.target.classList.contains("ol-popup-closer") || evt.target.classList.contains("ol-popup-previous") || evt.target.classList.contains("ol-popup-next");

if (isHeaderButton || isHeaderButton || helpers.isMobile()) {
isMoving = false;
isClosing = false;
return;
Expand Down
19 changes: 17 additions & 2 deletions src/helpers/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,8 @@ export function getWFSGeoJSON(serverUrl, layerName, callback, sortField = null,
export function getWFSLayerRecordCount(serverUrl, layerName, callback) {
const recordCountUrlTemplate = (serverURL, layerName) => `${serverURL}wfs?REQUEST=GetFeature&VERSION=1.1&typeName=${layerName}&RESULTTYPE=hits`;
const recordCountUrl = recordCountUrlTemplate(serverUrl, layerName);
console.log("getWFSLayerRecordCount - url", recordCountUrl);

getObjectFromXMLUrl(recordCountUrl, (result) => {
console.log("getWFSLayerRecordCount - result", result);
callback(result["wfs:FeatureCollection"]["$"].numberOfFeatures);
});
}
Expand Down Expand Up @@ -1139,6 +1138,22 @@ export function getWKTStringFromFeature(feature) {
// return feature;
}

export function formatReplace(fmt, ...args) {
if (!fmt.match(/^(?:(?:(?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{[0-9]+\}))+$/)) {
throw new Error("invalid format string.");
}
return fmt.replace(/((?:[^{}]|(?:\{\{)|(?:\}\}))+)|(?:\{([0-9]+)\})/g, (m, str, index) => {
if (str) {
return str.replace(/(?:{{)|(?:}})/g, (m) => m[0]);
} else {
if (index >= args.length) {
throw new Error("argument index is out of range in format");
}
return args[index];
}
});
}

export function toLatLongFromWebMercator(coords) {
return transform(coords, "EPSG:3857", "EPSG:4326");
}
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/components/mymaps/MyMapsFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const MyMapsFooter = (props) => {
<MenuItem className="sc-floating-menu-toolbox-menu-item" key="sc-floating-menu-merge-polygons">
<FloatingMenuItem imageName={"merge_polygon.png"} label="Merge Polygons" />
</MenuItem>
<SubMenu title="Export to ...">
<SubMenu title="Export to ..." key="sc-floating-menu-export">
<MenuItem className="sc-floating-menu-toolbox-menu-item" key="sc-floating-menu-export-all-to-kml">
<FloatingMenuItem label="KML" />
</MenuItem>
Expand Down
12 changes: 10 additions & 2 deletions src/sidebar/components/tools/weather/WeatherRadar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Static from "ol/source/ImageStatic";
const WeatherRadar = (props) => {
const radarImages = useRef([]);
const radarInterval = useRef(null);

const [radarDateSliderValue, setRadarDateSliderValue] = useState(helpers.roundTime(new Date()));
const [radarOpacitySliderValue, setRadarOpacitySliderValue] = useState(0.7);
const [startDate, setStartDate] = useState(helpers.roundTime(new Date(new Date().setHours(new Date().getHours() - 3))));
Expand Down Expand Up @@ -93,14 +94,21 @@ const WeatherRadar = (props) => {
};

const setStartAndEndDateDefault = () => {
setRadarDateSliderValue(startDate);
const firstImage = radarImages.current[0];
const startDate = firstImage.get("radarDate");
const lastImage = radarImages.current[radarImages.current.length - 1];
const endDate = lastImage.get("radarDate");

setStartDate(startDate);
setEndDate(endDate);
setRadarDateSliderValue(endDate);
window.map.once(
"postrender",
(event) => {
setIsLoading(false);
},
() => {
setRadarDateSliderValue(startDate);
setRadarDateSliderValue(endDate);
}
);
};
Expand Down

0 comments on commit 0e03167

Please sign in to comment.