/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
onDeviceFormHide() { // Ensure that we have onDeviceFormHide before calling it. if (this.props.onDeviceFormHide) { this.props.onDeviceFormHide();
}
}
onInputFocus(e) { // If the formType is "add", select all text in input field when focused. if (this.props.formType === "add") {
e.target.select();
}
}
/** * Validates the name field's value. * * @param {String} value * The input field value for the device name. * @return {Boolean} true if device name is valid, false otherwise.
*/
validateNameField(value) { const nameFieldValue = value.trim();
let isValidDeviceName = false;
// If the formType is "add", then we just need to check if a custom device with that // same name exists. if (this.props.formType === "add") {
isValidDeviceName = !this.props.devices.custom.find(
device => device.name == nameFieldValue
);
} else { // Otherwise, the formType is "edit". We'd have to find another device that // already has the same name, but not itself, so: // Find the index of the device being edited. Use this index value to distinguish // between the device being edited from other devices in the list. const deviceIndex = this.props.devices.custom.findIndex(({ name }) => { return name === this.props.device.name;
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.