Merge branch 'master' into dashboard-view-ticket
# Conflicts: # client/src/data/languages/en.js # client/src/scss/_vars.scss
This commit is contained in:
commit
b3d3cfef83
|
@ -1,15 +1,21 @@
|
|||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
|
||||
import Widget from 'core-components/widget';
|
||||
import Card from 'core-components/card';
|
||||
import i18n from 'lib-app/i18n';
|
||||
|
||||
class MainHomePagePortal extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<Widget className={classNames('main-home-page-portal', this.props.className)}>
|
||||
support portal
|
||||
<Card title={i18n('TICKETS')} description={i18n('TICKETS_DESCRIPTION')} icon="ticket" color="red"/>
|
||||
<Card title={i18n('ARTICLES')} description={i18n('ARTICLES_DESCRIPTION')} icon="book" color="blue"/>
|
||||
<Card title={i18n('ACCOUNT')} description={i18n('ACCOUNT_DESCRIPTION')} icon="user" color="green"/>
|
||||
</Widget>
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import React from 'react';
|
||||
import Icon from 'core-components/icon';
|
||||
import classNames from 'classnames';
|
||||
|
||||
class Card extends React.Component{
|
||||
static propTypes = {
|
||||
description: React.PropTypes.string,
|
||||
title: React.PropTypes.string,
|
||||
icon: React.PropTypes.string,
|
||||
color: React.PropTypes.string
|
||||
};
|
||||
|
||||
render(){
|
||||
return(
|
||||
<div className={this.getClass()}>
|
||||
<div className="card__icon"><Icon name={this.props.icon} size="5x"/></div>
|
||||
<div className="card__title">{this.props.title}</div>
|
||||
<div className="card__description">{this.props.description}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
getClass(){
|
||||
var classes = {
|
||||
'card': true,
|
||||
'card_red': (this.props.color === 'red'),
|
||||
'card_blue': (this.props.color === 'blue'),
|
||||
'card_green': (this.props.color === 'green')
|
||||
};
|
||||
return classNames(classes);
|
||||
}
|
||||
}
|
||||
export default Card;
|
|
@ -0,0 +1,26 @@
|
|||
@import "../scss/vars";
|
||||
|
||||
.card{
|
||||
padding: 15px;
|
||||
width: 200px;
|
||||
height: 260px;
|
||||
color: white;
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
border-radius: 4px;
|
||||
&__title{
|
||||
font-variant: small-caps;
|
||||
font-size: 20px;
|
||||
}
|
||||
&__description{
|
||||
}
|
||||
&_red{
|
||||
background-color: $primary-red;
|
||||
}
|
||||
&_blue{
|
||||
background-color: $secondary-blue;
|
||||
}
|
||||
&_green{
|
||||
background-color: $primary-green;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,8 @@
|
|||
export default {
|
||||
'WELCOME': 'Welcome',
|
||||
'TICKETS': 'Tickets',
|
||||
'ARTICLES': 'Articles',
|
||||
'ACCOUNT': 'Account',
|
||||
'SUBMIT': 'Submit',
|
||||
'LOG_IN': 'Log in',
|
||||
'SIGN_UP': 'Sign up',
|
||||
|
@ -16,6 +19,9 @@ export default {
|
|||
'CREATE_TICKET_DESCRIPTION': 'This is a form for creating tickets. Fill the form and send us your issues/doubts/suggestions. Our support system will answer it as soon as possible.',
|
||||
'TICKET_LIST': 'Ticket List',
|
||||
'TICKET_LIST_DESCRIPTION': 'Here you can find a list of all tickets you have sent to our support team.',
|
||||
'TICKETS_DESCRIPTION': 'A random text about tickets',
|
||||
'ARTICLES_DESCRIPTION': 'A random text about articles',
|
||||
'ACCOUNT_DESCRIPTION': 'A random text about account',
|
||||
'DEPARTMENT': 'Department',
|
||||
'AUTHOR': 'Author',
|
||||
'DATE': 'Date',
|
||||
|
|
|
@ -5,6 +5,8 @@ $secondary-red: #FB6362;
|
|||
$primary-blue: #414A59;
|
||||
$secondary-blue: #20B8c5;
|
||||
|
||||
$primary-green: #82CA9C;
|
||||
|
||||
$very-light-grey: #F7F7F7;
|
||||
$light-grey: #EEEEEE;
|
||||
$grey: #E7E7E7;
|
||||
|
|
|
@ -50,7 +50,6 @@ class CreateController extends Controller {
|
|||
|
||||
$ticket = new Ticket();
|
||||
$ticket->setProperties(array(
|
||||
'ticketId' => '',
|
||||
'title' => $this->title,
|
||||
'content' => $this->content,
|
||||
'language' => $this->language,
|
||||
|
|
|
@ -10,4 +10,7 @@ class Hashing {
|
|||
public static function generateRandomToken() {
|
||||
return md5(uniqid(rand()));
|
||||
}
|
||||
public static function getRandomTicketNumber($min,$max) {
|
||||
return rand($min,$max);
|
||||
}
|
||||
}
|
|
@ -16,6 +16,9 @@ abstract class DataStore {
|
|||
|
||||
return ($bean) ? new static($bean) : new NullDataStore();
|
||||
}
|
||||
public static function count() {
|
||||
return RedBean::count(static::TABLE);
|
||||
}
|
||||
|
||||
private static function validateProp($propToValidate) {
|
||||
$validProp = false;
|
||||
|
|
|
@ -26,18 +26,35 @@ class Ticket extends DataStore {
|
|||
public static function getTicket($value, $property = 'id') {
|
||||
return parent::getDataStore($value, $property);
|
||||
}
|
||||
|
||||
|
||||
public function getDefaultProps() {
|
||||
return array(
|
||||
'owner' => null
|
||||
'owner' => null,
|
||||
'ticketNumber' => $this->generateUniqueTicketNumber()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function store() {
|
||||
parent::store();
|
||||
|
||||
|
||||
if ($this->author instanceof User) {
|
||||
$this->author->store();
|
||||
}
|
||||
}
|
||||
}
|
||||
public function generateUniqueTicketNumber() {
|
||||
$ticketQuantity = Ticket::count('ticket');
|
||||
$minValue = 100000;
|
||||
$maxValue = 999999;
|
||||
|
||||
if ($ticketQuantity === 0) {
|
||||
$ticketNumber = Hashing::getRandomTicketNumber($minValue, $maxValue);
|
||||
} else {
|
||||
$firstTicketNumber = Ticket::getTicket(1)->ticketNumber;
|
||||
$gap = 176611;
|
||||
|
||||
$ticketNumber = ($firstTicketNumber - $minValue + $ticketQuantity * $gap) % ($maxValue - $minValue + 1) + $minValue;
|
||||
}
|
||||
|
||||
return $ticketNumber;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,42 @@ describe '/ticket/create' do
|
|||
(ticket['closed']).should.equal('0')
|
||||
(ticket['department_id']).should.equal('1')
|
||||
(ticket['author_id']).should.equal($csrf_userid)
|
||||
(ticket['ticket_number'].size).should.equal(6)
|
||||
|
||||
ticket_user_relation = $database.getRow('ticket_user','1','ticket_id')
|
||||
(ticket_user_relation['user_id']).should.equal($csrf_userid)
|
||||
end
|
||||
|
||||
it 'should set correct ticket number' do
|
||||
result = request('/ticket/create',{
|
||||
title: 'Winter is coming1',
|
||||
content: 'The north remembers',
|
||||
departmentId: 1,
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
result = request('/ticket/create',{
|
||||
title: 'Winter is coming2',
|
||||
content: 'The north remembers',
|
||||
departmentId: 1,
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
result = request('/ticket/create',{
|
||||
title: 'Winter is coming3',
|
||||
content: 'The north remembers',
|
||||
departmentId: 1,
|
||||
csrf_userid: $csrf_userid,
|
||||
csrf_token: $csrf_token
|
||||
})
|
||||
|
||||
ticket0 = $database.getRow('ticket','Winter is coming','title')['ticket_number'].to_i
|
||||
ticket1 = $database.getRow('ticket','Winter is coming1','title')['ticket_number'].to_i
|
||||
ticket2 = $database.getRow('ticket','Winter is coming2','title')['ticket_number'].to_i
|
||||
ticket3 = $database.getRow('ticket','Winter is coming3','title')['ticket_number'].to_i
|
||||
|
||||
(ticket1).should.equal((ticket0 - 100000 + 1 * 176611) % 900000 + 100000)
|
||||
(ticket2).should.equal((ticket0 - 100000 + 2 * 176611) % 900000 + 100000)
|
||||
(ticket3).should.equal((ticket0 - 100000 + 3 * 176611) % 900000 + 100000)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue