--- a/src/p4l/static/p4l/js/p4l.js Mon Sep 09 17:21:37 2013 +0200
+++ b/src/p4l/static/p4l/js/p4l.js Mon Sep 09 17:56:59 2013 +0200
@@ -76,62 +76,45 @@
});
-app.controller("ThesaurusCtrl", function($scope, RecordModel, context) {
-
- $scope.record = RecordModel.record;
- $scope.uriLabels = RecordModel.uriLabels;
- $scope.addUriText = '';
-
- $scope.addUriToList = function() {
- console.log("$scope")
- console.log($scope)
- $scope.record[$scope.listname].push($scope.addUriText);
- $scope.addUriText = '';
- };
-
- $scope.updateUriLabelDict = function(k,v) {
- $scope.uriLabels[k] = v;
- };
-
-
-});
-
app.directive('addSemUri', function(RecordModel, context){
return {
restrict: 'E',
- // This HTML will replace the zippy directive.
replace: true,
transclude: true,
scope: {
localid:"@",
- listname:"@",
- //url:"ntm"
+ listname:"@"
},
templateUrl: function(tElement, tAttrs) {
return context.urls.base_static+'p4l/templates/addSemanticUriForm.html';
},
- // The linking function will add behavior to the template
- link: function(scope, element, attrs) {
- // Get queries attributes from scope listname and context query dict
- /*console.log("scope = ");
- console.log(scope);
- console.log("id_listname = ");
- console.log(scope["listname"]);
- attr_dict = context[scope["listname"] + "_query_dict"];
- console.log("attr_dict = ");
- console.log(attr_dict);
- for (var k in attr_dict){
+ link: function($scope, $element, $attrs) {
+ // Get queries attributes from $scope listname and context query dict
+ attr_dict = context[$scope.listname + "_query_dict"];
+ for (var k in attr_dict){
if (attr_dict.hasOwnProperty(k)) {
- scope[k] = attr_dict[k];
+ $scope[k] = attr_dict[k];
}
- }*/
- //init_autocomplete();
- //console.log("element = ");
- //console.log(element);
- //console.log("attrs = ");
- //console.log(attrs);
- //console.log(parentCtrl.addUriToList);
- //init_autocomplete();
+ }
+ // initalize autocomplete and browse thesaurus events
+ init_autocomplete();
+ // We have to apply because init_browse needs the real ids and not {{ localid }}
+ $scope.$apply();
+ init_browse();
+ },
+ controller: function($scope, $element, $attrs, $transclude, RecordModel){
+ $scope.record = RecordModel.record;
+ $scope.uriLabels = RecordModel.uriLabels;
+ $scope.addUriText = '';
+
+ $scope.addUriToList = function() {
+ $scope.record[$scope.listname].push($scope.addUriText);
+ $scope.addUriText = '';
+ };
+
+ $scope.updateUriLabelDict = function(k,v) {
+ $scope.uriLabels[k] = v;
+ };
}
}
});
--- a/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 17:21:37 2013 +0200
+++ b/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 17:56:59 2013 +0200
@@ -37,12 +37,6 @@
$translateProvider.translations(catalog); //catalog is declared in django.views.i18n.javascript_catalog
}]);
- /*var sqd = angular.fromJson('{{ subjects_query_dict | safe | addslashes}}');
- for (var k in sqd){
- if (sqd.hasOwnProperty(k)) {
- $("#id_addSubjectText").attr(k,sqd[k]);
- }
- }*/
</script>
{% endblock %}
--- a/src/p4l/views.py Mon Sep 09 17:21:37 2013 +0200
+++ b/src/p4l/views.py Mon Sep 09 17:56:59 2013 +0200
@@ -126,18 +126,18 @@
context['uri_labels'] = json.dumps(uri_labels)
context['subjects_query_dict'] = json.dumps({
- 'data-url': settings.SPARQL_QUERY_ENDPOINT,
- 'data-query': settings.SPARQL_SUBJECT_QUERIES["filter"],
- 'data-root-query': settings.SPARQL_SUBJECT_QUERIES["root"],
- 'data-childs-query': settings.SPARQL_SUBJECT_QUERIES["childs"],
- 'data-child-count-query': settings.SPARQL_SUBJECT_QUERIES["child-count"]
+ 'dataurl': settings.SPARQL_QUERY_ENDPOINT,
+ 'dataquery': settings.SPARQL_SUBJECT_QUERIES["filter"],
+ 'datarootquery': settings.SPARQL_SUBJECT_QUERIES["root"],
+ 'datachildsquery': settings.SPARQL_SUBJECT_QUERIES["childs"],
+ 'datachildcountquery': settings.SPARQL_SUBJECT_QUERIES["child-count"]
})
context['themes_query_dict'] = json.dumps({
- 'data-url': settings.SPARQL_QUERY_ENDPOINT,
- 'data-query': settings.SPARQL_THEME_QUERIES["filter"],
- 'data-root-query': settings.SPARQL_THEME_QUERIES["root"],
- 'data-childs-query': settings.SPARQL_THEME_QUERIES["childs"],
- 'data-child-count-query': settings.SPARQL_THEME_QUERIES["child-count"]
+ 'dataurl': settings.SPARQL_QUERY_ENDPOINT,
+ 'dataquery': settings.SPARQL_THEME_QUERIES["filter"],
+ 'datarootquery': settings.SPARQL_THEME_QUERIES["root"],
+ 'datachildsquery': settings.SPARQL_THEME_QUERIES["childs"],
+ 'datachildcountquery': settings.SPARQL_THEME_QUERIES["child-count"]
})
return context