# HG changeset patch # User ymh # Date 1378729067 -7200 # Node ID 2e52a8a10f8e418182ae164eedd9c9e100787afc # Parent fcfa68f39f6b1ecc20c97d7a481ad3a506ac44b4 Add directive to edit objects diff -r fcfa68f39f6b -r 2e52a8a10f8e src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Mon Sep 09 02:39:50 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Mon Sep 09 14:17:47 2013 +0200 @@ -24,10 +24,30 @@ this.uriLabels = context.uri_labels; }); +app.directive('objectForm', function(RecordModel, context) { + return { + restrict: 'E', + replace: true, + transclude: true, + scope: { + obj:"=editedObject", + onOk: "&" + }, + //templateUrl: context.urls.base_static+'p4l/templates/imprintForm.html', + templateUrl: function(tElement, tAttrs) { + return context.urls.base_static+'p4l/templates/'+ tAttrs.templateName +'.html'; + }, + link: function(scope, element, attrs) { + + } + }; +}); + app.controller("RecordCtrl", function($scope, RecordModel, context){ $scope.record = RecordModel.record; $scope.uriLabels = RecordModel.uriLabels; + $scope.editedImprint = null; $scope.submitRecord = function() { @@ -40,6 +60,16 @@ list.splice(i, 1); } }; + + $scope.setEditedObject = function(obj, prop) { + $scope[prop] = obj; + } + + $scope.newEditedObject = function(templ, list, prop) { + list.push(templ); + $scope[prop] = templ; + } + }); app.controller("ThesaurusCtrl", function($scope, RecordModel) { diff -r fcfa68f39f6b -r 2e52a8a10f8e src/p4l/static/p4l/templates/imprintForm.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/imprintForm.html Mon Sep 09 14:17:47 2013 +0200 @@ -0,0 +1,9 @@ +
+
+ + + + +
+ +
\ No newline at end of file diff -r fcfa68f39f6b -r 2e52a8a10f8e src/p4l/templates/p4l/record_update_form.html --- a/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 02:39:50 2013 +0200 +++ b/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 14:17:47 2013 +0200 @@ -27,8 +27,9 @@ uri_labels: angular.fromJson('{{uri_labels | safe | addslashes}}'), csrf_token: "{{ csrf_token }}", urls: { - record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":") - } + base_static: "{% get_static_prefix %}", + record_api: "{% url 'record-detail' identifier=':recordId' %}".replace("\%3A",":"), + }, }) .config(['$translateProvider', function($translateProvider) { $translateProvider.translations(catalog); //catalog is declared in django.views.i18n.javascript_catalog @@ -62,8 +63,8 @@ {{'subjects' | translate}} -