Skip to content

Commit

Permalink
Merge pull request #1011 from nathang15/failure-if-no-map-file-chosen…
Browse files Browse the repository at this point in the history
…-or-no-name-on-creation

Fix failure if no map file chosen or no name
  • Loading branch information
huss authored Sep 17, 2023
2 parents ad32738 + 59ac455 commit a5c512f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
25 changes: 18 additions & 7 deletions src/client/app/components/maps/MapCalibrationInitiateComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ type MapInitiatePropsWithIntl = MapInitiateProps & WrappedComponentProps;

class MapCalibrationInitiateComponent extends React.Component<MapInitiatePropsWithIntl, MapInitiateState > {
private readonly fileInput: any;
private notifyLoadComplete() {
window.alert(`${this.props.intl.formatMessage({id: 'map.load.complete'})} ${this.state.filename}.`);
}
private notifyBadNumber() {
window.alert(`${this.props.intl.formatMessage({id: 'map.bad.number'})}`);
}
Expand All @@ -43,6 +40,12 @@ class MapCalibrationInitiateComponent extends React.Component<MapInitiatePropsWi
private notifyBadDigit0() {
window.alert(`${this.props.intl.formatMessage({id: 'map.bad.digitb'})}`);
}
private notifyBadMapLoad() {
window.alert(`${this.props.intl.formatMessage({id: 'map.bad.load'})}`);
}
private notifyBadName() {
window.alert(`${this.props.intl.formatMessage({id: 'map.bad.name'})}`);
}

constructor(props: MapInitiatePropsWithIntl) {
super(props);
Expand All @@ -54,13 +57,14 @@ class MapCalibrationInitiateComponent extends React.Component<MapInitiatePropsWi
this.fileInput = React.createRef();
this.handleInput = this.handleInput.bind(this);
this.confirmUpload = this.confirmUpload.bind(this);
this.notifyLoadComplete = this.notifyLoadComplete.bind(this);
this.handleNameInput = this.handleNameInput.bind(this);
this.handleAngleInput = this.handleAngleInput.bind(this);
this.handleAngle = this.handleAngle.bind(this);
this.notifyBadNumber = this.notifyBadNumber.bind(this);
this.notifyBadDigit360 = this.notifyBadDigit360.bind(this);
this.notifyBadDigit0 = this.notifyBadDigit0.bind(this);
this.notifyBadMapLoad = this.notifyBadMapLoad.bind(this);
this.notifyBadName = this.notifyBadName.bind(this);
}

public render() {
Expand Down Expand Up @@ -94,9 +98,16 @@ class MapCalibrationInitiateComponent extends React.Component<MapInitiatePropsWi
private async confirmUpload(event: any) {
const bcheck = this.handleAngle(event);
if (bcheck) {
await this.handleInput(event);
await this.notifyLoadComplete();
this.props.updateMapMode(CalibrationModeTypes.calibrate);
if (this.fileInput.current.files.length === 0) {
this.notifyBadMapLoad();
}
else if (this.state.mapName.trim() === '') {
this.notifyBadName();
}
else {
await this.handleInput(event);
this.props.updateMapMode(CalibrationModeTypes.calibrate);
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion src/client/app/translations/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ const localeData = {
"manage": "Manage",
"map": "Map",
"maps": "Maps",
"map.bad.load": "Map image file needed",
"map.bad.name": "Map name needed",
"map.bad.number": "Not a number, please change angle to a number between 0 and 360",
"map.bad.digita": "Greater than 360, please change angle to a number between 0 and 360",
"map.bad.digitb": "Less than 0, please change angle to a number between 0 and 360",
Expand All @@ -296,7 +298,7 @@ const localeData = {
"map.is.displayable": "Display Enabled",
"map.is.not.calibrated": "Calibration Needed",
"map.is.not.displayable": "Display Disabled",
"map.load.complete": "Map load complete from",
"map.load.complete": "Map load complete from",
"map.modified.date": "Last Modified",
"map.name": "Map Name",
"map.new.angle": "List the angle with respect to true north (0 to 360)",
Expand Down Expand Up @@ -750,6 +752,8 @@ const localeData = {
"manage": "(Need French) Manage",
"map": "Carte",
"maps": "Plans",
"map.bad.load": "Fichier image de la carte requis",
"map.bad.name": "Nom de la carte requis",
"map.bad.number": "Pas un nombre, veuillez changer l'angle en un nombre entre 0 et 360",
"map.bad.digita": "Supérieur à 360, veuillez changer l'angle en un nombre compris entre 0 et 360",
"map.bad.digitb": "Moins de 0, veuillez changer l'angle en un nombre compris entre 0 et 360",
Expand Down Expand Up @@ -1220,6 +1224,8 @@ const localeData = {
"manage": "Gestionar",
"map": "Mapa",
"maps": "Mapas",
"map.bad.load": "Se necesita el archivo de la imagen del mapa",
"map.bad.name": "Nombre para el mapa es necesario",
"map.bad.number": "Ni un número, por favor cambiar el angúlo entre 0 a 360",
"map.bad.digita": "Mayor que 360, por favor cambiar el angúlo a un número entre 0 a 360",
"map.bad.digitb": "Menor que 0, por favor cambiar el angúlo a un número entre 0 a 360",
Expand Down

0 comments on commit a5c512f

Please sign in to comment.