Skip to content

Commit 52a7fab

Browse files
committed
Fix custom control example
1 parent a1b9428 commit 52a7fab

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

examples/app/custom/custom.jsf.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1-
function customDirective(){
1+
function customDirective() {
22
return {
33
restrict : "E",
4-
//replace= true;
5-
template : '<control><input type="text" style="background-color: #3278b3; color: #8dd0ff" class="jsf-control-string jsf-control form-control" ng-change="vm.modelChanged()" ng-model="vm.modelValue[vm.fragment]" /></control>',
4+
template : '<jsonforms-control>' +
5+
'<input type="text" style="background-color: #3278b3; color: #8dd0ff" class="jsf-control-string jsf-control form-control" ng-change="vm.modelChanged()" ng-model="vm.modelValue[vm.fragment]" />' +
6+
'</jsonforms-control>',
67
controller : customController,
7-
controllerAs : 'vm',
8+
controllerAs : 'vm'
89
};
910
}
10-
function CustomControlRendererTester (element, dataSchema, dataObject,pathResolver ){
11-
if(element.type!='Control')
11+
/**
12+
* @return {number}
13+
*/
14+
function CustomControlRendererTester (element, dataSchema, dataObject,pathResolver ) {
15+
if(element.type !== 'Control')
1216
return -1;
13-
let schemaPath=element['scope']['$ref'];
14-
if(schemaPath != undefined && schemaPath.endsWith("firstName"))
17+
var schemaPath = element['scope']['$ref'];
18+
if(schemaPath !== undefined && schemaPath.endsWith("firstName"))
1519
return 100;
1620
return -1;
1721
}
18-
let customController=['$scope','PathResolver', function ($scope,refResolver) {
22+
var customController = ['$scope','PathResolver', function ($scope,refResolver) {
1923
var vm = this;
20-
vm.fragment=refResolver.lastFragment($scope.uiSchema.scope.$ref);
21-
vm.modelValue=refResolver.resolveToLastModel($scope.data,$scope.uiSchema.scope.$ref);
22-
}]
24+
vm.fragment = refResolver.lastFragment($scope.uischema.scope.$ref);
25+
vm.modelValue = refResolver.resolveToLastModel($scope.data,$scope.uischema.scope.$ref);
26+
}];
2327

2428
var app = angular.module('makeithappen');
25-
app.directive('customControl', customDirective)
29+
app.directive('customControl', customDirective);
2630
app.run(['RendererService', function(RendererService) {
27-
RendererService.register("custom-control",CustomControlRendererTester);
31+
RendererService.register("custom-control", CustomControlRendererTester);
2832
}]);

0 commit comments

Comments
 (0)