diff --git a/.gitignore b/.gitignore index 26776490be..f7c584e23c 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ *.log /packages/asc-web-components /products/ASC.People/Data/ +Data/ diff --git a/products/ASC.People/Client/src/store/people/selectors.js b/products/ASC.People/Client/src/store/people/selectors.js index aad26c2ead..066e923b5e 100644 --- a/products/ASC.People/Client/src/store/people/selectors.js +++ b/products/ASC.People/Client/src/store/people/selectors.js @@ -1,4 +1,4 @@ -import { find, filter } from "lodash"; +import { find, filter, cloneDeep } from "lodash"; import { EmployeeActivationStatus, EmployeeStatus } from "../../helpers/constants"; export function getSelectedUser(selection, userId) { @@ -141,5 +141,5 @@ export function toEmployeeWrapper(profile) { contacts: [] }; - return { ...emptyData, ...profile }; + return cloneDeep({ ...emptyData, ...profile }); } \ No newline at end of file diff --git a/web/ASC.Web.Components/package.json b/web/ASC.Web.Components/package.json index a138ef8985..d358cb187a 100644 --- a/web/ASC.Web.Components/package.json +++ b/web/ASC.Web.Components/package.json @@ -1,6 +1,6 @@ { "name": "asc-web-components", - "version": "1.0.65", + "version": "1.0.66", "description": "Ascensio System SIA component library", "license": "AGPL-3.0", "main": "dist/asc-web-components.js", diff --git a/web/ASC.Web.Components/src/components/icon-button/index.js b/web/ASC.Web.Components/src/components/icon-button/index.js index 4f72c4c9c9..d3cfb384f0 100644 --- a/web/ASC.Web.Components/src/components/icon-button/index.js +++ b/web/ASC.Web.Components/src/components/icon-button/index.js @@ -2,16 +2,17 @@ import React from "react"; import PropTypes from "prop-types"; import styled from 'styled-components'; import { Icons } from '../icons'; +import isEqual from 'lodash/isEqual'; const StyledOuter = styled.div` width: ${props => props.size ? Math.abs(parseInt(props.size)) + "px" : "20px"}; cursor: ${props => props.isDisabled || !props.isClickable ? 'default' : 'pointer'}; line-height: 0; `; -class IconButton extends React.Component{ +class IconButton extends React.Component { constructor(props) { super(props); - + this.state = { currentIconName: this.props.iconName, currentIconColor: this.props.color @@ -24,9 +25,9 @@ class IconButton extends React.Component{ this.isNeedUpdate = false; } - - onMouseEnter(e){ - if(!this.props.isDisabled){ + + onMouseEnter(e) { + if (!this.props.isDisabled) { this.setState({ currentIconName: this.props.iconHoverName ? this.props.iconHoverName : this.props.iconName, currentIconColor: this.props.hoverColor ? this.props.hoverColor : this.props.color @@ -34,8 +35,8 @@ class IconButton extends React.Component{ this.props.onMouseEnter && this.props.onMouseEnter(e); } } - onMouseLeave(e){ - if(!this.props.isDisabled){ + onMouseLeave(e) { + if (!this.props.isDisabled) { this.setState({ currentIconName: this.props.iconName, currentIconColor: this.props.color @@ -43,22 +44,22 @@ class IconButton extends React.Component{ this.props.onMouseDown && this.props.onMouseDown(e); } } - onMouseDown(e){ - if(!this.props.isDisabled){ + onMouseDown(e) { + if (!this.props.isDisabled) { this.setState({ currentIconName: this.props.iconClickName ? this.props.iconClickName : this.props.iconName, - currentIconColor: this.props.clickColor ? this.props.clickColor : this.props.color + currentIconColor: this.props.clickColor ? this.props.clickColor : this.props.color }); this.props.onMouseDown && this.props.onMouseDown(e); } } - onMouseUp(e){ - if(!this.props.isDisabled){ + onMouseUp(e) { + if (!this.props.isDisabled) { switch (e.nativeEvent.which) { case 1: //Left click this.setState({ currentIconName: this.props.iconHoverName ? this.props.iconHoverName : this.props.iconName, - currentIconColor: this.props.iconHoverName ? this.props.iconHoverName : this.props.color + currentIconColor: this.props.iconHoverName ? this.props.iconHoverName : this.props.color }); this.props.onClick && this.props.onClick(e); this.props.onMouseUp && this.props.onMouseUp(e); @@ -66,43 +67,32 @@ class IconButton extends React.Component{ case 3://Right click this.props.onMouseUp && this.props.onMouseUp(e); break; - + default: break; - } + } } } - shouldComponentUpdate(nextProps, nextState){ - if(!this.isNeedUpdate){ - for (let propsKey in this.props) { - if(typeof this.props[propsKey] != "function" && typeof this.props[propsKey] != "object" && this.props[propsKey] != nextProps[propsKey]){ - this.isNeedUpdate = true; - if(propsKey == "iconName"){ - this.setState({ - currentIconName: nextProps[propsKey] - }); - break; - } - } + shouldComponentUpdate(nextProps, nextState) { + + if (!isEqual(this.props, nextProps)) { + let newState = { + currentIconName: this.state.currentIconName, + currentIconColor: this.state.currentIconColor } - for (let stateKey in this.state) { - if(typeof this.state[stateKey] != "function" && typeof this.state[stateKey] != "object" && this.state[stateKey] != nextState[stateKey]){ - this.isNeedUpdate = true; - break; - } - } - if(!this.isNeedUpdate) return false; - else return true; + if (this.props.iconName !== nextProps.iconName) newState.currentIconName = nextProps.iconName; + if (this.props.color !== nextProps.color) newState.currentIconColor = nextProps.color; + this.setState(newState); + return true; } - this.isNeedUpdate = false; - return true; + return !isEqual(this.state, nextState); } - render(){ + render() { //console.log("IconButton render"); return ( - - {React.createElement(Icons[this.state.currentIconName], {size: "scale", color: this.state.currentIconColor, isfill: this.props.isFill})} + {React.createElement(Icons[this.state.currentIconName], { size: "scale", color: this.state.currentIconColor, isfill: this.props.isFill })} ); } @@ -127,7 +117,7 @@ IconButton.propTypes = { iconName: PropTypes.string.isRequired, iconHoverName: PropTypes.string, iconClickName: PropTypes.string, - onClick:PropTypes.func + onClick: PropTypes.func }; IconButton.defaultProps = {