# HG changeset patch # User cavaliet # Date 1379674495 -7200 # Node ID e2ecb345b58f55f9df6b96ae120c49e2f32717e0 # Parent 7a2b612ca5e024612992d7200b9f3ca8c75ccaa3 thesaurus add button enabled only when uri is correct diff -r 7a2b612ca5e0 -r e2ecb345b58f src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Fri Sep 20 11:43:49 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Fri Sep 20 12:54:55 2013 +0200 @@ -14,12 +14,12 @@ save:{ method:"PUT", isArray:false, - headers:{'X-CSRFToken':context.csrf_token} + headers:{'X-CSRFToken':context.csrf_token} } }); }); -app.service("RecordModel", function(Api, context) { +app.service("RecordModel", function(Api, context) { this.record = Api.record.get({recordId: context.record_id}); this.uriLabels = context.uri_labels; }); @@ -193,6 +193,7 @@ $scope.record = RecordModel.record; $scope.uriLabels = RecordModel.uriLabels; $scope.addUriText = ''; + $scope.uriInDict = false; $scope.addUriToList = function() { $scope.list.push($scope.addUriText); @@ -208,6 +209,9 @@ $scope.updateUriLabelDict = function(k,v) { $scope.uriLabels[k] = v; }; + $scope.$watch("addUriText", function(newValue, oldValue){ + $scope.uriInDict = (($scope.dataquery!='') && ($scope.addUriText in $scope.uriLabels)); + }); } } }); @@ -246,6 +250,7 @@ $scope.record = RecordModel.record; $scope.uriLabels = RecordModel.uriLabels; $scope.addUriText = ''; + $scope.uriInDict = false; $scope.updateVal = function() { $scope.val = $scope.addUriText; @@ -254,6 +259,9 @@ $scope.updateUriLabelDict = function(k,v) { $scope.uriLabels[k] = v; }; + $scope.$watch("addUriText", function(newValue, oldValue){ + $scope.uriInDict = (($scope.dataquery!='') && ($scope.addUriText in $scope.uriLabels)); + }); } }; }); diff -r 7a2b612ca5e0 -r e2ecb345b58f src/p4l/static/p4l/js/semantictree.js --- a/src/p4l/static/p4l/js/semantictree.js Fri Sep 20 11:43:49 2013 +0200 +++ b/src/p4l/static/p4l/js/semantictree.js Fri Sep 20 12:54:55 2013 +0200 @@ -42,6 +42,7 @@ angular.element(this).scope().updateUriLabelDict(uri, ui.item.label); // Angular does not listen to val() event so we update the model value manually: angular.element(this).controller('ngModel').$setViewValue(uri); + angular.element(this).scope().$apply(); }, minLength: 2 }); @@ -200,6 +201,7 @@ angular.element($('#id_'+input_name)[0]).scope().updateUriLabelDict(uri, label); // Angular does not listen to val() event so we update the model value manually: angular.element($('#id_'+input_name)[0]).controller('ngModel').$setViewValue(uri); + angular.element($('#id_'+input_name)[0]).scope().$apply(); // And update the text field val $('#id_'+input_name).val(label + " (" + uri + ")"); } diff -r 7a2b612ca5e0 -r e2ecb345b58f src/p4l/static/p4l/templates/addSemanticUriForm.html --- a/src/p4l/static/p4l/templates/addSemanticUriForm.html Fri Sep 20 11:43:49 2013 +0200 +++ b/src/p4l/static/p4l/templates/addSemanticUriForm.html Fri Sep 20 12:54:55 2013 +0200 @@ -18,7 +18,7 @@