#2 - Publish
Showing
3 changed files
with
80 additions
and
2 deletions
... | @@ -19,6 +19,21 @@ build: | ... | @@ -19,6 +19,21 @@ build: |
19 | test: | 19 | test: |
20 | stage: test | 20 | stage: test |
21 | script: | 21 | script: |
22 | - ls | ||
23 | - ls node_modules/.bin | ||
24 | - npm run test | 22 | - npm run test |
23 | |||
24 | publish: | ||
25 | stage: publish | ||
26 | only: | ||
27 | - tags | ||
28 | artifacts: | ||
29 | paths: | ||
30 | - dist/ | ||
31 | - package.json | ||
32 | - README.md | ||
33 | - LICENCE | ||
34 | - CHANGELOG.md | ||
35 | environement: | ||
36 | name: npm | ||
37 | url: https://www.npmjs.com/package/angular-matrix-validation | ||
38 | scripts: | ||
39 | - npm publish | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
.npmignore
0 → 100644
README.md
0 → 100644
1 | # Angular Matrix Validation | ||
2 | |||
3 | [![build status](http://gitlab.techniv.fr/WestCoastSwing/RelativePlacement/badges/master/build.svg)](http://gitlab.techniv.fr/WestCoastSwing/RelativePlacement/commits/master) | ||
4 | |||
5 | This module provide an addon directive for form to validate matrix form. | ||
6 | |||
7 | ## Example | ||
8 | |||
9 | ```html | ||
10 | <body ng-app="test" ng-controller="ctrlTest"> | ||
11 | <ng-form name="mForm" matrix-validator data-all="validator"> | ||
12 | <table> | ||
13 | <tr ng-repeat="row in matrix" ng-init="rowId = $index"> | ||
14 | <td ng-repeat="item in row track by $index"> | ||
15 | <input ng-model="row[$index]" type="number" | ||
16 | data-row="rowId" data-col="$index" | ||
17 | name="item{{rowId}}_{{$index}}" | ||
18 | ng-class="{error: mForm['item'+rowId+'_'+$index].$invalid}" | ||
19 | > | ||
20 | </td> | ||
21 | </tr> | ||
22 | </table> | ||
23 | </ng-form> | ||
24 | </body> | ||
25 | ``` | ||
26 | |||
27 | ```javascript | ||
28 | angular.module('test', ['matrixValidation']).controller('ctrlTest', [ | ||
29 | '$scope', | ||
30 | ($scope) => { | ||
31 | $scope.matrix = [ | ||
32 | [0,0,0], | ||
33 | [0,0,0], | ||
34 | [0,0,0] | ||
35 | ]; | ||
36 | |||
37 | $scope.test=2; | ||
38 | |||
39 | /** | ||
40 | * @param {mixed[][]} matrix The matrix with the value of form fields | ||
41 | * @param {null[][]} validationMatrix The validation matrix template. | ||
42 | * @returns {boolean[][]} | ||
43 | */ | ||
44 | $scope.validator = (matrix, validationMatrix) => { | ||
45 | // Do something to fill validationMatrix with true/false | ||
46 | // to validate matrix. | ||
47 | |||
48 | // validationMatrix is give to help you to construct it. | ||
49 | // It have the same dimension than matrix. | ||
50 | // But you to return it. | ||
51 | return validationMatrix; | ||
52 | }; | ||
53 | } | ||
54 | ]); | ||
55 | ``` |
-
Please register or sign in to post a comment