Merge branch 'master' into os-84-frontend-ticket-events
This commit is contained in:
commit
fff2bca646
|
@ -7,6 +7,8 @@ import Button from 'core-components/button';
|
|||
import Tooltip from 'core-components/tooltip';
|
||||
import TicketInfo from 'app-components/ticket-info';
|
||||
|
||||
import DateTransformer from 'lib-core/date-transformer';
|
||||
|
||||
class TicketList extends React.Component {
|
||||
static propTypes = {
|
||||
tickets: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||
|
@ -24,7 +26,7 @@ class TicketList extends React.Component {
|
|||
render() {
|
||||
return (
|
||||
<div className="ticket-list">
|
||||
<Table headers={this.getTableHeaders()} rows={this.getTableRows()} pageSize={10} />
|
||||
<Table headers={this.getTableHeaders()} rows={this.getTableRows()} pageSize={10} comp={this.compareFunction} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -110,11 +112,13 @@ class TicketList extends React.Component {
|
|||
priority: this.getTicketPriority(ticket.priority),
|
||||
department: ticket.department.name,
|
||||
author: ticket.author.name,
|
||||
date: ticket.date,
|
||||
date: DateTransformer.transformToString(ticket.date),
|
||||
unread: ticket.unread,
|
||||
highlighted: ticket.unread
|
||||
};
|
||||
}
|
||||
getTicketPriority(priority){
|
||||
|
||||
getTicketPriority(priority) {
|
||||
if(priority == 'high'){
|
||||
return (
|
||||
<span className="ticket-list__priority-high">{i18n('HIGH')}</span>
|
||||
|
@ -131,6 +135,39 @@ class TicketList extends React.Component {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
compareFunction(row1, row2) {
|
||||
let ans = 0;
|
||||
|
||||
if (row1.closed == row2.closed) {
|
||||
if (row1.unread == row2.unread) {
|
||||
let s1 = row1.date;
|
||||
let s2 = row2.date;
|
||||
|
||||
let y1 = s1.substring(0, 4);
|
||||
let y2 = s2.substring(0, 4);
|
||||
|
||||
if (y1 == y2) {
|
||||
let m1 = s1.substring(4, 6);
|
||||
let m2 = s2.substring(4, 6);
|
||||
|
||||
if (m1 == m2) {
|
||||
let d1 = s1.substring(6, 8);
|
||||
let d2 = s2.substring(6, 8);
|
||||
|
||||
if (d1 == d2) {
|
||||
return 0;
|
||||
}
|
||||
return d1 > d2 ? -1 : 1;
|
||||
}
|
||||
return m1 > m2 ? -1 : 1;
|
||||
}
|
||||
return y1 > y2 ? -1 : 1;
|
||||
}
|
||||
return row1.unread ? -1 : 1;
|
||||
}
|
||||
return row1.closed ? -1 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -145,21 +145,28 @@ let DemoPage = React.createClass({
|
|||
{value:'Title First', key: 'title1'},
|
||||
{value:'Title Second', key: 'title2'}
|
||||
]} rows={[
|
||||
{title1: 'Row1', title2: 'Example'},
|
||||
{title1: 'Row2', title2: 'Example'},
|
||||
{title1: 'Row3', title2: 'Example'},
|
||||
{title1: 'Row4', title2: 'Example'},
|
||||
{title1: 'Row5', title2: 'Example'},
|
||||
{title1: 'Row6', title2: 'Example'},
|
||||
{title1: 'Row7', title2: 'Example'},
|
||||
{title1: 'Row8', title2: 'Example'},
|
||||
{title1: 'Row9', title2: 'Example'},
|
||||
{title1: 'Row10', title2: 'Example'},
|
||||
{title1: 'Row11', title2: 'Example'},
|
||||
{title1: 'Row12', title2: 'Example'},
|
||||
{title1: 'Row13', title2: 'Example'},
|
||||
{title1: 'Row14', title2: 'Example'}
|
||||
]} pageSize={3}/>
|
||||
{title1: 'Row1', title2: 'Example', n: 1},
|
||||
{title1: 'Row2', title2: 'Example', n: 2},
|
||||
{title1: 'Row3', title2: 'Example', n: 3},
|
||||
{title1: 'Row4', title2: 'Example', n: 4},
|
||||
{title1: 'Row5', title2: 'Example', n: 5},
|
||||
{title1: 'Row6', title2: 'Example', n: 6},
|
||||
{title1: 'Row7', title2: 'Example', n: 7},
|
||||
{title1: 'Row8', title2: 'Example', n: 8},
|
||||
{title1: 'Row9', title2: 'Example', n: 9},
|
||||
{title1: 'Row10', title2: 'Example', n: 10},
|
||||
{title1: 'Row11', title2: 'Example', n: 11},
|
||||
{title1: 'Row12', title2: 'Example', n: 12},
|
||||
{title1: 'Row13', title2: 'Example', n: 13},
|
||||
{title1: 'Row14', title2: 'Example', n: 14}
|
||||
]} pageSize={3} comp={function (a, b) {
|
||||
let ans = 0;
|
||||
if(a.title1 < b.title1)
|
||||
ans = -1;
|
||||
else if(a.title1 > b.title1)
|
||||
ans = 1;
|
||||
return ans;
|
||||
}}/>
|
||||
)
|
||||
}
|
||||
],
|
||||
|
|
|
@ -15,7 +15,8 @@ class Table extends React.Component {
|
|||
rows: React.PropTypes.arrayOf(React.PropTypes.object),
|
||||
pageSize: React.PropTypes.number,
|
||||
loading: React.PropTypes.bool,
|
||||
type: React.PropTypes.oneOf(['default'])
|
||||
type: React.PropTypes.oneOf(['default']),
|
||||
comp: React.PropTypes.func
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
@ -36,7 +37,7 @@ class Table extends React.Component {
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{(!this.props.loading) ? this.props.rows.map(this.renderRow.bind(this)) : null}
|
||||
{(!this.props.loading) ? this.getRows().map(this.renderRow.bind(this)) : null}
|
||||
</tbody>
|
||||
</table>
|
||||
{(this.props.loading) ? this.renderLoading() : null}
|
||||
|
@ -111,6 +112,13 @@ class Table extends React.Component {
|
|||
|
||||
return classNames(classes);
|
||||
}
|
||||
|
||||
getRows() {
|
||||
let v = _.clone(this.props.rows);
|
||||
v.sort(this.props.comp);
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Table;
|
|
@ -90,7 +90,6 @@ module.exports = [
|
|||
path: '/user/signup',
|
||||
time: 1000,
|
||||
response: function (data) {
|
||||
|
||||
if (data.email.length > 15) {
|
||||
return {
|
||||
status: 'success',
|
||||
|
@ -143,7 +142,7 @@ module.exports = [
|
|||
id: 2,
|
||||
name: 'Technical Issues'
|
||||
},
|
||||
date: '15 Apr 2016',
|
||||
date: '20160416',
|
||||
file: 'http://www.opensupports.com/some_file.zip',
|
||||
language: 'en',
|
||||
unread: true,
|
||||
|
@ -162,7 +161,7 @@ module.exports = [
|
|||
events: [
|
||||
{
|
||||
type: 'ASSIGN',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -172,7 +171,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
content: 'Do you have apache installed? It generally happens if you dont have apache.',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -183,7 +182,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'UN_ASSIGN',
|
||||
date: 20150410,
|
||||
date: '20150410',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -193,7 +192,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'DEPARTMENT_CHANGED',
|
||||
date: 20150411,
|
||||
date: '20150411',
|
||||
content: 'System support',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -204,7 +203,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150412,
|
||||
date: '20150412',
|
||||
content: 'I have already installed apache, but the problem persists',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
|
@ -214,7 +213,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'PRIORITY_CHANGED',
|
||||
date: 20150413,
|
||||
date: '20150413',
|
||||
content: 'MEDIUM',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -225,8 +224,8 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150511,
|
||||
content: 'Thanks!, I soved it by myself',
|
||||
date: '20150511',
|
||||
content: 'Thanks!, I solved it by myself',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
steve: 'haskell@lambda.com',
|
||||
|
@ -235,7 +234,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'CLOSE',
|
||||
date: 20150513,
|
||||
date: '20150513',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -245,7 +244,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'RE_OPEN',
|
||||
date: 20151018,
|
||||
date: '20151018',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
email: 'haskell@lambda.com',
|
||||
|
@ -262,7 +261,7 @@ module.exports = [
|
|||
id: 1,
|
||||
name: 'Sales Support'
|
||||
},
|
||||
date: '15 Apr 2016',
|
||||
date: '20160415',
|
||||
file: 'http://www.opensupports.com/some_file.zip',
|
||||
language: 'en',
|
||||
unread: false,
|
||||
|
@ -278,7 +277,7 @@ module.exports = [
|
|||
events: [
|
||||
{
|
||||
type: 'ASSIGN',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -288,7 +287,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
content: 'Do you have apache installed? It generally happens if you dont have apache.',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -299,7 +298,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'UN_ASSIGN',
|
||||
date: 20150410,
|
||||
date: '20150410',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -309,7 +308,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'DEPARTMENT_CHANGED',
|
||||
date: 20150411,
|
||||
date: '20150411',
|
||||
content: 'System support',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -320,7 +319,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150412,
|
||||
date: '20150412',
|
||||
content: 'I have already installed apache, but the problem persists',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
|
@ -330,7 +329,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'PRIORITY_CHANGED',
|
||||
date: 20150413,
|
||||
date: '20150413',
|
||||
content: 'MEDIUM',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -341,7 +340,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150511,
|
||||
date: '20150511',
|
||||
content: 'Thanks!, I soved it by myself',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
|
@ -351,7 +350,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'CLOSE',
|
||||
date: 20150513,
|
||||
date: '20150513',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -361,7 +360,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'RE_OPEN',
|
||||
date: 20151018,
|
||||
date: '20151018',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
email: 'haskell@lambda.com',
|
||||
|
@ -378,7 +377,7 @@ module.exports = [
|
|||
id: 1,
|
||||
name: 'Sales Support'
|
||||
},
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
file: 'http://www.opensupports.com/some_file.zip',
|
||||
language: 'en',
|
||||
unread: false,
|
||||
|
@ -394,7 +393,7 @@ module.exports = [
|
|||
events: [
|
||||
{
|
||||
type: 'ASSIGN',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -404,7 +403,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150409,
|
||||
date: '20150409',
|
||||
content: 'Do you have apache installed? It generally happens if you dont have apache.',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -415,7 +414,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'UN_ASSIGN',
|
||||
date: 20150410,
|
||||
date: '20150410',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -425,7 +424,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'DEPARTMENT_CHANGED',
|
||||
date: 20150411,
|
||||
date: '20150411',
|
||||
content: 'System support',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -436,7 +435,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150412,
|
||||
date: '20150412',
|
||||
content: 'I have already installed apache, but the problem persists',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
|
@ -446,7 +445,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'PRIORITY_CHANGED',
|
||||
date: 20150413,
|
||||
date: '20150413',
|
||||
content: 'MEDIUM',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
|
@ -457,7 +456,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'COMMENT',
|
||||
date: 20150511,
|
||||
date: '20150511',
|
||||
content: 'Thanks!, I soved it by myself',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
|
@ -467,7 +466,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'CLOSE',
|
||||
date: 20150513,
|
||||
date: '20150513',
|
||||
author: {
|
||||
name: 'Emilia Clarke',
|
||||
email: 'jobs@steve.com',
|
||||
|
@ -477,7 +476,7 @@ module.exports = [
|
|||
},
|
||||
{
|
||||
type: 'RE_OPEN',
|
||||
date: 20151018,
|
||||
date: '20151018',
|
||||
author: {
|
||||
name: 'Haskell Curry',
|
||||
email: 'haskell@lambda.com',
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
let month = ["", "Jan", "Feb", "Mar", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
||||
|
||||
export default {
|
||||
transformToString (date) {
|
||||
let y = date.substring(0, 4);
|
||||
let m = date.substring(4, 6);
|
||||
let d = date.substring(6, 8);
|
||||
m = (m[0] - '0') * 10 + (m[1] - '0');
|
||||
|
||||
return d + " " + month[m] + " " + y;
|
||||
}
|
||||
};
|
|
@ -3,6 +3,7 @@ require_once 'staff/get.php';
|
|||
require_once 'staff/assign-ticket.php';
|
||||
require_once 'staff/un-assign-ticket.php';
|
||||
require_once 'staff/get-tickets.php';
|
||||
require_once 'staff/get-new-tickets.php';
|
||||
|
||||
$systemControllerGroup = new ControllerGroup();
|
||||
$systemControllerGroup->setGroupPath('/staff');
|
||||
|
@ -11,5 +12,6 @@ $systemControllerGroup->addController(new GetStaffController);
|
|||
$systemControllerGroup->addController(new AssignStaffController);
|
||||
$systemControllerGroup->addController(new UnAssignStaffController);
|
||||
$systemControllerGroup->addController(new GetTicketStaffController);
|
||||
$systemControllerGroup->addController(new GetNewTicketsStaffController);
|
||||
|
||||
$systemControllerGroup->finalize();
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
use Respect\Validation\Validator as DataValidator;
|
||||
|
||||
class GetNewTicketsStaffController extends Controller {
|
||||
const PATH = '/get-new-tickets';
|
||||
|
||||
public function validations() {
|
||||
return[
|
||||
'permission' => 'staff_1',
|
||||
'requestData' => []
|
||||
];
|
||||
}
|
||||
public function handler() {
|
||||
$user = Controller::getLoggedUser();
|
||||
$query = ' (';
|
||||
foreach ($user->sharedDepartmentList as $department) {
|
||||
$query .= 'department_id=' . $department->id . ' OR ';
|
||||
}
|
||||
$query = substr($query,0,-3);
|
||||
$query .= ') AND owner_id IS NULL';
|
||||
|
||||
$ticketList = Ticket::find($query);
|
||||
|
||||
Response::respondSuccess($ticketList->toArray());
|
||||
}
|
||||
}
|
|
@ -30,6 +30,11 @@ abstract class DataStore {
|
|||
|
||||
return $dataStoreList;
|
||||
}
|
||||
public static function find($query) {
|
||||
$beanList = RedBean::find(static::TABLE,$query);
|
||||
|
||||
return DataStoreList::getList(ucfirst(static::TABLE),$beanList);
|
||||
}
|
||||
|
||||
private static function validateProp($propToValidate) {
|
||||
$validProp = false;
|
||||
|
|
|
@ -30,5 +30,6 @@ require './staff/assign-ticket.rb'
|
|||
require './staff/un-assign-ticket.rb'
|
||||
require './staff/get-tickets.rb'
|
||||
require './ticket/change-priority.rb'
|
||||
require './staff/get-new-tickets.rb'
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
describe '/staff/get-new-tickets' do
|
||||
request('/user/logout')
|
||||
Scripts.login($staff[:email], $staff[:password], true)
|
||||
|
||||
it 'should get news tickets' do
|
||||
|
||||
result = request('/staff/get-new-tickets', {
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
(result['status']).should.equal('success')
|
||||
(result['data'].size).should.equal(7)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue