@@ -30,60 +30,52 @@ export class AuthorComponent {
30
30
this . author = author ;
31
31
console . info ( 'success author controller' , author ) ;
32
32
} ,
33
- error => console . error ( 'Could not load author.'
34
- )
35
- ) ;
36
- } ) ;
37
- //
38
- // this.relatedbooks = BooksService.all(
39
- // { beforepath: 'authors/' + $stateParams.authorId },
40
- // () => {
41
- // console.info('Books from authors relationship', this.relatedbooks);
42
- // }
43
- // );
44
- }
45
-
46
- /*
47
- Add a new author
48
- */
49
- public newAuthor ( ) {
50
- let author = this . authorsService . new ( ) ;
51
- author . attributes . name = prompt ( 'New author name:' , 'John Doe' ) ;
52
- if ( ! author . attributes . name ) {
53
- return ;
33
+ error => console . error ( 'Could not load author.' , error )
34
+ ) ;
35
+ } ) ;
54
36
}
55
- author . attributes . date_of_birth = '2030-12-10' ;
56
- console . log ( 'author data for save' , author . toObject ( ) ) ;
57
- author . save (
58
- /* { include: ['book'] } */
59
- success => {
60
- console . log ( 'author saved' , author . toObject ( ) ) ;
61
- }
62
- ) ;
63
- }
64
37
65
- /*
66
- Update name for actual author
67
- */
68
- public updateAuthor ( ) {
69
- this . author . attributes . name = prompt ( 'Author name:' , this . author . attributes . name ) ;
70
- console . log ( 'author data for save with book include' , this . author . toObject ( { include : [ 'books' ] } ) ) ;
71
- console . log ( 'author data for save without any include' , this . author . toObject ( ) ) ;
72
- this . author . save (
73
- /* { include: ['book'] } */
74
- success => {
75
- console . log ( 'author saved' , this . author . toObject ( ) ) ;
38
+ /*
39
+ Add a new author
40
+ */
41
+ public newAuthor ( ) {
42
+ let author = this . authorsService . new ( ) ;
43
+ author . attributes . name = prompt ( 'New author name:' , 'John Doe' ) ;
44
+ if ( ! author . attributes . name ) {
45
+ return ;
76
46
}
77
- ) ;
78
- }
47
+ author . attributes . date_of_birth = '2030-12-10' ;
48
+ console . log ( 'author data for save' , author . toObject ( ) ) ;
49
+ author . save (
50
+ /* { include: ['book'] } */
51
+ success => {
52
+ console . log ( 'author saved' , author . toObject ( ) ) ;
53
+ }
54
+ ) ;
55
+ }
79
56
80
- public getPhotos ( author : Resource ) : Array < Resource > {
81
- return ( < ICollection > author . relationships . photos . data ) . $toArray ;
82
- }
57
+ /*
58
+ Update name for actual author
59
+ */
60
+ public updateAuthor ( ) {
61
+ this . author . attributes . name = prompt ( 'Author name:' , this . author . attributes . name ) ;
62
+ console . log ( 'author data for save with book include' , this . author . toObject ( { include : [ 'books' ] } ) ) ;
63
+ console . log ( 'author data for save without any include' , this . author . toObject ( ) ) ;
64
+ this . author . save (
65
+ /* { include: ['book'] } */
66
+ success => {
67
+ console . log ( 'author saved' , this . author . toObject ( ) ) ;
68
+ }
69
+ ) ;
70
+ }
83
71
84
- public removeRelationship ( ) {
85
- this . author . removeRelationship ( 'photos' , '1' ) ;
86
- this . author . save ( ) ;
87
- console . log ( 'removeRelationship save with photos include' , this . author . toObject ( ) ) ;
88
- }
72
+ public getPhotos ( author : Resource ) : Array < Resource > {
73
+ return ( < ICollection > author . relationships . photos . data ) . $toArray ;
74
+ }
75
+
76
+ public removeRelationship ( ) {
77
+ this . author . removeRelationship ( 'photos' , '1' ) ;
78
+ this . author . save ( ) ;
79
+ console . log ( 'removeRelationship save with photos include' , this . author . toObject ( ) ) ;
80
+ }
89
81
}
0 commit comments