-
Notifications
You must be signed in to change notification settings - Fork 24
/
app.js
110 lines (103 loc) · 4.19 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
'use strict';
var myApp = angular.module('formApp', [
'schemaForm',
'pascalprecht.translate',
'ngSchemaFormFile'
])
.controller('formController', ['$scope', '$q', function($scope, $q) {
$scope.schema = {
"type": "object",
"title": "Album",
"properties": {
"image": {
"title": "Image (Label coming from form definition)",
"type": "array",
"format": "singlefile",
"x-schema-form": {
"type": "array"
},
"pattern": {
"mimeType": "image/*",
"validationMessage": "Falscher Dateityp: "
},
"maxSize": {
"maximum": "2MB",
"validationMessage": "Erlaubte Dateigröße überschritten: ",
"validationMessage2": "Aktuelle Dateigröße: "
},
"maxItems": {
"validationMessage": "Es wurden mehr Dateien hochgeladen als erlaubt."
},
"minItems": {
"validationMessage": "Sie müssen mindestens eine Datei hochladen"
}
},
"images": {
"title": "Images (Labels defined using the translate module)",
"type": "array",
"format": "multifile",
"x-schema-form": {
"type": "array"
},
"pattern": {
"mimeType": "image/*,!.gif",
"validationMessage": "Falscher Dateityp: "
},
"maxSize": {
"maximum": "2MB",
"validationMessage": "Erlaubte Dateigröße überschritten: ",
"validationMessage2": "Aktuelle Dateigröße: "
},
"maxItems": {
"validationMessage": "Es wurden mehr Dateien hochgeladen als erlaubt."
},
"minItems": {
"validationMessage": "Sie müssen mindestens eine Datei hochladen"
}
}
},
"required": [
"images"
]
};
$scope.form = [{
"key": "image",
"type": "nwpFileUpload",
"endpoint": "https://angular-file-upload-cors-srv.appspot.com/upload",
"i18n": {
"add": "Open file browser",
"preview": "Preview Upload",
"filename": "File Name",
"progress": "Progress Status",
"upload": "Upload",
"dragorclick": "Drag and drop your file here or click here"
}
}, {
"key": "images",
"type": "nwpFileUpload",
"endpoint": "https://angular-file-upload-cors-srv.appspot.com/upload"
}];
$scope.model = {};
$scope.submit = function() {
$scope.$broadcast('schemaFormValidate');
if ($scope.myForm.$valid) {
console.log('form valid');
}
};
}])
.config(['$translateProvider', function($translateProvider) {
// Simply register translation table as object hash
$translateProvider.translations('en', {
'modules.upload.dndNotSupported': 'Drag n drop not surpported by your browser',
'modules.attribute.fields.required.caption': 'Required',
'modules.upload.descriptionSinglefile': 'Drop your file here',
'modules.upload.descriptionMultifile': 'Drop your file(s) here',
'buttons.add': 'Open file browser',
'modules.upload.field.filename': 'Filename',
'modules.upload.field.preview': 'Preview',
'modules.upload.multiFileUpload': 'Multifile upload',
'modules.upload.field.progress': 'Progress',
'buttons.upload': 'Upload'
});
$translateProvider.preferredLanguage('en');
}]);