Commit 979e664b authored by Hellmich, Christoph's avatar Hellmich, Christoph
Browse files

Remove form service

parent dade8d4b
......@@ -148,7 +148,6 @@
<script src="scripts/components/wizardEditor/nextStep/nextStep.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/form.service.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>
......
......@@ -2,44 +2,36 @@
angular.module('ddaApp')
.constant('customElements', [
{
'fieldName': 'simpleConditional',
'category': 'Wizard',
'fieldOptions': {
'displayName': 'Conditional',
'hidden': false,
'nolabel': false
}
},
{
'fieldName': 'checkbox', // = Ordnername in components/wizardEditor/
'category': '- Development -',
'category': ' Development',
'fieldOptions': {
'displayName': 'Checkbox'
}
},
{
'fieldName': 'checkboxlist',
'category': '- Development -',
'category': ' Development',
'fieldOptions': {
'displayName': 'Checkbox List'
}
},
{
'fieldName': 'simpleConditional',
'category': 'Wizard',
'fieldName': 'templateImporter',
'category': '⚠ Development',
'fieldOptions': {
'displayName': 'Conditional',
'hidden': false,
'nolabel': false
'displayName': 'Template Importer'
}
},
// {
// 'fieldName': 'nextStep',
// 'category': 'Development',
// 'fieldOptions': {
// 'displayName': 'Next Step',
// 'hidden': true
// }
// },
// {
// 'fieldName': 'templateImporter',
// 'category': 'Development',
// 'fieldOptions': {
// 'displayName': 'Template Importer'
// }
// }
}
])
.constant('validationMessages', {
// 'date' : 'Invalid date',
......@@ -64,7 +56,7 @@ angular.module('ddaApp')
fgConfigProvider.validation.message(validationMessages);
fgConfigProvider.validation.pattern(validationPattern);
})
.controller('WizardEditorController', function($scope, $state, entity, Wizard, tree, form) {
.controller('WizardEditorController', function($scope, $state, entity, Wizard, Step, Element, tree) {
var deletedFields = [];
$scope.formDirty = false; // TODO: use $dirty, or something else
......@@ -132,6 +124,11 @@ angular.module('ddaApp')
var changingFormWatcher = watchFormChanging();
changingFormWatcher(true);
var onSaveError = function(result) {
console.log('onSaveError');
console.log(result);
};
function loadFields(step) {
if(!step) {
$scope.selectedStep = null;
......@@ -142,8 +139,7 @@ angular.module('ddaApp')
};
return;
}
form.getElements(step.id).then(function(elements) {
Step.elements({ 'id': step.id }, function(elements) {
$scope.myForm.schema.fields = elements;
$scope.selectedStep = step;
deletingFieldWatcher(false);
......@@ -161,7 +157,7 @@ angular.module('ddaApp')
i;
for (i = 0; i < deletedFields.length; i++) {
form.removeElement(deletedFields[i].id);
Element.delete({ 'id': deletedFields[i].id });
}
var counter = 0;
......@@ -180,12 +176,11 @@ angular.module('ddaApp')
element.formRow = i;
if(!element.id) {
form.addElement(element).then(count);
Element.save(element, count, onSaveError); // TODO: onSaveError
} else {
form.updateElement(element).then(count);
Element.update(element, count, onSaveError); // TODO: onSaveError
}
}
};
$scope.cancelForm = function() {
......
'use strict';
angular
.module('ddaApp').factory('form', function(Step, Element) {
function getElements(stepId) {
var elements = Step.elements({
id: stepId
}).$promise;
return elements;
}
var onSaveSuccess = function(result) {
// console.log('onSaveSuccess');
// console.log(result);
};
var onSaveError = function(result) {
console.log('onSaveError');
console.log(result);
};
function addElement(element) {
console.log('addElement');
return Element.save(element, onSaveSuccess, onSaveError).$promise;
}
function updateElement(element) {
console.log('updateElement');
return Element.update(element, onSaveSuccess, onSaveError).$promise;
}
function removeElement(id) {
console.log('removeElement');
return Element.delete({
'id': id
}).$promise;
}
var service = {
getElements: getElements,
addElement: addElement,
updateElement: updateElement,
removeElement: removeElement
};
return service;
});
'use strict';
angular.module('ddaApp').controller('templateImporterController', function($scope, $state, DataUtils, Template, form, fgConfig, FgField) {
angular.module('ddaApp').controller('templateImporterController', function($scope, $state, DataUtils, Template) {
$scope.template = {};
$scope.result = null;
......
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