1
1
import Component from '@ember/component' ;
2
2
import { computed } from '@ember/object' ;
3
+ import { readOnly , oneWay } from '@ember/object/computed' ;
3
4
import { run } from '@ember/runloop' ;
4
5
import { inject as service } from '@ember/service' ;
5
6
import FormMixin from 'open-event-frontend/mixins/form' ;
@@ -14,18 +15,12 @@ import {
14
15
export default Component . extend ( FormMixin , {
15
16
router : service ( ) ,
16
17
17
- buyer : computed ( 'data.user' , function ( ) {
18
- return this . get ( 'data.user' ) ;
19
- } ) ,
20
-
21
- buyerHasFirstName : computed ( function ( ) {
22
- return this . get ( 'data.user.firstName' ) ;
23
- } ) ,
24
-
25
- buyerHasLastName : computed ( function ( ) {
26
- return this . get ( 'data.user.lastName' ) ;
27
- } ) ,
28
- holders : computed ( 'data.attendees' , function ( ) {
18
+ buyerFirstName : oneWay ( 'buyerHasFirstName' ) ,
19
+ buyerLastName : oneWay ( 'buyerHasLastName' ) ,
20
+ buyer : readOnly ( 'data.user' ) ,
21
+ buyerHasFirstName : readOnly ( 'data.user.firstName' ) ,
22
+ buyerHasLastName : readOnly ( 'data.user.lastName' ) ,
23
+ holders : computed ( 'data.attendees' , function ( ) {
29
24
this . get ( 'data.attendees' ) . forEach ( attendee => {
30
25
attendee . set ( 'firstname' , '' ) ;
31
26
attendee . set ( 'lastname' , '' ) ;
@@ -474,13 +469,16 @@ export default Component.extend(FormMixin, {
474
469
actions : {
475
470
submit ( data ) {
476
471
this . onValid ( ( ) => {
472
+ let currentUser = this . get ( 'data.user' ) ;
473
+ currentUser . set ( 'firstName' , this . buyerFirstName ) ;
474
+ currentUser . set ( 'lastName' , this . buyerLastName ) ;
477
475
this . sendAction ( 'save' , data ) ;
478
476
} ) ;
479
477
} ,
480
478
modifyHolder ( holder ) {
481
479
if ( this . sameAsBuyer ) {
482
- holder . set ( 'firstname' , this . buyer . content . firstName ) ;
483
- holder . set ( 'lastname' , this . buyer . content . lastName ) ;
480
+ holder . set ( 'firstname' , this . buyerFirstName ) ;
481
+ holder . set ( 'lastname' , this . buyerLastName ) ;
484
482
holder . set ( 'email' , this . buyer . content . email ) ;
485
483
} else {
486
484
holder . set ( 'firstname' , '' ) ;
0 commit comments