@@ -18,11 +18,13 @@ export class FabricComponent implements OnInit {
18
18
fabric : Fabric ;
19
19
fabrics : Fabric [ ] ;
20
20
fabricSorts : any ;
21
+ userRole : number ;
21
22
22
23
constructor ( private backendService : BackendService , private notificationService : NotificationsService ,
23
24
private modalService : BsModalService ) {
24
25
this . loadingMessage = 'Loading fabrics' ;
25
26
this . fabricSorts = this . backendService . prefs . fabric_sort ;
27
+ this . userRole = parseInt ( localStorage . getItem ( 'userRole' ) ) ;
26
28
}
27
29
28
30
ngOnInit ( ) : void {
@@ -99,39 +101,38 @@ export class FabricComponent implements OnInit {
99
101
}
100
102
101
103
public onSubmit ( ) {
102
- if ( this . fabric . apic_password !== undefined && this . fabric . apic_password != '' && this . fabric . apic_password == this . fabric . password_confirm ) {
103
- const validate = this . fabric . validate ;
104
- if ( this . fabric . is_new ) {
105
- this . backendService . createFabric ( this . fabric ) . subscribe ( ( results ) => {
106
- if ( validate ) {
107
- this . verifyFabric ( this . fabric ) ;
108
- } else {
109
- this . getFabrics ( ) ;
110
- }
111
- } , ( err ) => {
112
- if ( err [ 'error' ] !== undefined && err [ 'error' ] [ 'error' ] !== undefined ) {
113
- this . notificationService . error ( err [ 'error' ] [ 'error' ] ) ;
114
- } else {
115
- this . notificationService . error ( 'Error' , 'Could not add fabric' ) ;
116
- }
117
- this . loading = false ;
118
- } ) ;
119
- } else {
120
- this . backendService . updateFabric ( this . fabric ) . subscribe ( ( results ) => {
121
- if ( validate ) {
122
- this . verifyFabric ( this . fabric ) ;
123
- } else {
124
- this . getFabrics ( ) ;
125
- }
126
- } , ( err ) => {
127
- if ( err [ 'error' ] !== undefined && err [ 'error' ] [ 'error' ] !== undefined ) {
128
- this . notificationService . error ( err [ 'error' ] [ 'error' ] ) ;
129
- } else {
130
- this . notificationService . error ( 'Error' , 'Could not update fabric' ) ;
131
- }
132
- this . loading = false ;
133
- } ) ;
134
- }
104
+ this . hideModal ( ) ;
105
+ const validate = this . fabric . validate ;
106
+ if ( this . fabric . is_new ) {
107
+ this . backendService . createFabric ( this . fabric ) . subscribe ( ( results ) => {
108
+ if ( validate ) {
109
+ this . verifyFabric ( this . fabric ) ;
110
+ } else {
111
+ this . getFabrics ( ) ;
112
+ }
113
+ } , ( err ) => {
114
+ if ( err [ 'error' ] !== undefined && err [ 'error' ] [ 'error' ] !== undefined ) {
115
+ this . notificationService . error ( err [ 'error' ] [ 'error' ] ) ;
116
+ } else {
117
+ this . notificationService . error ( 'Error' , 'Could not add fabric' ) ;
118
+ }
119
+ this . loading = false ;
120
+ } ) ;
121
+ } else {
122
+ this . backendService . updateFabric ( this . fabric ) . subscribe ( ( results ) => {
123
+ if ( validate ) {
124
+ this . verifyFabric ( this . fabric ) ;
125
+ } else {
126
+ this . getFabrics ( ) ;
127
+ }
128
+ } , ( err ) => {
129
+ if ( err [ 'error' ] !== undefined && err [ 'error' ] [ 'error' ] !== undefined ) {
130
+ this . notificationService . error ( err [ 'error' ] [ 'error' ] ) ;
131
+ } else {
132
+ this . notificationService . error ( 'Error' , 'Could not update fabric' ) ;
133
+ }
134
+ this . loading = false ;
135
+ } ) ;
135
136
}
136
137
}
137
138
0 commit comments