# HG changeset patch # User cavaliet # Date 1378803465 -7200 # Node ID a0ef3043b1d27bf2c34d0894c3622bb6d9064af1 # Parent 32591d23cb4bb59409ff428b344e628a723a3f75# Parent cae920b543068c169d5d09fdbb2fd7c4eac7e147 Merge with cae920b543068c169d5d09fdbb2fd7c4eac7e147 and enhance add sem directive diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/css/p4l.css --- a/src/p4l/static/p4l/css/p4l.css Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/static/p4l/css/p4l.css Tue Sep 10 10:57:45 2013 +0200 @@ -44,3 +44,8 @@ .flag.flag-es {background-position: -16px 0} .flag.flag-fr {background-position: 0 -11px} .flag.flag-en {background-position: -16px -11px} + +/* css class to avoid angular flicker */ +[ng\:cloak], [ng-cloak], [data-ng-cloak], [x-ng-cloak], .ng-cloak, .x-ng-cloak { + display: none !important; +} diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/css/semantictree.css --- a/src/p4l/static/p4l/css/semantictree.css Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/static/p4l/css/semantictree.css Tue Sep 10 10:57:45 2013 +0200 @@ -1,7 +1,7 @@ -.ng-scope { +/*.ng-scope { border: 1px dashed red; } -/*@charset "UTF-8"; +@charset "UTF-8"; .large_25 { width: 25px; diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/js/p4l.js --- a/src/p4l/static/p4l/js/p4l.js Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/static/p4l/js/p4l.js Tue Sep 10 10:57:45 2013 +0200 @@ -1,4 +1,4 @@ - +//"use strict"; // initialize the app var app = angular.module("recordApp", ['ngResource', 'ngRoute', 'pascalprecht.translate']) @@ -24,53 +24,96 @@ this.uriLabels = context.uri_labels; }); -app.directive('objectForm', function(RecordModel, context) { + +app.directive('objectDisp', ['$compile', '$http', '$templateCache', 'context', function($compile, $http, $templateCache, context) { + + var getTemplate = function(templateName) { + var templateLoader, + templateUrl = context.urls.base_static+'p4l/templates/'+templateName+'.html'; + templateLoader = $http.get(templateUrl, {cache: $templateCache}); + + return templateLoader; + } + + var linker = function(scope, element, attrs) { + + var loader = getTemplate(scope.dispTemplate); + + var promise = loader.success(function(html) { + element.html(html); + }).then(function (response) { + element.replaceWith($compile(element.html())(scope)); + }); + } + + return { + restrict: 'E', + scope: { + dispTemplate: "=", + obj: "=" + }, + link: linker + }; +}]); + + +app.directive('objectList', function(RecordModel, context) { return { restrict: 'E', replace: true, transclude: true, scope: { - obj:"=editedObject", - onOk: "&" + list:"=objectList", + dispTemplate: "@dispTemplate", + formTemplate: "@formTemplate", + objectFields: "@objectFields" + }, + controller: function($scope, $element, $attrs, $transclude) { + $scope.getStaticTemplateUrl = function(templateName) { + return context.urls.base_static+'p4l/templates/'+templateName+".html"; + } + $scope.getEmptyObjectFromList = function(fieldList) { + var res = {}; + for ( var field in fieldList) { + res[field] = ""; + } + return res; + } }, - //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) { + templateUrl: context.urls.base_static+'p4l/templates/objectList.html', + link: function($scope, $element, $attrs) { + $scope.editedObj = null; + + $scope.getEmptyObject = function() { + return $scope.getEmptyObjectFromList(angular.fromJson($scope.objectFields)); + }; + + $scope.setEditedObject = function(obj) { + $scope.editedObj = obj; + } + + $scope.newEditedObject = function() { + var newObj = $scope.getEmptyObject(); + $scope.list.push(newObj); + $scope.setEditedObject(newObj); + }; + + $scope.removeFromList = function(obj) { + var i = $scope.list.indexOf(obj); + if(i>=0){ + $scope.list.splice(i, 1); + } + $scope.setEditedObject(null); + } + + $scope.onOk = function() { + $scope.setEditedObject(null); + } } }; }); -app.controller("RecordCtrl", function($scope, RecordModel, context){ - - $scope.record = RecordModel.record; - $scope.uriLabels = RecordModel.uriLabels; - $scope.editedImprint = null; - - - $scope.submitRecord = function() { - $scope.record.$save({recordId: context.record_id}); - } - - $scope.removeFromList = function(uri, list) { - i = list.indexOf(uri); - if(i>=0){ - 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.directive('addSemUri', function(RecordModel, context){ return { @@ -113,7 +156,20 @@ }; } } - }); +}); + + +app.controller("RecordCtrl", function($scope, RecordModel, context){ + + $scope.record = RecordModel.record; + $scope.uriLabels = RecordModel.uriLabels; + + $scope.submitRecord = function() { + $scope.record.$save({recordId: context.record_id}); + } + + +}); app.config(['$routeProvider', function($routeProvider) { // $routeProvider.when('/', {controller: 'RecordCtrl', templateUrl: 'partials/record.html'}); diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/addSemanticUriForm.html --- a/src/p4l/static/p4l/templates/addSemanticUriForm.html Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/static/p4l/templates/addSemanticUriForm.html Tue Sep 10 10:57:45 2013 +0200 @@ -1,15 +1,20 @@ -
-
- - {{ 'or' | translate}} - - {{'Browse' | translate}} - - -
-
- -
-
\ No newline at end of file +
+ +
+
+ + {{ 'or' | translate}} + + {{'Browse' | translate}} + + +
+
+ +
+
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/documentCodeDisp.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/documentCodeDisp.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,1 @@ +
{{'document code'|translate}} : {{obj.documentCode}}
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/documentCodeForm.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/documentCodeForm.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/imprintDisp.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/imprintDisp.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,6 @@ + diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/imprintForm.html --- a/src/p4l/static/p4l/templates/imprintForm.html Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/static/p4l/templates/imprintForm.html Tue Sep 10 10:57:45 2013 +0200 @@ -1,9 +1,10 @@ -
-
- - - - -
- -
\ No newline at end of file +
+
+ + +
+
+ + +
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/isbnDisp.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/isbnDisp.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,1 @@ +
{{'isbn'|translate}} : {{obj.isbn}}
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/isbnForm.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/isbnForm.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/issnDisp.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/issnDisp.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,1 @@ +
{{'issn'|translate}} : {{obj.issn}}
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/issnForm.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/issnForm.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/static/p4l/templates/objectList.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/p4l/static/p4l/templates/objectList.html Tue Sep 10 10:57:45 2013 +0200 @@ -0,0 +1,15 @@ +
+ + +
+ + +
+
\ No newline at end of file diff -r 32591d23cb4b -r a0ef3043b1d2 src/p4l/templates/p4l/record_update_form.html --- a/src/p4l/templates/p4l/record_update_form.html Mon Sep 09 18:46:02 2013 +0200 +++ b/src/p4l/templates/p4l/record_update_form.html Tue Sep 10 10:57:45 2013 +0200 @@ -41,7 +41,7 @@ {% block content %} {% verbatim %} -
+
@@ -58,18 +58,12 @@ @@ -78,23 +72,21 @@ + + + + + + + + + + + + - - + +
{{'property' | translate}}{{'value' | translate }}
{{'subjects' | translate}} -
    -
  • {{uriLabels[subject]}} ({{subject}})
  • -
{{'themes' | translate}} -
    -
  • {{ uriLabels[theme] }} ({{theme}})
  • -
{{ 'issns' | translate }}
{{ 'isbns' | translate }}
{{'document code' | translate }}
{{'imprints' | translate}}
    -
  • -
      -
    • {{'City'|translate}} : {{ imprint.imprintCity }}
    • -
    • {{'Publisher'|translate}} : {{ imprint.publisher }}
    • -
    • {{'Date'|translate}} : {{ imprint.imprintDate }}
    • -
    • {{'Language'|translate}} : {{ imprint.lang }}
    • -
    - - -
  • -
- - -