diff --git a/frontend/app/components/error-messages.js b/frontend/app/components/error-messages.js new file mode 100644 index 00000000..f8f18d48 --- /dev/null +++ b/frontend/app/components/error-messages.js @@ -0,0 +1,20 @@ +const ErrorMessagesComponent = { + template: ` +
+ This field is required. + This field is too short. + This needs to be a valid email. +
+ `, + replace: true, + bindings: { + input: '<', + form: '<', + }, + controller() { + }, +}; + +export default function (ngModule) { + ngModule.component('errorMessages', ErrorMessagesComponent); +} diff --git a/frontend/app/components/index.js b/frontend/app/components/index.js index 23ec34b9..acbe13b4 100644 --- a/frontend/app/components/index.js +++ b/frontend/app/components/index.js @@ -10,3 +10,4 @@ export { default as permissionsEditor } from './permissions-editor'; export { default as dynamicTable } from './dynamic-table'; export { default as paginator } from './paginator'; export { default as settingsScreen } from './settings-screen'; +export { default as errorMessages } from './error-messages'; diff --git a/frontend/app/filters/index.js b/frontend/app/filters/index.js index 63c2465d..30b7e973 100644 --- a/frontend/app/filters/index.js +++ b/frontend/app/filters/index.js @@ -110,3 +110,7 @@ export function remove(items, item) { export function notEmpty(collection) { return !isEmpty(collection); } + +export function showError(field, form) { + return (field.$touched && field.$invalid) || form.$submitted; +} diff --git a/frontend/app/pages/users/new.html b/frontend/app/pages/users/new.html index 3ecd2412..83a236f0 100644 --- a/frontend/app/pages/users/new.html +++ b/frontend/app/pages/users/new.html @@ -1,34 +1,25 @@ - {{$ctrl.test}}
- {{$ctrl.test}} -
+
-
- This field is required. - This field is too short. - This needs to be a valid email. -
+
-
+
-
- This field is required. - This field is too short. - This needs to be a valid email. -
+
+

The user has been created and should receive an invite email soon. diff --git a/rd_ui/app/scripts/directives/directives.js b/rd_ui/app/scripts/directives/directives.js index c64680c3..4b54131c 100644 --- a/rd_ui/app/scripts/directives/directives.js +++ b/rd_ui/app/scripts/directives/directives.js @@ -257,17 +257,6 @@ }; }); - directives.directive('inputErrors', function () { - return { - restrict: "E", - templateUrl: "/views/directives/input_errors.html", - replace: true, - scope: { - errors: "=" - } - }; - }); - directives.directive('onDestroy', function () { /* This directive can be used to invoke a callback when an element is destroyed, A useful example is the following: diff --git a/rd_ui/app/views/directives/input_errors.html b/rd_ui/app/views/directives/input_errors.html deleted file mode 100644 index 2bb72ac6..00000000 --- a/rd_ui/app/views/directives/input_errors.html +++ /dev/null @@ -1,5 +0,0 @@ -

- This field is required. - This field is too short. - This needs to be a valid email. -