TagSpaces is an offline, open source, document manager with tagging support
merging develop
Ilian Sapundshieva5699e6434a4
diff --cc app/components/TagContainer.jsindex 26bd133bd,7d73fe4b8..b13b56b76--- a/app/components/TagContainer.js+++ b/app/components/TagContainer.js@@@ -42,163 -39,134 +42,152 @@@ type Props =isDragging: boolean,tagMode: 'default' | 'display' | 'remove',entryPath: string,- deleteIcon: Object+ deleteIcon: Object,+ addTags: (paths: Array<string>, tags: Array<Tag>) => void,- removeTags: (paths: Array<string>, tags: Array<Tag>) => void,++ // removeTags: (paths: Array<string>, tags: Array<Tag>) => void,+ selectedEntries: Array<Object>};+ const TagContainer = (props: Props) => {+ // shouldComponentUpdate(nextProps) {+ // if (this.props.tag.title !== nextProps.tag.title+ // || typeof this.props.key !== typeof nextProps.key+ // || (this.props.key && nextProps.key && this.props.key !== nextProps.key)+ // || this.props.tag.color !== nextProps.tag.color+ // || this.props.tag.textcolor !== nextProps.tag.textcolor+ // || this.props.allTags.some((currentTag: Tag) => {+ // if (currentTag.title === this.props.tag.title) {+ // return (nextProps.allTags.some((updatedTag: Tag) => {+ // if (updatedTag.title === this.props.tag.title) {+ // return currentTag.color !== updatedTag.color || currentTag.textcolor !== updatedTag.textcolor;+ // }+ // return false;+ // }));+ // }+ // return false;+ // })+ // || (this.props.tagGroup && this.props.tagGroup ? (this.props.tagGroup.uuid !== nextProps.tagGroup.uuid) : false)+ // || this.props.isDragging !== nextProps.isDragging+ // || typeof this.props.entryPath !== typeof nextProps.entryPath+ // || (this.props.entryPath && this.props.entryPath !== nextProps.entryPath)++ // || this.props.selectedEntries !== nextProps.selectedEntries+ // ) {+ // return true;+ // }+ // return false;+ // }- class TagContainer extends React.Component<Props> {- shouldComponentUpdate(nextProps) {- if (this.props.tag.title !== nextProps.tag.title- || typeof this.props.key !== typeof nextProps.key- || (this.props.key && nextProps.key && this.props.key !== nextProps.key)- || this.props.tag.color !== nextProps.tag.color- || this.props.tag.textcolor !== nextProps.tag.textcolor- || this.props.allTags.some((currentTag: Tag) => {- if (currentTag.title === this.props.tag.title) {- return (nextProps.allTags.some((updatedTag: Tag) => {- if (updatedTag.title === this.props.tag.title) {- return currentTag.color !== updatedTag.color || currentTag.textcolor !== updatedTag.textcolor;- }- return false;- }));- }- return false;- })- || (this.props.tagGroup && this.props.tagGroup ? (this.props.tagGroup.uuid !== nextProps.tagGroup.uuid) : false)- || this.props.isDragging !== nextProps.isDragging- || typeof this.props.entryPath !== typeof nextProps.entryPath- || (this.props.entryPath && this.props.entryPath !== nextProps.entryPath)- || this.props.selectedEntries !== nextProps.selectedEntries- ) {- return true;- }- return false;- }+ const {+ key,+ tag,+ deleteIcon,+ isDragging,+ defaultTextColor,+ defaultBackgroundColor,+ tagGroup,+ entryPath,+ allTags,+ handleRemoveTag,+ handleTagMenu,++ selectedEntries,++ addTags,+ tagMode+ } = props;- render() {- const {- key,- tag,- deleteIcon,- isDragging,- defaultTextColor,- defaultBackgroundColor,- tagGroup,- entryPath,- allTags,- selectedEntries,- addTags,- removeTags- } = this.props;- const { tagMode } = this.props;- let mode = '';- let mode = '';+ let textColor = tag.textcolor || defaultTextColor;+ let backgroundColor = tag.color || defaultBackgroundColor;- let textColor = tag.textcolor || defaultTextColor;- let backgroundColor = tag.color || defaultBackgroundColor;-- allTags.some((currentTag: Tag) => {- if (currentTag.title === tag.title) {- textColor = currentTag.textcolor;- backgroundColor = currentTag.color;- return true;- }- return false;- });-- if (tagMode === 'remove') {- mode = deleteIcon || (- <RemoveTagIcon- data-tid={'tagRemoveButton_' + tag.title.replace(/ /g, '_')}- style={{- color: tag.textColor- }}- onClick={event => this.props.handleRemoveTag(event, tag)}- />- );- } else if (tagMode === 'display') {- mode = '';- } else {- mode = (- <MoreVertIcon- data-tid={'tagMoreButton_' + tag.title.replace(/ /g, '_')}- style={{- color: tag.textColor- }}- />- );+ allTags.some((currentTag: Tag) => {+ if (currentTag.title === tag.title) {+ textColor = currentTag.textcolor;+ backgroundColor = currentTag.color;+ return true;}+ return false;+ });- return (- <div- role="presentation"- data-tid={'tagContainer_' + tag.title.replace(/ /g, '_')}- key={key || tag.id || uuidv1()}- onClick={event => {- if (event.ctrlKey) {- const selectedEntryPaths = [];- selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- addTags(selectedEntryPaths, [tag]);- // Removing tags doesn't seem to work correctly here, yet. Using sidecar tagging, but the removeTagsFromEntry function in tagging.actions.js- // doesn't recignize it correctly, thinking it's a plain tag and thus tries to rename the files- // } else if (event.shiftKey) {- // const selectedEntryPaths = [];- // selectedEntries.map(entry => selectedEntryPaths.push(entry.path));- // removeTags(selectedEntryPaths, [tag]);- } else if (this.props.handleTagMenu) { this.props.handleTagMenu(event, tag, entryPath || tagGroup); }- if (tagMode === 'remove') {- mode = deleteIcon || (- <RemoveTagIcon- data-tid={'tagRemoveButton_' + tag.title.replace(/ /g, '_')}- style={{- color: tag.textColor-- }}- onContextMenu={event => { if (this.props.handleTagMenu) { this.props.handleTagMenu(event, tag, entryPath || tagGroup); } }}- onDoubleClick={event => { if (this.props.handleTagMenu) { this.props.handleTagMenu(event, tag, entryPath || tagGroup); } }}- onClick={event => handleRemoveTag(event, tag)}- />- );- } else if (tagMode === 'display') {- mode = '';- } else {- mode = (- <MoreVertIcon- data-tid={'tagMoreButton_' + tag.title.replace(/ /g, '_')}- style={{- color: tag.textColor- }}- />- );- }-+ return (+ <div+ role="presentation"+ data-tid={'tagContainer_' + tag.title.replace(/ /g, '_')}+ key={key || tag.id || uuidv1()}- onClick={event => { if (handleTagMenu) { props.handleTagMenu(event, tag, entryPath || tagGroup); } }}- onContextMenu={event => { if (handleTagMenu) { props.handleTagMenu(event, tag, entryPath || tagGroup); } }}- onDoubleClick={event => { if (handleTagMenu) { props.handleTagMenu(event, tag, entryPath || tagGroup); } }}++ onClick={event => {++ if (event.ctrlKey) {++ const selectedEntryPaths = [];++ selectedEntries.map(entry => selectedEntryPaths.push(entry.path));++ addTags(selectedEntryPaths, [tag]);++ // Removing tags doesn't seem to work correctly here, yet. Using sidecar tagging, but the removeTagsFromEntry function in tagging.actions.js++ // doesn't recignize it correctly, thinking it's a plain tag and thus tries to rename the files++ // } else if (event.shiftKey) {++ // const selectedEntryPaths = [];++ // selectedEntries.map(entry => selectedEntryPaths.push(entry.path));++ // removeTags(selectedEntryPaths, [tag]);++ } else if (handleTagMenu) { handleTagMenu(event, tag, entryPath || tagGroup); }++ }}++ onContextMenu={event => { if (handleTagMenu) { handleTagMenu(event, tag, entryPath || tagGroup); } }}++ onDoubleClick={event => { if (handleTagMenu) { handleTagMenu(event, tag, entryPath || tagGroup); } }}+ style={{+ backgroundColor: 'transparent',+ marginLeft: 4,+ marginTop: 0,+ marginBottom: 4,+ display: 'inline-block'+ }}+ >+ <Button+ size="small"style={{- backgroundColor: 'transparent',- marginLeft: 4,- marginTop: 0,- marginBottom: 4,- display: 'inline-block'+ opacity: isDragging ? 0.5 : 1,+ fontSize: 13,+ textTransform: 'none',+ color: textColor,+ backgroundColor,+ minHeight: 25,+ margin: 0,+ paddingTop: 0,+ paddingBottom: 0,+ paddingRight: 3,+ borderRadius: 5}}>- <Button- size="small"- style={{- opacity: isDragging ? 0.5 : 1,- fontSize: 13,- textTransform: 'none',- color: textColor,- backgroundColor,- minHeight: 25,- margin: 0,- paddingTop: 0,- paddingBottom: 0,- paddingRight: 3,- borderRadius: 5- }}- >- <span>- {tag.title}- </span>- {mode}- </Button>- </div>- );- }- }+ <span>+ {tag.title}+ </span>- {mode}++ {(tagMode === 'remove') ? (deleteIcon || (++ <RemoveTagIcon++ data-tid={'tagRemoveButton_' + tag.title.replace(/ /g, '_')}++ style={{++ color: tag.textColor++ }}++ onClick={event => handleRemoveTag(event, tag)}++ />++ )) : (++ <MoreVertIcon++ data-tid={'tagMoreButton_' + tag.title.replace(/ /g, '_')}++ style={{++ color: tag.textColor++ }}++ />++ )}+ </Button>+ </div>+ );+ };function mapStateToProps(state) {return {allTags: getAllTags(state),defaultBackgroundColor: getTagColor(state),- defaultTextColor: getTagTextColor(state)+ defaultTextColor: getTagTextColor(state),- selectedEntries: getSelectedEntries(state)++ // selectedEntries: getSelectedEntries(state)};}+- function mapActionCreatorsToProps(dispatch) {- return bindActionCreators({- addTags: TaggingActions.addTags,- removeTags: TaggingActions.removeTags- }, dispatch);- }++// function mapActionCreatorsToProps(dispatch) {++// return bindActionCreators({++// addTags: TaggingActions.addTags,++// removeTags: TaggingActions.removeTags++// }, dispatch);++// }+- export default connect(mapStateToProps, mapActionCreatorsToProps)(TagContainer);+ export default connect(mapStateToProps)(TagContainer);diff --cc app/components/TagContainerDnd.jsindex 95db87fd6,54202ab12..931a329a1--- a/app/components/TagContainerDnd.js+++ b/app/components/TagContainerDnd.js@@@ -111,11 -104,11 +111,12 @@@ class TagContainerDnd extends React.ComentryPath,handleTagMenu,deleteIcon,- selectedEntries++ selectedEntries,+ isDragging,+ connectDragSource,+ tagMode} = this.props;- const { isDragging, connectDragSource, tagMode } = this.props;- // return connectDragPreview(<span>{return connectDragSource(<span><TagContainer@@@ -127,11 -120,8 +128,9 @@@tagMode={tagMode}entryPath={entryPath}isDragging={isDragging}+ selectedEntries={selectedEntries}/></span>);- // , { dropEffect: 'copy' });- // }</span>, { anchorX: 0, anchorY: 0 });}}diff --cc app/perspectives/grid-perspective/src/index.jsindex 2bebefbbe,85b878809..3ff1ec4b4--- a/app/perspectives/grid-perspective/src/index.js+++ b/app/perspectives/grid-perspective/src/index.js@@@ -213,12 -212,17 +213,8 @@@ class GridPerspective extends React.Com}if (lastSelectedEntryPath !== null) {-- this.setState(- {- selectedEntries: directoryContent.filter(- fsEntry => fsEntry.path === lastSelectedEntryPath- )- },-- () => {-- this.computeFileOperationsEnabled();-- // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling-- }-- );++ this.computeFileOperationsEnabled();++ // this.makeFirstSelectedEntryVisible(); // disable due to wrong scrolling}// Directory changed