import React from 'react'; import {closeActionsMenu} from '../helpers'; import {gettext} from 'core/utils'; import ng from 'core/services/ng'; import {IArticle, IDesk} from 'superdesk-api'; interface IProps { item: IArticle; markedDesksById: any; } /** * @ngdoc React * @module superdesk.apps.search * @name MarkedDesksList * @param {Object} item story to be marked * @param {Object} markedDesksById the dict of deskId and desk object * @description Creates a list of desks that is used for marking a story for a desk */ export class MarkedDesksList extends React.Component { static propTypes: any; static defaultProps: any; timeout: any; $timeout: any; desks: any; constructor(props) { super(props); this.removeMarkedDesk = this.removeMarkedDesk.bind(this); this.stopTimeout = this.stopTimeout.bind(this); this.close = this.close.bind(this); this.closeMenu = this.closeMenu.bind(this); this.$timeout = ng.get('$timeout'); this.desks = ng.get('desks'); } removeMarkedDesk(desk) { const {desks} = this; return function(event) { event.stopPropagation(); desks.markItem(desk._id, this.props.item); this.closeMenu(); }.bind(this); } componentDidMount() { this.timeout = null; } componentWillUnmount() { this.stopTimeout(); } closeMenu() { closeActionsMenu(this.props.item._id); } stopTimeout() { const {$timeout} = this; this.timeout = $timeout.cancel(this.timeout); } close() { const {$timeout} = this; this.timeout = $timeout(this.closeMenu, 2000, false); } render() { const {desks} = this; const markedDesksById = this.props.markedDesksById || {}; return ( ); } }