UNPKG

hadron-document

Version:
50 lines 1.65 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const hadron_type_checker_1 = __importDefault(require("hadron-type-checker")); const element_events_1 = require("../element-events"); const standard_1 = __importDefault(require("./standard")); /** * CRUD editor for int32 values. */ class Int64Editor extends standard_1.default { /** * Create the editor with the element. * * @param {Element} element - The hadron document element. */ constructor(element) { super(element); } /** * Complete the int64 edit by converting the valid string to a int64 * value or leaving as invalid. */ complete() { super.complete(); if (this.element.isCurrentTypeValid()) { this.element.edit(hadron_type_checker_1.default.cast(this.element.currentValue, 'Int64')); } } /** * Edit Int64 element. Check if the value is a Int64 before setting typed * up value. * * @param {Object} value - The new value. */ edit(value) { try { hadron_type_checker_1.default.cast(value, 'Int64'); this.element.currentValue = value; this.element.setValid(); this.element._bubbleUp(element_events_1.ElementEvents.Edited, this.element); } catch (error) { this.element.setInvalid(value, this.element.currentType, error.message); } } } exports.default = Int64Editor; //# sourceMappingURL=int64.js.map