/** * Licensed Materials - Property of IBM * IBM Cognos Products: BI UI_Commons * (C) Copyright IBM Corp. 2017 * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ define('baglass/core-client/js/core-client/utils/ValidationUtils',['../i18n/Formatter', 'underscore', '../nls/StringResources', '../ui/dialogs/MessageBox'], function (Formatter, _, StringResources, MessageBox) { return { _getValidationMessages: function _getValidationMessages() { return { 'isNumber': function isNumber() { return StringResources.get('invalidNumber'); }, 'isEmail': function isEmail() { return StringResources.get('invalidEmailMessage'); }, 'maxLength': function (checkList, timeLocale) { timeLocale = timeLocale || {}; return StringResources.get('exceedMaxLength', { 'maxLength': Formatter.formatNumber(checkList.maxLength, { 'locale': timeLocale.contentLocale }) }); }.bind(this), 'numericRange': function numericRange(checkList, timeLocale) { var errorMessage; if (checkList.numericRange.min !== undefined && checkList.numericRange.max !== undefined) { errorMessage = StringResources.get('numberOutOfRange', { 'min': Formatter.formatNumber(checkList.numericRange.min, { 'locale': timeLocale.contentLocale }), 'max': Formatter.formatNumber(checkList.numericRange.max, { 'locale': timeLocale.contentLocale }) }); } else if (checkList.numericRange.min !== undefined) { errorMessage = StringResources.get('numberTooSmall', { 'min': Formatter.formatNumber(checkList.numericRange.min, { 'locale': timeLocale.contentLocale }) }); } else if (checkList.numericRange.max !== undefined) { errorMessage = StringResources.get('numberTooBig', { 'max': Formatter.formatNumber(checkList.numericRange.max, { 'locale': timeLocale.contentLocale }) }); } return errorMessage; } }; }, /** * Validate an input * @param value {string} - the value to be validated * @param checkList {object} - the different 'validators' to be applied to the value * @param validationFailedCallback {function} - if the validation fails, a dialog will be shown. This callback will be called once that dialog is hidden by the user. * @return true|false depending if the value is valid */ validateInput: function validateInput(value, checkList, validationFailedCallback, timeLocale) { var okCallback = function okCallback(e) { e.stopPropagation(); MessageBox.inherited('ok', this, arguments); if (validationFailedCallback) { validationFailedCallback(); } return false; }; for (var validationCheck in checkList) { if (checkList.hasOwnProperty(validationCheck)) { // Function names for validation need to start with '_validate' var funcName = '_validate' + validationCheck.charAt(0).toUpperCase() + validationCheck.slice(1); if (this[funcName] && !this[funcName](value, checkList)) { var dlg = new MessageBox('warning', StringResources.get('invalidInput'), this.GET_VALIDATION_MESSAGES[validationCheck](checkList, timeLocale)); dlg.ok = okCallback; dlg.open(); return false; } } } return true; } }; }); //# sourceMappingURL=ValidationUtils.js.map ; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Content Explorer *| (C) Copyright IBM Corp. 2015, 2017 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define('baglass/core-client/js/core-client/utils/GlassContextHelper',[], function () { 'use strict'; var GlassContextHelper = function GlassContextHelper() {}; /* @glassContext - glassContext @jqXHR - jQuery XMLHttpRequest returned by Glass Ajax service on fail Is temporary and should be removed when Glass handles the showing of error messages */ GlassContextHelper.prototype.showAjaxServiceErrorMessage = function (glassContext, jqXHR) { var messages = ''; if (jqXHR) { var responseJSON = jqXHR.responseJSON; if (responseJSON) { if (responseJSON.messages) { messages = jqXHR.responseJSON.messages.join('\n'); } else if (responseJSON.cause) { try { var cause = JSON.parse(responseJSON.cause); if (cause.messages) { messages = cause.messages.join('\n'); } } catch (e) { //if we get here, 'cause' is not a json object messages = responseJSON.cause; } } } else { messages = jqXHR.responseText; } } glassContext.appController.showErrorMessage(messages, 'Error'); }; /* @glassContext - glassContext @str - the message @options - an options jsonObject to pass to glass's showToast */ GlassContextHelper.prototype.displayToast = function (glassContext, str, options) { glassContext.appController.showToast(str, options); }; /* * preference - name of the preference setting to get. e.g contentLocale, email, etc */ GlassContextHelper.prototype.getUserPreference = function (glassContext, preference) { return glassContext.getCoreSvc('.UserProfile').preferences[preference]; }; GlassContextHelper.prototype.getContentLocales = function (glassContext) { return glassContext.getCoreSvc('.Config').getContentLocales(); }; GlassContextHelper.prototype.getLocaleTime = function (glassContext) { var preferences = glassContext ? glassContext.getCoreSvc('.UserProfile').preferences : {}; return { timeZone: preferences.timeZoneID || 'America/New_York', contentLocale: preferences.contentLocale || 'en' }; }; return new GlassContextHelper(); }); //# sourceMappingURL=GlassContextHelper.js.map ; /* *+------------------------------------------------------------------------+ *| Licensed Materials - Property of IBM *| IBM Cognos Products: Content Explorer *| (C) Copyright IBM Corp. 2015, 2021 *| *| US Government Users Restricted Rights - Use, duplication or disclosure *| restricted by GSA ADP Schedule Contract with IBM Corp. *+------------------------------------------------------------------------+ */ define('baglass/core-client/js/core-client/ui/properties/BaseProperty',['../core/View', 'jquery', 'underscore', '../../utils/BidiUtil', '../../utils/ContentFormatter', '../../utils/ValidationUtils', '../KeyCodes', '../../nls/StringResources', '../../utils/GlassContextHelper', '../dialogs/MessageBox'], function (View, $, _, BidiUtil, ContentFormatter, ValidationUtils, KeyCodes, StringResources, GlassContextHelper, MessageBox) { 'use strict'; var BaseProperty = View.extend({ /** @param options.id - unique id @param options.validator - for validating property value @param options.validator.script {boolean} - validation to check if value contains "