Commit df281886 authored by Hellmich, Christoph's avatar Hellmich, Christoph
Browse files

Move element configuration to a new file

parent d3dc7bb7
......@@ -147,6 +147,7 @@
<script src="scripts/app/wizardEditor/wizardEditor-wizard-delete-dialog.controller.js"></script>
<script src="scripts/components/wizardEditor/simpleConditional/simpleConditional-directive.js"></script>
<script src="scripts/components/wizardEditor/templateImporter/templateImporter.controller.js"></script>
<script src="scripts/components/wizardEditor/element.config.js"></script>
<script src="scripts/components/wizardEditor/tree.service.js"></script>
<script src="scripts/components/auth/services/sessions.service.js"></script>
<script src="scripts/components/auth/provider/auth.session.service.js"></script>
......
'use strict';
angular.module('ddaApp')
.constant('customElements', [
{
'fieldName': 'simpleConditional',
'category': 'Wizard',
'fieldOptions': {
'displayName': 'Conditional',
'hidden': false,
'nolabel': false
}
},
{
'fieldName': 'checkbox', // = Ordnername in components/wizardEditor/
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Checkbox'
}
},
{
'fieldName': 'checkboxlist',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Checkbox List'
}
},
{
'fieldName': 'templateImporter',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Template Importer'
}
}
])
.constant('validationMessages', {
// 'date' : 'Invalid date',
// 'dateMin' : 'Date value too low',
// 'dateMax' : 'Date value too high',
// 'max' : 'The value {{ field.schema && ("should be less than " + field.schema.validation.max) || field.state.$viewValue + " is too high" }}'
})
.constant('validationPattern', {
// 'Integer': '/^-{0,1}\\d+$/'
})
.config(function(fgConfigProvider, FgField, customElements, validationMessages, validationPattern) {
for (var i = 0; i < customElements.length; i++) {
var element = customElements[i];
var fieldTemplate = new FgField(element.fieldName, element.fieldOptions);
var templateUrl = 'scripts/components/wizardEditor/' + element.fieldName + '/' + element.fieldName + '-template.ng.html';
var propertiesUrl = 'scripts/components/wizardEditor/' + element.fieldName + '/' + element.fieldName + '-properties.ng.html';
fgConfigProvider.fields.add(fieldTemplate, element.category, templateUrl, propertiesUrl);
}
fgConfigProvider.validation.message(validationMessages);
fgConfigProvider.validation.pattern(validationPattern);
})
.controller('WizardEditorController', function($scope, $state, entity, Wizard, Step, Element, treeService) {
var deletedFields = [];
$scope.formDirty = false; // TODO: use $dirty, or something else
......@@ -124,13 +69,13 @@ angular.module('ddaApp')
var changingFormWatcher = watchFormChanging();
changingFormWatcher(true);
var onSaveError = function(result) {
var onSaveError = function(result) {
console.log('onSaveError');
console.log(result);
};
function loadFields(step) {
if(!step) {
if (!step) {
$scope.selectedStep = null;
$scope.myForm = {
schema: {
......@@ -139,7 +84,9 @@ angular.module('ddaApp')
};
return;
}
Step.elements({ 'id': step.id }, function(elements) {
Step.elements({
'id': step.id
}, function(elements) {
$scope.myForm.schema.fields = elements;
$scope.selectedStep = step;
deletingFieldWatcher(false);
......@@ -157,13 +104,16 @@ angular.module('ddaApp')
i;
for (i = 0; i < deletedFields.length; i++) {
Element.delete({ 'id': deletedFields[i].id });
Element.delete({
'id': deletedFields[i].id
});
}
var counter = 0;
function count() {
counter++;
if(counter === fields.length) {
if (counter === fields.length) {
loadFields($scope.selectedStep);
}
}
......@@ -171,11 +121,11 @@ angular.module('ddaApp')
for (i = 0; i < fields.length; i++) {
var element = fields[i];
element.step = {
'id': $scope.selectedStep.id
'id': $scope.selectedStep.id
};
element.formRow = i;
if(!element.id) {
if (!element.id) {
Element.save(element, count, onSaveError); // TODO: onSaveError
} else {
Element.update(element, count, onSaveError); // TODO: onSaveError
......@@ -205,7 +155,7 @@ angular.module('ddaApp')
$scope.wizards = result;
});
if($state.params.id) {
if ($state.params.id) {
Wizard.steps({
id: $state.params.id
}, function(steps) {
......
'use strict';
angular.module('ddaApp')
.constant('customElements', [{
'fieldName': 'simpleConditional', // = Ordnername in components/wizardEditor/
'category': 'Wizard',
'fieldOptions': {
'displayName': 'Conditional',
'hidden': false,
'nolabel': false
}
}, {
'fieldName': 'checkbox',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Checkbox'
}
}, {
'fieldName': 'checkboxlist',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Checkbox List'
}
}, {
'fieldName': 'templateImporter',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Template Importer'
}
}])
.constant('validationMessages', {
// 'date' : 'Invalid date',
// 'dateMin' : 'Date value too low',
// 'dateMax' : 'Date value too high',
// 'max' : 'The value {{ field.schema && ("should be less than " + field.schema.validation.max) || field.state.$viewValue + " is too high" }}'
})
.constant('validationPattern', {
// 'Integer': '/^-{0,1}\\d+$/'
})
.config(function(fgConfigProvider, FgField, customElements, validationMessages, validationPattern) {
for (var i = 0; i < customElements.length; i++) {
var element = customElements[i];
var fieldTemplate = new FgField(element.fieldName, element.fieldOptions);
var templateUrl = 'scripts/components/wizardEditor/' + element.fieldName + '/' + element.fieldName + '-template.ng.html';
var propertiesUrl = 'scripts/components/wizardEditor/' + element.fieldName + '/' + element.fieldName + '-properties.ng.html';
fgConfigProvider.fields.add(fieldTemplate, element.category, templateUrl, propertiesUrl);
}
fgConfigProvider.validation.message(validationMessages);
fgConfigProvider.validation.pattern(validationPattern);
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment