diff --git a/public/modules/forms/base/config/forms.client.config.js b/public/modules/forms/base/config/forms.client.config.js index 8bd182e9..6b04a479 100644 --- a/public/modules/forms/base/config/forms.client.config.js +++ b/public/modules/forms/base/config/forms.client.config.js @@ -1,8 +1,8 @@ 'use strict'; // Configuring the Forms drop-down menus -angular.module('forms').filter('formValidity', -function(){ +angular.module('forms') +.filter('formValidity', function(){ return function(formObj){ if(formObj && formObj.form_fields && formObj.visible_form_fields){ diff --git a/public/modules/forms/base/config/i18n/english.js b/public/modules/forms/base/config/i18n/english.js new file mode 100644 index 00000000..d5a9c7c1 --- /dev/null +++ b/public/modules/forms/base/config/i18n/english.js @@ -0,0 +1,32 @@ +'use strict'; + +angular.module('forms').config(['$translateProvider', function ($translateProvider) { + + $translateProvider.translations('english', { + FORM_SUCCESS: 'Form entry successfully submitted!', + BACK_TO_FORM: 'Go back to Form', + EDIT_FORM: 'Edit this TellForm', + CREATE_FORM: 'Create this TellForm', + ADVANCEMENT: '{{done}} out of {{total}} answered', + CONTINUE_FORM: 'Continue to Form', + REQUIRED: 'required', + OPTIONAL: 'optional', + ERROR_EMAIL_INVALID: 'Please enter a valid email address', + ERROR_NOT_A_NUMBER: 'Please enter valid numbers only', + ERROR_URL_INVALID: 'Please a valid url', + OK: 'OK', + ENTER: 'press ENTER', + CONTINUE: 'Continue', + LEGAL_ACCEPT: 'I accept', + LEGAL_NO_ACCEPT: 'I don’t accept', + DELETE: 'Delete', + CANCEL: 'Cancel', + UPLOAD_FILE: 'Upload your File' + + }); + + $translateProvider.preferredLanguage('english') + .fallbackLanguage('english') + .useSanitizeValueStrategy('escape'); + +}]); diff --git a/public/modules/forms/base/config/i18n/french.js b/public/modules/forms/base/config/i18n/french.js new file mode 100644 index 00000000..3a346b8c --- /dev/null +++ b/public/modules/forms/base/config/i18n/french.js @@ -0,0 +1,27 @@ +'use strict'; + +angular.module('forms').config(['$translateProvider', function ($translateProvider) { + + $translateProvider.translations('french', { + FORM_SUCCESS: 'Votre formulaire a été enregistré!', + BACK_TO_FORM: 'Retourner au formulaire', + EDIT_FORM: 'Éditer le Tellform', + CREATE_FORM: 'Créer un TellForm', + ADVANCEMENT: '{{done}} complétés sur {{total}}', + CONTINUE_FORM: 'Aller au formulaire', + REQUIRED: 'obligatoire', + OPTIONAL: 'facultatif', + ERROR_EMAIL_INVALID: 'Merci de rentrer une adresse mail valide', + ERROR_NOT_A_NUMBER: 'Merce de ne rentrer que des nombres', + ERROR_URL_INVALID: 'Merci de rentrer une url valide', + OK: 'OK', + ENTER: 'presser ENTRÉE', + CONTINUE: 'Continuer', + LEGAL_ACCEPT: 'J’accepte', + LEGAL_NO_ACCEPT: 'Jen n’accepte pas', + DELETE: 'Supprimer', + CANCEL: 'Réinitialiser', + UPLOAD_FILE: 'Envoyer des fichier' + }); + +}]); diff --git a/public/modules/forms/base/controllers/submit-form.client.controller.js b/public/modules/forms/base/controllers/submit-form.client.controller.js index c2919531..e15df9e6 100644 --- a/public/modules/forms/base/controllers/submit-form.client.controller.js +++ b/public/modules/forms/base/controllers/submit-form.client.controller.js @@ -1,10 +1,13 @@ 'use strict'; // SubmitForm controller -angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScope', '$state', 'myForm', 'Auth', - function($scope, $rootScope, $state, myForm, Auth) { +angular.module('forms').controller('SubmitFormController', [ + '$scope', '$rootScope', '$state', '$translate', 'myForm', 'Auth', + function($scope, $rootScope, $state, $translate, myForm, Auth) { $scope.authentication = Auth; $scope.myform = myForm; + console.log(myForm); + $translate.use(myForm.language); if(!$scope.myform.isLive){ // Show navbar if form is not public AND user IS loggedin @@ -19,6 +22,5 @@ angular.module('forms').controller('SubmitFormController', ['$scope', '$rootScop }else{ $scope.hideNav = $rootScope.hideNav = true; } - } ]); diff --git a/public/modules/forms/base/demo/boot.js b/public/modules/forms/base/demo/boot.js index 7f9c368f..a889417d 100644 --- a/public/modules/forms/base/demo/boot.js +++ b/public/modules/forms/base/demo/boot.js @@ -1,5 +1,5 @@ -angular.module('forms', ['duScroll', 'ngResource', 'NodeForm.templates']); +angular.module('forms', ['duScroll', 'ngResource', 'NodeForm.templates', 'pascalprecht.translate']); angular.module('NodeForm', [ 'ui.select', 'cgBusy', 'ngSanitize', 'vButton', 'ngResource', diff --git a/public/modules/forms/base/demo/index.html b/public/modules/forms/base/demo/index.html index d94659ce..61083082 100644 --- a/public/modules/forms/base/demo/index.html +++ b/public/modules/forms/base/demo/index.html @@ -39,7 +39,34 @@ @@ -68,6 +95,7 @@ + diff --git a/public/modules/forms/base/directives/field.client.directive.js b/public/modules/forms/base/directives/field.client.directive.js index 14177c4f..c8c9a456 100644 --- a/public/modules/forms/base/directives/field.client.directive.js +++ b/public/modules/forms/base/directives/field.client.directive.js @@ -14,25 +14,11 @@ angular.module('forms').directive('fieldDirective', ['$http', '$compile', '$root var getTemplateUrl = function(fieldType) { var type = fieldType; var templateUrl = 'modules/forms/base/views/directiveViews/field/'; - var supported_fields = [ - 'textfield', - 'textarea', - 'date', - 'dropdown', - 'hidden', - 'password', - 'radio', - 'legal', - 'statement', - 'rating', - 'yes_no', - 'number', - 'natural' - ]; - if (__indexOf.call(supportedFields, type) >= 0) { + + if (__indexOf.call(supportedFields, type) >= 0) { templateUrl = templateUrl+type+'.html'; } - return $templateCache.get('../public/'+templateUrl); + return $templateCache.get(templateUrl); }; return { diff --git a/public/modules/forms/base/directives/submit-form.client.directive.js b/public/modules/forms/base/directives/submit-form.client.directive.js index 66215725..c9066270 100644 --- a/public/modules/forms/base/directives/submit-form.client.directive.js +++ b/public/modules/forms/base/directives/submit-form.client.directive.js @@ -1,6 +1,7 @@ 'use strict'; -angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth', +angular.module('forms').directive('submitFormDirective', + ['$http', 'TimeCounter', '$filter', '$rootScope', 'Auth', function ($http, TimeCounter, $filter, $rootScope, Auth) { return { templateUrl: 'modules/forms/base/views/directiveViews/form/submit-form.client.view.html', restrict: 'E', @@ -11,12 +12,17 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter' $scope.authentication = $rootScope.authentication; $scope.noscroll = false; $scope.forms = {}; - $scope.form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ + + var form_fields_count = $scope.myform.visible_form_fields.filter(function(field){ if(field.fieldType === 'statement' || field.fieldType === 'rating'){ return false; } return true; }).length; + $scope.translateAdvancementData = { + done: $filter('formValidity')($scope.myform), + total: form_fields_count + }; $scope.reloadForm = function(){ //Reset Form @@ -99,6 +105,11 @@ angular.module('forms').directive('submitFormDirective', ['$http', 'TimeCounter' $scope.selected._id = field_id; $scope.selected.index = field_index; + $scope.translateAdvancementData = { + done: $filter('formValidity')($scope.myform), + total: form_fields_count + }; + if(animateScroll){ $scope.noscroll=true; setTimeout(function() { diff --git a/public/modules/forms/base/views/directiveViews/entryPage/startPage.html b/public/modules/forms/base/views/directiveViews/entryPage/startPage.html index 212a9d7e..d13f1715 100644 --- a/public/modules/forms/base/views/directiveViews/entryPage/startPage.html +++ b/public/modules/forms/base/views/directiveViews/entryPage/startPage.html @@ -9,7 +9,7 @@

@@ -18,7 +18,7 @@

-
\ No newline at end of file +
diff --git a/public/modules/forms/base/views/directiveViews/field/date.html b/public/modules/forms/base/views/directiveViews/field/date.html index ce6af237..444e6171 100755 --- a/public/modules/forms/base/views/directiveViews/field/date.html +++ b/public/modules/forms/base/views/directiveViews/field/date.html @@ -6,8 +6,8 @@ {{index+1}} - {{field.title}} - optional + {{field.title}} + {{ 'OPTIONAL' | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/dropdown.html b/public/modules/forms/base/views/directiveViews/field/dropdown.html index 88072775..3fb6e4f4 100755 --- a/public/modules/forms/base/views/directiveViews/field/dropdown.html +++ b/public/modules/forms/base/views/directiveViews/field/dropdown.html @@ -7,8 +7,8 @@ {{index+1}} - {{field.title}} - optional + {{field.title}} + {{ 'OPTIONAL' | translate }}
@@ -24,7 +24,7 @@ ng-class="{'active': option.option_value === field.fieldValue }"> - +

diff --git a/public/modules/forms/base/views/directiveViews/field/file.html b/public/modules/forms/base/views/directiveViews/field/file.html index fa865f3a..70c7f9e2 100644 --- a/public/modules/forms/base/views/directiveViews/field/file.html +++ b/public/modules/forms/base/views/directiveViews/field/file.html @@ -6,7 +6,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}
@@ -19,18 +19,18 @@
-
+
- Upload your File + {{ UPLOAD_FILE | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/legal.html b/public/modules/forms/base/views/directiveViews/field/legal.html index d071a616..8f82c39a 100644 --- a/public/modules/forms/base/views/directiveViews/field/legal.html +++ b/public/modules/forms/base/views/directiveViews/field/legal.html @@ -1,14 +1,14 @@
diff --git a/public/modules/forms/base/views/directiveViews/field/radio.html b/public/modules/forms/base/views/directiveViews/field/radio.html index 36e56049..de208ef6 100755 --- a/public/modules/forms/base/views/directiveViews/field/radio.html +++ b/public/modules/forms/base/views/directiveViews/field/radio.html @@ -9,7 +9,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}
@@ -25,12 +25,12 @@ type="radio" class="focusOn" ng-focus="setActiveField(field._id, index, true)" value="{{option.option_value}}" - ng-model="field.fieldValue" - ng-model-options="{ debounce: 250 }" + ng-model="field.fieldValue" + ng-model-options="{ debounce: 250 }" ng-required="field.required" ng-disabled="field.disabled" ng-change="$root.nextField()"/> - +
diff --git a/public/modules/forms/base/views/directiveViews/field/rating.html b/public/modules/forms/base/views/directiveViews/field/rating.html index 231182f2..835b09ee 100644 --- a/public/modules/forms/base/views/directiveViews/field/rating.html +++ b/public/modules/forms/base/views/directiveViews/field/rating.html @@ -6,8 +6,8 @@ {{index+1}} - {{field.title}} - optional + {{field.title}} + {{ 'OPTIONAL' | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/statement.html b/public/modules/forms/base/views/directiveViews/field/statement.html index 72d1cc81..064456ab 100644 --- a/public/modules/forms/base/views/directiveViews/field/statement.html +++ b/public/modules/forms/base/views/directiveViews/field/statement.html @@ -9,11 +9,11 @@

{{field.description}}


-
diff --git a/public/modules/forms/base/views/directiveViews/field/textarea.html b/public/modules/forms/base/views/directiveViews/field/textarea.html index 13cf097b..8014d142 100755 --- a/public/modules/forms/base/views/directiveViews/field/textarea.html +++ b/public/modules/forms/base/views/directiveViews/field/textarea.html @@ -33,11 +33,11 @@ ng-click="$root.nextField()" class="btn col-sm-5 col-xs-5"> - OK + {{ 'OK' | translate }}
- press ENTER + {{ 'ENTER' | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/textfield.html b/public/modules/forms/base/views/directiveViews/field/textfield.html index a85b3a74..f68e29d0 100755 --- a/public/modules/forms/base/views/directiveViews/field/textfield.html +++ b/public/modules/forms/base/views/directiveViews/field/textfield.html @@ -10,50 +10,50 @@ {{field.title}} - (optional) + ({{ 'OPTIONAL' | translate }})
-
-
+
-
- press ENTER + {{ 'ENTER' | translate }}
diff --git a/public/modules/forms/base/views/directiveViews/field/yes_no.html b/public/modules/forms/base/views/directiveViews/field/yes_no.html index 191d9e24..1fce19ae 100644 --- a/public/modules/forms/base/views/directiveViews/field/yes_no.html +++ b/public/modules/forms/base/views/directiveViews/field/yes_no.html @@ -10,7 +10,7 @@ {{field.title}} - optional + {{ 'OPTIONAL' | translate }}

@@ -22,36 +22,36 @@

Yes
- +