File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -266,4 +266,39 @@ angular.module('GLDirectives', ['GLBrowserCrypto']).
266
266
pgpPubkeyValidator : '@' ,
267
267
}
268
268
} ;
269
+ } ] ) .
270
+ // isolateForm directive makes possible to isolate validation of nested forms
271
+ directive ( 'isolateForm' , [ function ( ) {
272
+ return {
273
+ restrict : 'A' ,
274
+ require : '?form' ,
275
+ link : function ( scope , elm , attrs , ctrl ) {
276
+ if ( ! ctrl ) {
277
+ return ;
278
+ }
279
+
280
+ // Do a copy of the controller
281
+ var ctrlCopy = { } ;
282
+ angular . copy ( ctrl , ctrlCopy ) ;
283
+
284
+ // Get the parent of the form
285
+ var parent = elm . parent ( ) . controller ( 'form' ) ;
286
+ // Remove parent link to the controller
287
+ parent . $removeControl ( ctrl ) ;
288
+
289
+ // Replace form controller with a "isolated form"
290
+ var isolatedFormCtrl = {
291
+ $setValidity : function ( validationToken , isValid , control ) {
292
+ ctrlCopy . $setValidity ( validationToken , isValid , control ) ;
293
+ parent . $setValidity ( validationToken , true , ctrl ) ;
294
+ } ,
295
+ $setDirty : function ( ) {
296
+ elm . removeClass ( 'ng-pristine' ) . addClass ( 'ng-dirty' ) ;
297
+ ctrl . $dirty = true ;
298
+ ctrl . $pristine = false ;
299
+ } ,
300
+ } ;
301
+ angular . extend ( ctrl , isolatedFormCtrl ) ;
302
+ }
303
+ } ;
269
304
} ] ) ;
Original file line number Diff line number Diff line change 113
113
< div class ="text-danger " data-ng-show ="editUser.email.$error.required " data-translate > This field is mandatory</ div >
114
114
< div class ="text-danger " data-ng-show ="editUser.email.$error.pattern " data-translate > Invalid email address</ div >
115
115
</ div >
116
- < div class ="form-group ">
116
+ < div class ="form-group " data-ng-form =" userPasswordForm " data-isolate-form data-ng-class =" {'has-error': passwordStrength.score > 0 && !userPassword.password.$valid} " >
117
117
< label data-translate > Password</ label >
118
118
< input name ="password " class ="form-control " data-ng-model ="user.password " maxlength ="{{node.maximum_namesize}} " type ="password " zxcvbn ="passwordStrength " zx-min-score ="3 " />
119
119
< zx-password-meter value ="passwordStrength "> </ zx-password-meter >
You can’t perform that action at this time.
0 commit comments