1var TasksBlock = React.createClass({displayName: "TasksBlock", 2 getInitialState: function() { 3 return { 4 loaded: false, 5 opened: false, 6 data: {} 7 } 8 }, 9 render: function() { 10 if ( ! this.state.loaded ) { 11 return null; 12 } 13 if ( ! this.state.data.totalTasksCount || this.state.data.totalTasksCount == 0 ) { 14 return null; 15 } 16 17 if ( $('.top-notification').length > 0 ) { 18 return null; 19 } 20 21 var tasksBlocks = []; 22 var groupLabels = [] 23 var i = 0; 24 var linkToAllBlock = ""; 25 var stop = false; 26 27 for ( key in this.state.data.groups ) { 28 var groupData = this.state.data.groups[key] 29 if ( groupData.tasksCount <= 0 ) { 30 continue; 31 } 32 groupLabels.push( groupData.tasksCountLabel ) 33 if ( stop ) { 34 break; 35 } 36 37 tasksBlocks.push( 38 React.createElement("div", {className: "tasks-group-label"}, 39 groupData.groupLabel 40 ) 41 ) 42 for( taskKey in groupData.tasks ) { 43 i++; 44 if ( i > 5 ) { 45 linkToAllBlock = ( 46 React.createElement("a", {href: "/pl/tasks/task/my", className: "all-tasks-link-block"}, 47 window.tt('common', 'All active tasks') 48 ) 49 ); 50 stop = true; 51 break; 52 } 53 54 var managerLabel = 'менеджеÑ'; 55 var expiredLabel = 'ÐÑоÑÑоÑена'; 56 var closeLabel = 'ÐавеÑÑиÑÑ'; 57 if (typeof Yii != 'undefined') { 58 managerLabel = Yii.t('common', managerLabel); 59 expiredLabel = Yii.t('common', expiredLabel); 60 closeLabel = Yii.t('common', closeLabel); 61 } 62 var taskData = groupData.tasks[taskKey]; 63 if(taskData.normal_time_expired === null) { 64 taskData.normalTimeStatus = ""; 65 taskData.normalTimeText = ""; 66 taskData.normalTime = ""; 67 }else if (taskData.normal_time_expired < 0) { 68 taskData.normalTime = "normal-time"; 69 taskData.normalTimeStatus = "expired"; 70 taskData.normalTimeText = expiredLabel + " " + taskData.normal_time_expired_at; 71 }else{ 72 taskData.normalTime = "normal-time"; 73 taskData.normalTimeStatus = "not-expired"; 74 taskData.normalTimeText = closeLabel + " " + taskData.normal_time_expired_at; 75 } 76 tasksBlocks.push( 77 React.createElement("a", {className: "task-block " + taskData.normalTime + " " + taskData.normalTimeStatus, "data-url": taskData.url, href: taskData.url}, 78 React.createElement("div", {className: "image"}, React.createElement("img", {src: taskData.image_url})), 79 React.createElement("div", {className: "status-wrapper"}, 80 React.createElement("div", {className: "label label-" + taskData.status_class}, taskData.status_label) 81 ), 82 React.createElement("div", {className: "task-text-data"}, 83 React.createElement("div", {className: "object-name small text-muted"}, taskData.object_name), 84 React.createElement("div", {className: "title"}, taskData.title), 85 React.createElement("div", {className: "manager-name"}, managerLabel + ": ", taskData.manager_user_name), 86 React.createElement("div", {className: "expired-time"}, taskData.normalTimeText) 87 ) 88 ) 89 ) 90 } 91 } 92 93 var tasksCountLabel = []; 94 for ( key in groupLabels ) { 95 var val = groupLabels[key] 96 tasksCountLabel.push( 97 React.createElement("div", null, 98 val 99 ) 100 ) 101 } 102 103 return ( 104 React.createElement("div", {className: "gc-tasks-block " + ( this.state.opened ? "opened" : "closed") }, 105 React.createElement("div", {className: "annotate-block", onClick: this.handleClickAnnotate}, 106 tasksCountLabel 107 ), 108 React.createElement("div", {className: "tasks-block"}, 109 tasksBlocks, 110 linkToAllBlock 111 ) 112 ) 113 ); 114 }, 115 handleTaskClick: function( url ) { 116 location.href = url; 117 }, 118 componentDidMount: function() { 119 this.loadNotifications(); 120 }, 121 handleClickAnnotate: function() { 122 var self = this; 123 if ( ! this.state.opened && ! this.windowClickHandler ) { 124 this.loadTasksData( function() { 125 126 $(window).click( function(e) { 127 if ( self.state.opened && $(e.target).parents('.gc-tasks-block').length == 0 ) { 128 self.setState({opened: false}); 129 } 130 }); 131 this.windowClickHandler = true; 132 self.setState( { opened: ! self.state.opened }); 133 }) 134 135 } 136 else { 137 this.setState( { opened: ! this.state.opened }); 138 } 139 140 }, 141 loadTasksData: function( callback ) { 142 var self = this; 143 if ( ! this.state.data.tasks ) { 144 ajaxCall( "/pl/tasks/task/get-data?full=1", {}, {}, function( response ) { 145 console.log( response ) 146 data = response.data; 147 self.setState( {data: data } ) 148 callback(); 149 } ); 150 151 } else { 152 callback(); 153 } 154 }, 155 loadNotifications: function() { 156 var self = this; 157 ajaxCall( "/pl/tasks/task/get-data", {}, {}, function( response ) { 158 newParams = {} 159 newParams.loaded = true; 160 newParams.data = response.data; 161 self.setState( newParams ) 162 } ); 163 }, 164 refresh: function() { 165 this.loadNotifications(); 166 } 167}); 168 169$( function() { 170 if ( window.disableTasksBlock ) { 171 return false;
172 } 173 if ( $(window).width() < 700 ) { 174 return false; 175 } 176 177 var $blockEl = $("<div></div>") 178 $blockEl.appendTo ( $(document.body) ); 179 if ( window.userInfo.isAdmin || window.userInfo.isManager || window.userInfo.canViewTasksBlock ) { 180 window.tasksBlockComponent = React.render( 181 React.createElement(TasksBlock, {params: window.activeBlockMenu}), $blockEl.get(0) 182 ); 183 } 184});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.