# HG changeset patch # User cavaliet # Date 1378740097 -7200 # Node ID 634e0994c1c83a2d14cba8013de4b2893019a0df # Parent 2e52a8a10f8e418182ae164eedd9c9e100787afc add uri generic diff -r 2e52a8a10f8e -r 634e0994c1c8 src/p4l/static/p4l/css/semantictree.css --- a/src/p4l/static/p4l/css/semantictree.css Mon Sep 09 14:17:47 2013 +0200 +++ b/src/p4l/static/p4l/css/semantictree.css Mon Sep 09 17:21:37 2013 +0200 @@ -1,3 +1,6 @@ +.ng-scope { + border: 1px dashed red; +} /*@charset "UTF-8"; .large_25 { diff -r 2e52a8a10f8e -r 634e0994c1c8 src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Mon Sep 09 14:17:47 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Mon Sep 09 17:21:37 2013 +0200 @@ -54,6 +54,10 @@ $scope.record.$save({recordId: context.record_id}); } + $scope.addUriToList = function(list, uri) { + list.push(uri); + }; + $scope.removeFromList = function(uri, list) { i = list.indexOf(uri); if(i>=0){ @@ -72,15 +76,17 @@ }); -app.controller("ThesaurusCtrl", function($scope, RecordModel) { +app.controller("ThesaurusCtrl", function($scope, RecordModel, context) { $scope.record = RecordModel.record; $scope.uriLabels = RecordModel.uriLabels; - $scope.addSubjectText = ''; + $scope.addUriText = ''; - $scope.addSubject = function() { - $scope.record.subjects.push($scope.addSubjectText); - $scope.addSubjectText = ''; + $scope.addUriToList = function() { + console.log("$scope") + console.log($scope) + $scope.record[$scope.listname].push($scope.addUriText); + $scope.addUriText = ''; }; $scope.updateUriLabelDict = function(k,v) { @@ -90,6 +96,46 @@ }); +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" + }, + 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){ + if (attr_dict.hasOwnProperty(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(); + } + } + }); + app.config(['$routeProvider', function($routeProvider) { // $routeProvider.when('/', {controller: 'RecordCtrl', templateUrl: 'partials/record.html'}); // $routeProvider.otherwise({redirectTo: '/'}); diff -r 2e52a8a10f8e -r 634e0994c1c8 src/p4l/templates/p4l/record_update_form.html --- a/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 14:17:47 2013 +0200 +++ b/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 17:21:37 2013 +0200 @@ -30,17 +30,19 @@ base_static: "{% get_static_prefix %}", record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":"), }, + themes_query_dict: angular.fromJson('{{ themes_query_dict | safe | addslashes}}'), + subjects_query_dict: angular.fromJson('{{ subjects_query_dict | safe | addslashes}}') }) .config(['$translateProvider', function($translateProvider) { $translateProvider.translations(catalog); //catalog is declared in django.views.i18n.javascript_catalog }]); - var sqd = angular.fromJson('{{ subjects_query_dict | safe | addslashes}}'); + /*var sqd = angular.fromJson('{{ subjects_query_dict | safe | addslashes}}'); for (var k in sqd){ if (sqd.hasOwnProperty(k)) { $("#id_addSubjectText").attr(k,sqd[k]); } - } + }*/ {% endblock %} @@ -66,19 +68,16 @@
- +