lodash#isUndefined JavaScript Examples
The following examples show how to use
lodash#isUndefined.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.js From hzero-front with Apache License 2.0 | 7 votes |
/**
* 渲染一级菜单的icon
* @param {string} menu - menu 菜单
* @param {string} classPrefix - 样式前缀
// * @param {boolean} isHover - 时候hover
*/
export function renderIcon(menu, classPrefix = 'main-menu-item' /* , isHover */) {
const classNames = [styles[`${classPrefix}-icon`]];
const { name, icon, path } = menu;
classNames.push(styles[`${classPrefix}-icon-img`]);
if (!isUndefined(icon)) {
return name.includes('choerodon') && path.includes('hlcd') ? (
<Icon type={icon} style={{ fontSize: '12px' }} className={classNames.join(' ')} />
) : (
<Icons type={icon} className={classNames.join(' ')} />
);
} else {
return <Icons type="development-management" className={classNames.join(' ')} />;
}
}
Example #2
Source File: utils.ui.js From jafar with MIT License | 7 votes |
export function mapFieldToProps(id, model, resources) {
const field = isUndefined(model) ? undefined : model.fields[id];
// if the field is not defined, or the field.component not defined, or the core actions still didn't
// formatted the field value into the component.value - then field is excluded
if (isUndefined(field) || isUndefined(field.component) || !Object.keys(field.component).includes('value')) {
return {
id,
excluded: true,
};
}
const { renderer } = resources.components[field.component.name] || {};
return {
id,
label: field.label,
description: field.description,
value: field.component.value,
component: renderer,
state: field.component.state,
excluded: field.excluded,
disabled: field.disabled,
dirty: field.dirty,
required: field.required,
empty: field.empty,
errors: field.errors,
invalid: !(field.required && field.empty) && field.errors.length > 0, // required is not considered invalid in UX terms
};
}
Example #3
Source File: index.js From datapass with GNU Affero General Public License v3.0 | 6 votes |
function changelogFormatTransformer(accumulatorArray, changes, key) {
let valueBefore, valueAfter;
if (changes.length === 2) [valueBefore, valueAfter] = changes;
if (changes.length === 1) [valueAfter] = changes;
const label = getLabel(key);
let displayedValueBefore = getDisplayValue(valueBefore);
const displayedValueAfter = getDisplayValue(valueAfter);
if (isBoolean(valueAfter) && isUndefined(valueBefore)) {
displayedValueBefore = getDisplayValue(false);
}
const separator =
(displayedValueBefore || '').toString().length < 120 ? '"' : '\n\n';
accumulatorArray.push(
`Changement ${label} de ${separator}${displayedValueBefore}${separator} en ${separator}${displayedValueAfter}${separator}`
);
return accumulatorArray;
}
Example #4
Source File: CheckoutForm.js From web with MIT License | 6 votes |
componentDidMount() {
const isMobile = !isUndefined(global.window)
? global.window.innerWidth < 768
: false;
setTimeout(() => {
this.setState({ isVisible: true });
// const scroll = new SmoothScroll();
// scroll.animateScroll(isMobile ? 1100 : 450);
}, 200);
}
Example #5
Source File: Group.jsx From kube-design with MIT License | 6 votes |
componentDidMount() {
const { checkable, keepDataWhenUnCheck } = this.props;
const { formData } = this.context;
if (
checkable &&
!keepDataWhenUnCheck &&
formData &&
this.items.size > 0 &&
Array.from(this.items).some((item) => !isUndefined(get(formData, item)))
) {
this.setState({ isCheck: true });
}
}
Example #6
Source File: index.js From hzero-front with Apache License 2.0 | 6 votes |
@Bind()
save(data) {
const { form, field: fieldName } = this.props;
const { list, language } = this.state;
// 设置多语言后,构建编辑的数据结构
const newList = Object.keys(data).map(item => {
const filterName = list.find(items => item === items.code);
return { code: item, value: data[item], name: filterName.name || '' };
});
this.setState({ text: data[language], list: newList, modalVisible: false, isSave: true });
if (form && isUndefined(form.getFieldValue('_tls'))) {
// 往外层form配置_tls表单域
form.registerField('_tls');
// 设置_tls值
form.setFieldsValue({ _tls: { [fieldName]: data } });
} else {
const oldTls = form.getFieldValue('_tls');
const newTls = { ...oldTls, [fieldName]: data };
form.setFieldsValue({ _tls: newTls });
}
// 更新input显示值
if (this.props.onChange) {
this.props.onChange(data[language]);
}
}