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

Remove form service

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