@@ -19,7 +19,7 @@ import { observer } from 'mobx-react'
19
19
import sortBy from 'lodash/sortBy'
20
20
import union from 'lodash/union'
21
21
22
- import { transferToThirdParty } from 'actions/tickets'
22
+ import { transferToThirdParty , fetchTicketTypes } from 'actions/tickets'
23
23
import { fetchGroups , unloadGroups } from 'actions/groups'
24
24
import { showModal } from 'actions/common'
25
25
@@ -101,6 +101,7 @@ class SingleTicketContainer extends React.Component {
101
101
socket . socket . on ( 'updateTicketTags' , this . onUpdateTicketTags )
102
102
103
103
fetchTicket ( this )
104
+ this . props . fetchTicketTypes ( )
104
105
this . props . fetchGroups ( )
105
106
}
106
107
@@ -243,9 +244,9 @@ class SingleTicketContainer extends React.Component {
243
244
} )
244
245
: [ ]
245
246
246
- const mappedTypes = this . props . common . ticketTypes
247
- ? this . props . common . ticketTypes . map ( type => {
248
- return { text : type . name , value : type . _id , raw : type }
247
+ const mappedTypes = this . props . ticketTypes
248
+ ? this . props . ticketTypes . map ( type => {
249
+ return { text : type . get ( ' name' ) , value : type . get ( ' _id' ) , raw : type . toJS ( ) }
249
250
} )
250
251
: [ ]
251
252
@@ -341,14 +342,18 @@ class SingleTicketContainer extends React.Component {
341
342
< select
342
343
value = { this . ticket . type . _id }
343
344
onChange = { e => {
344
- const type = this . props . common . ticketTypes . find ( t => t . _id === e . target . value )
345
- const hasPriority =
346
- type . priorities . findIndex ( p => p . _id === this . ticket . priority . _id ) !== - 1
345
+ const type = this . props . ticketTypes . find ( t => t . get ( '_id' ) === e . target . value )
346
+
347
+ const priority = type
348
+ . get ( 'priorities' )
349
+ . findIndex ( p => p . get ( '_id' ) === this . ticket . priority . _id )
350
+
351
+ const hasPriority = priority !== - 1
347
352
348
353
if ( ! hasPriority ) {
349
354
socket . ui . setTicketPriority (
350
355
this . ticket . _id ,
351
- type . priorities . find ( ( ) => true )
356
+ type . get ( ' priorities' ) . find ( ( ) => true )
352
357
)
353
358
showPriorityConfirm ( )
354
359
}
@@ -438,7 +443,7 @@ class SingleTicketContainer extends React.Component {
438
443
) }
439
444
{ ! hasTicketUpdate && (
440
445
< div className = 'input-box' >
441
- { helpers . formatDate ( this . ticket . dueDate , this . props . common . shortDateFormat ) }
446
+ { helpers . formatDate ( this . ticket . dueDate , this . props . common . get ( ' shortDateFormat' ) ) }
442
447
</ div >
443
448
) }
444
449
</ div >
@@ -489,7 +494,9 @@ class SingleTicketContainer extends React.Component {
489
494
{ this . ticket . history &&
490
495
this . ticket . history . map ( item => (
491
496
< div key = { item . _id } className = 'history-item' >
492
- < time dateTime = { helpers . formatDate ( item . date , this . props . common . longDateFormat ) } />
497
+ < time
498
+ dateTime = { helpers . formatDate ( item . date , this . props . common . get ( 'longDateFormat' ) ) }
499
+ />
493
500
< em >
494
501
Action by: < span > { item . owner . fullname } </ span >
495
502
</ em >
@@ -506,7 +513,7 @@ class SingleTicketContainer extends React.Component {
506
513
{ /* Right Side */ }
507
514
< div className = 'page-message nopadding' style = { { marginLeft : 360 } } >
508
515
< div className = 'page-title-right noshadow' >
509
- { this . props . common . hasThirdParty && (
516
+ { this . props . common . get ( ' hasThirdParty' ) && (
510
517
< div className = 'page-top-comments uk-float-right' >
511
518
< a
512
519
role = 'button'
@@ -576,7 +583,7 @@ class SingleTicketContainer extends React.Component {
576
583
subject = { this . ticket . subject }
577
584
issue = { this . ticket . issue }
578
585
date = { this . ticket . date }
579
- dateFormat = { `${ this . props . common . longDateFormat } , ${ this . props . common . timeFormat } ` }
586
+ dateFormat = { `${ this . props . common . get ( ' longDateFormat' ) } , ${ this . props . common . get ( ' timeFormat' ) } ` }
580
587
attachments = { this . ticket . attachments }
581
588
editorWindow = { this . editorWindow }
582
589
/>
@@ -618,7 +625,9 @@ class SingleTicketContainer extends React.Component {
618
625
ticketSubject = { this . ticket . subject }
619
626
comment = { item }
620
627
isNote = { item . isNote }
621
- dateFormat = { `${ this . props . common . longDateFormat } , ${ this . props . common . timeFormat } ` }
628
+ dateFormat = { `${ this . props . common . get ( 'longDateFormat' ) } , ${ this . props . common . get (
629
+ 'timeFormat'
630
+ ) } `}
622
631
onEditClick = { ( ) => {
623
632
this . editorWindow . openEditorWindow ( {
624
633
showSubject : false ,
@@ -646,7 +655,9 @@ class SingleTicketContainer extends React.Component {
646
655
ticketStatus = { this . ticket . status }
647
656
ticketSubject = { this . ticket . subject }
648
657
comment = { comment }
649
- dateFormat = { `${ this . props . common . longDateFormat } , ${ this . props . common . timeFormat } ` }
658
+ dateFormat = { `${ this . props . common . get ( 'longDateFormat' ) } , ${ this . props . common . get (
659
+ 'timeFormat'
660
+ ) } `}
650
661
onEditClick = { ( ) => {
651
662
this . editorWindow . openEditorWindow ( {
652
663
showSubject : false ,
@@ -673,7 +684,9 @@ class SingleTicketContainer extends React.Component {
673
684
ticketSubject = { this . ticket . subject }
674
685
comment = { note }
675
686
isNote = { true }
676
- dateFormat = { `${ this . props . common . longDateFormat } , ${ this . props . common . timeFormat } ` }
687
+ dateFormat = { `${ this . props . common . get ( 'longDateFormat' ) } , ${ this . props . common . get (
688
+ 'timeFormat'
689
+ ) } `}
677
690
onEditClick = { ( ) => {
678
691
this . editorWindow . openEditorWindow ( {
679
692
showSubject : false ,
@@ -781,6 +794,8 @@ SingleTicketContainer.propTypes = {
781
794
ticketUid : PropTypes . string . isRequired ,
782
795
shared : PropTypes . object . isRequired ,
783
796
common : PropTypes . object . isRequired ,
797
+ ticketTypes : PropTypes . object . isRequired ,
798
+ fetchTicketTypes : PropTypes . func . isRequired ,
784
799
groupsState : PropTypes . object . isRequired ,
785
800
fetchGroups : PropTypes . func . isRequired ,
786
801
unloadGroups : PropTypes . func . isRequired ,
@@ -789,11 +804,16 @@ SingleTicketContainer.propTypes = {
789
804
}
790
805
791
806
const mapStateToProps = state => ( {
792
- common : state . common ,
807
+ common : state . common . viewdata ,
793
808
shared : state . shared ,
809
+ ticketTypes : state . ticketsState . types ,
794
810
groupsState : state . groupsState
795
811
} )
796
812
797
- export default connect ( mapStateToProps , { fetchGroups, unloadGroups, showModal, transferToThirdParty } ) (
798
- SingleTicketContainer
799
- )
813
+ export default connect ( mapStateToProps , {
814
+ fetchTicketTypes,
815
+ fetchGroups,
816
+ unloadGroups,
817
+ showModal,
818
+ transferToThirdParty
819
+ } ) ( SingleTicketContainer )
0 commit comments