Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
origin-web-common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Java-于龙
origin-web-common
Commits
dc179692
Commit
dc179692
authored
Sep 28, 2017
by
Sam Padgett
Committed by
GitHub
Sep 28, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #203 from juanvallejo/jvallejo/add-osc-unique-disabled-attr
add ability to "disable" form validity
parents
f73a9fb4
844fb58c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
13 deletions
+42
-13
origin-web-common-ui.js
dist/origin-web-common-ui.js
+11
-3
origin-web-common.js
dist/origin-web-common.js
+11
-3
origin-web-common.min.js
dist/origin-web-common.min.js
+9
-4
oscUnique.js
src/components/osc-unique/oscUnique.js
+11
-3
No files found.
dist/origin-web-common-ui.js
View file @
dc179692
...
@@ -978,11 +978,13 @@ angular.module('openshiftCommonUI')
...
@@ -978,11 +978,13 @@ angular.module('openshiftCommonUI')
return
{
return
{
restrict
:
'A'
,
restrict
:
'A'
,
scope
:
{
scope
:
{
oscUnique
:
'='
oscUnique
:
'='
,
oscUniqueDisabled
:
'='
},
},
require
:
'ngModel'
,
require
:
'ngModel'
,
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
var
list
=
[];
var
list
=
[];
var
isUnique
=
true
;
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
list
=
_
.
isArray
(
newVal
)
?
list
=
_
.
isArray
(
newVal
)
?
...
@@ -990,9 +992,15 @@ angular.module('openshiftCommonUI')
...
@@ -990,9 +992,15 @@ angular.module('openshiftCommonUI')
_
.
keys
(
newVal
);
_
.
keys
(
newVal
);
});
});
var
updateValidity
=
function
()
{
ctrl
.
$setValidity
(
'oscUnique'
,
$scope
.
oscUniqueDisabled
||
isUnique
);
};
$scope
.
$watch
(
'oscUniqueDisabled'
,
updateValidity
);
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
// is valid so long as it doesn't already exist
isUnique
=
!
_
.
includes
(
list
,
value
);
ctrl
.
$setValidity
(
'oscUnique'
,
!
_
.
includes
(
list
,
value
)
);
updateValidity
(
);
return
value
;
return
value
;
});
});
}
}
...
...
dist/origin-web-common.js
View file @
dc179692
...
@@ -1149,11 +1149,13 @@ angular.module('openshiftCommonUI')
...
@@ -1149,11 +1149,13 @@ angular.module('openshiftCommonUI')
return
{
return
{
restrict
:
'A'
,
restrict
:
'A'
,
scope
:
{
scope
:
{
oscUnique
:
'='
oscUnique
:
'='
,
oscUniqueDisabled
:
'='
},
},
require
:
'ngModel'
,
require
:
'ngModel'
,
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
var
list
=
[];
var
list
=
[];
var
isUnique
=
true
;
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
list
=
_
.
isArray
(
newVal
)
?
list
=
_
.
isArray
(
newVal
)
?
...
@@ -1161,9 +1163,15 @@ angular.module('openshiftCommonUI')
...
@@ -1161,9 +1163,15 @@ angular.module('openshiftCommonUI')
_
.
keys
(
newVal
);
_
.
keys
(
newVal
);
});
});
var
updateValidity
=
function
()
{
ctrl
.
$setValidity
(
'oscUnique'
,
$scope
.
oscUniqueDisabled
||
isUnique
);
};
$scope
.
$watch
(
'oscUniqueDisabled'
,
updateValidity
);
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
// is valid so long as it doesn't already exist
isUnique
=
!
_
.
includes
(
list
,
value
);
ctrl
.
$setValidity
(
'oscUnique'
,
!
_
.
includes
(
list
,
value
)
);
updateValidity
(
);
return
value
;
return
value
;
});
});
}
}
...
...
dist/origin-web-common.min.js
View file @
dc179692
...
@@ -345,15 +345,20 @@ ctrl.shown && onHide();
...
@@ -345,15 +345,20 @@ ctrl.shown && onHide();
return
{
return
{
restrict
:
"A"
,
restrict
:
"A"
,
scope
:{
scope
:{
oscUnique
:
"="
oscUnique
:
"="
,
oscUniqueDisabled
:
"="
},
},
require
:
"ngModel"
,
require
:
"ngModel"
,
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
var
list
=
[];
var
list
=
[]
,
isUnique
=
!
0
;
$scope
.
$watchCollection
(
"oscUnique"
,
function
(
newVal
)
{
$scope
.
$watchCollection
(
"oscUnique"
,
function
(
newVal
)
{
list
=
_
.
isArray
(
newVal
)
?
newVal
:
_
.
keys
(
newVal
);
list
=
_
.
isArray
(
newVal
)
?
newVal
:
_
.
keys
(
newVal
);
}),
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
});
return
ctrl
.
$setValidity
(
"oscUnique"
,
!
_
.
includes
(
list
,
value
)),
value
;
var
updateValidity
=
function
()
{
ctrl
.
$setValidity
(
"oscUnique"
,
$scope
.
oscUniqueDisabled
||
isUnique
);
};
$scope
.
$watch
(
"oscUniqueDisabled"
,
updateValidity
),
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
return
isUnique
=
!
_
.
includes
(
list
,
value
),
updateValidity
(),
value
;
});
});
}
}
};
};
...
...
src/components/osc-unique/oscUnique.js
View file @
dc179692
...
@@ -31,11 +31,13 @@ angular.module('openshiftCommonUI')
...
@@ -31,11 +31,13 @@ angular.module('openshiftCommonUI')
return
{
return
{
restrict
:
'A'
,
restrict
:
'A'
,
scope
:
{
scope
:
{
oscUnique
:
'='
oscUnique
:
'='
,
oscUniqueDisabled
:
'='
},
},
require
:
'ngModel'
,
require
:
'ngModel'
,
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
link
:
function
(
$scope
,
$elem
,
$attrs
,
ctrl
)
{
var
list
=
[];
var
list
=
[];
var
isUnique
=
true
;
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
$scope
.
$watchCollection
(
'oscUnique'
,
function
(
newVal
)
{
list
=
_
.
isArray
(
newVal
)
?
list
=
_
.
isArray
(
newVal
)
?
...
@@ -43,9 +45,15 @@ angular.module('openshiftCommonUI')
...
@@ -43,9 +45,15 @@ angular.module('openshiftCommonUI')
_
.
keys
(
newVal
);
_
.
keys
(
newVal
);
});
});
var
updateValidity
=
function
()
{
ctrl
.
$setValidity
(
'oscUnique'
,
$scope
.
oscUniqueDisabled
||
isUnique
);
};
$scope
.
$watch
(
'oscUniqueDisabled'
,
updateValidity
);
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
ctrl
.
$parsers
.
unshift
(
function
(
value
)
{
// is valid so long as it doesn't already exist
isUnique
=
!
_
.
includes
(
list
,
value
);
ctrl
.
$setValidity
(
'oscUnique'
,
!
_
.
includes
(
list
,
value
)
);
updateValidity
(
);
return
value
;
return
value
;
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment