Skip to content

Commit 181e9a5

Browse files
committed
init
1 parent dd38dbf commit 181e9a5

12 files changed

+2046
-0
lines changed

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory": "app/vendors"
3+
}

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.tmp
3+
.idea
4+
app/vendors/*

Gruntfile.js

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
5+
// Load grunt tasks automatically
6+
require('load-grunt-tasks')(grunt);
7+
8+
// Time how long tasks take. Can help when optimizing build times
9+
require('time-grunt')(grunt);
10+
11+
// Configurable paths for the application
12+
var appConfig = {
13+
app: require('./bower.json').appPath || 'app',
14+
src: 'src',
15+
dist: 'dist'
16+
};
17+
18+
// Define the configuration for all the tasks
19+
grunt.initConfig({
20+
21+
// Project settings
22+
yeoman: appConfig,
23+
24+
// Watches files for changes and runs tasks based on the changed files
25+
watch: {
26+
bower: {
27+
files: ['bower.json'],
28+
tasks: ['wiredep']
29+
},
30+
js: {
31+
files: ['<%= yeoman.src %>/*.js'],
32+
tasks: ['concat:src']
33+
},
34+
dist: {
35+
files: ['<%= yeoman.app %>/js/formus.js'],
36+
tasks: ['concat:dist']
37+
}
38+
},
39+
40+
// Make sure code styles are up to par and there are no obvious mistakes
41+
jshint: {
42+
options: {
43+
jshintrc: '.jshintrc',
44+
reporter: require('jshint-stylish')
45+
},
46+
src: {
47+
src: [
48+
'Gruntfile.js',
49+
'<%= yeoman.src %>/*.js'
50+
]
51+
}
52+
},
53+
54+
// Empties folders to start fresh
55+
clean: {
56+
dist: {
57+
files: [
58+
{
59+
dot: true,
60+
src: [
61+
'.tmp',
62+
'<%= yeoman.dist %>/{,*/}*',
63+
'!<%= yeoman.dist %>/.git*'
64+
]
65+
}
66+
]
67+
},
68+
server: '.tmp'
69+
},
70+
71+
// Automatically inject Bower components into the app
72+
wiredep: {
73+
app: {
74+
src: ['<%= yeoman.app %>/index.html'],
75+
dependencies: true,
76+
devDependencies: true
77+
}
78+
},
79+
concat: {
80+
options: {
81+
separator: ';'
82+
},
83+
src: {
84+
src: '<%= yeoman.src %>/*.js',
85+
dest: '<%= yeoman.app %>/js/formus.js'
86+
},
87+
dist: {
88+
src: '<%= yeoman.src %>/*.js',
89+
dest: '<%= yeoman.dist %>/formus.js'
90+
}
91+
},
92+
93+
94+
// Copies remaining files to places other tasks can use
95+
copy: {
96+
dist: {
97+
files: [
98+
]
99+
},
100+
styles: {
101+
expand: true,
102+
cwd: '<%= yeoman.app %>/styles',
103+
dest: '.tmp/styles/',
104+
src: '{,*/}*.css'
105+
}
106+
},
107+
ngtemplates: {
108+
app: {
109+
cwd: '<%= yeoman.app %>',
110+
src: ['views/**/*.html','views/*.html'],
111+
dest: '<%= yeoman.app %>/scripts/templates.js',
112+
options: {
113+
htmlmin: { collapseWhitespace: true, collapseBooleanAttributes: true }
114+
}
115+
}
116+
}
117+
});
118+
119+
grunt.registerTask('default', [
120+
'watch'
121+
]);
122+
};

app/bower.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"devDependencies": {},
3+
"name": "AnguarFormus",
4+
"version": "0.0.1",
5+
"dependencies": {
6+
"angular": "1.2.15",
7+
"bootstrap": "~3.0.3",
8+
"lodash": "2.4.1"
9+
}
10+
}

app/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title></title>
5+
<!-- bower:css -->
6+
<link rel="stylesheet" href="vendors/bootstrap/dist/css/bootstrap.css" />
7+
<!-- endbower -->
8+
</head>
9+
<body ng-app="app">
10+
<div ng-controller="MainCtrl">
11+
<pre>{{form | json}}</pre>
12+
</div>
13+
</body>
14+
<!-- bower:js -->
15+
<script src="vendors/jquery/dist/jquery.js"></script>
16+
<script src="vendors/angular/angular.js"></script>
17+
<script src="vendors/bootstrap/dist/js/bootstrap.js"></script>
18+
<script src="vendors/lodash/dist/lodash.compat.js"></script>
19+
<!-- endbower -->
20+
<script src="js/forms.js"></script>
21+
<script src="js/formus.js"></script>
22+
<script src="js/app.js"></script>
23+
</html>

app/js/app.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
var app = angular.module('app', [
2+
'formus',
3+
]);
4+
app.constant('FORMS_CONFIG', formsConfiguration);
5+
/** Set source of forms configuration */
6+
app.config(['FormusContainerProvider', 'FORMS_CONFIG', function (FormusContainerProvider, FORMS_CONFIG) {
7+
FormusContainerProvider.setContainer(FORMS_CONFIG);
8+
}]);
9+
10+
app.controller('MainCtrl',function ($scope, FormusContainer) {
11+
$scope.form = FormusContainer.get('firstForm');
12+
})

app/js/forms.js

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
2+
var formsConfiguration = {
3+
firstForm: {
4+
title: "Info",
5+
fieldset: {
6+
fields: [
7+
{
8+
name: "id",
9+
type: "text",
10+
label: " ID",
11+
input: "textbox",
12+
readonly: true,
13+
validators: {
14+
required: true
15+
}
16+
},
17+
{
18+
name: "name",
19+
type: "string",
20+
label: "Name",
21+
input: "textbox",
22+
validators: {
23+
required: true
24+
}
25+
},
26+
{
27+
name: "website",
28+
type: "string",
29+
label: "Website",
30+
input: "textbox",
31+
validators: {
32+
required: true,
33+
url: true
34+
}
35+
},
36+
{
37+
name: "address",
38+
type: "string",
39+
label: "Address",
40+
input: "textarea",
41+
validators: {
42+
required: true
43+
}
44+
},
45+
{
46+
name: "phone",
47+
type: "string",
48+
label: "Phone",
49+
input: "textbox",
50+
validators: {
51+
required: true,
52+
phone: true
53+
}
54+
},
55+
{
56+
name: "fax",
57+
type: "string",
58+
label: "Fax",
59+
input: "textbox",
60+
validators: {
61+
required: true,
62+
phone: true
63+
}
64+
},
65+
{
66+
name: "currency",
67+
type: "int",
68+
label: "Currency",
69+
input: "select",
70+
items: [
71+
{
72+
value: 1,
73+
title: "AUD"
74+
}
75+
],
76+
validators: {
77+
required: true
78+
}
79+
},
80+
{
81+
name: "timezone",
82+
type: "int",
83+
label: "Timezone",
84+
input: "select",
85+
validators: {
86+
required: true
87+
},
88+
items: [
89+
{
90+
value: 1,
91+
title: "ACT"
92+
},
93+
{
94+
value: 2,
95+
title: "North"
96+
},
97+
{
98+
value: 3,
99+
title: "NSW"
100+
},
101+
{
102+
value: 4,
103+
title: "Queensland"
104+
},
105+
{
106+
value: 5,
107+
title: "South"
108+
},
109+
{
110+
value: 6,
111+
title: "Victoria"
112+
},
113+
{
114+
value: 7,
115+
title: "West"
116+
}
117+
]
118+
}
119+
]
120+
}
121+
},
122+
}

0 commit comments

Comments
 (0)