# HG changeset patch # User ymh # Date 1378687190 -7200 # Node ID fcfa68f39f6b1ecc20c97d7a481ad3a506ac44b4 # Parent e2ccb00934527d2a46a6b2a70483b5260f45bbbb model/controler separation. Add controler for thesaurus. diff -r e2ccb0093452 -r fcfa68f39f6b src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Mon Sep 09 01:48:26 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Mon Sep 09 02:39:50 2013 +0200 @@ -19,31 +19,47 @@ }); }); -app.controller("RecordCtrl", function($scope, Api, context){ - $scope.record = Api.record.get({recordId: context.record_id}); - $scope.uriLabels = context.uri_labels; +app.service("RecordModel", function(Api, context) { + this.record = Api.record.get({recordId: context.record_id}); + this.uriLabels = context.uri_labels; +}); + +app.controller("RecordCtrl", function($scope, RecordModel, context){ - $scope.addSubject = function() { - $scope.record.subjects.push($scope.addSubjectText); - $scope.addSubjectText = ''; - }; + $scope.record = RecordModel.record; + $scope.uriLabels = RecordModel.uriLabels; - $scope.updateUriLabelDict = function(k,v) { - $scope.uriLabels[k] = v; - }; $scope.submitRecord = function() { $scope.record.$save({recordId: context.record_id}); } - $scope.removeSubject = function(uri) { - i = $scope.record.subjects.indexOf(uri); + $scope.removeFromList = function(uri, list) { + i = list.indexOf(uri); if(i>=0){ - $scope.record.subjects.splice(i, 1); + list.splice(i, 1); } }; }); +app.controller("ThesaurusCtrl", function($scope, RecordModel) { + + $scope.record = RecordModel.record; + $scope.uriLabels = RecordModel.uriLabels; + $scope.addSubjectText = ''; + + $scope.addSubject = function() { + $scope.record.subjects.push($scope.addSubjectText); + $scope.addSubjectText = ''; + }; + + $scope.updateUriLabelDict = function(k,v) { + $scope.uriLabels[k] = v; + }; + + +}); + app.config(['$routeProvider', function($routeProvider) { // $routeProvider.when('/', {controller: 'RecordCtrl', templateUrl: 'partials/record.html'}); // $routeProvider.otherwise({redirectTo: '/'}); diff -r e2ccb0093452 -r fcfa68f39f6b src/p4l/templates/p4l/record_update_form.html --- a/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 01:48:26 2013 +0200 +++ b/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 02:39:50 2013 +0200 @@ -63,9 +63,9 @@ {{'subjects' | translate}} -
+
{{'or' | translate}}