From: Radek Czajka Date: Thu, 7 Jul 2022 13:04:54 +0000 (+0200) Subject: Metadata editor X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/008b2c8d44987a6ef6b405ffc2124f28d3c6220d Metadata editor --- diff --git a/requirements/requirements.txt b/requirements/requirements.txt index a7a944ef..2d3966c4 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -10,10 +10,10 @@ python-slugify python-docx==0.8.10 Wikidata==0.6.1 -librarian==2.4.3 +librarian==2.4.4 ## Django -Django==3.2.12 +Django==3.2.14 fnpdjango==0.5 django-pipeline==2.0.7 django-cas-ng==4.3.0 diff --git a/src/redakcja/static/css/html.scss b/src/redakcja/static/css/html.scss index 0b9e9433..6d3d3c54 100644 --- a/src/redakcja/static/css/html.scss +++ b/src/redakcja/static/css/html.scss @@ -108,27 +108,27 @@ content: "\feff"; } -.htmlview .strofa .wers_wciety, .htmlview .strofa .wers_wciety[data-wlf-typ='1'] { +.htmlview .strofa .wers_wciety, .htmlview .strofa .wers_wciety[x-a-wl-typ='1'] { margin-left: 1em; } -.htmlview .strofa .wers_wciety[data-wlf-typ='2'], .htmlview .strofa .wers_cd { +.htmlview .strofa .wers_wciety[x-a-wl-typ='2'], .htmlview .strofa .wers_cd { margin-left: 2em; } -.htmlview .strofa .wers_wciety[data-wlf-typ='3'] { +.htmlview .strofa .wers_wciety[x-a-wl-typ='3'] { margin-left: 3em; } -.htmlview .strofa .wers_wciety[data-wlf-typ='4'] { +.htmlview .strofa .wers_wciety[x-a-wl-typ='4'] { margin-left: 4em; } -.htmlview .strofa .wers_wciety[data-wlf-typ='5'] { +.htmlview .strofa .wers_wciety[x-a-wl-typ='5'] { margin-left: 5em; } -.htmlview .strofa .wers_wciety[data-wlf-typ='6'] { +.htmlview .strofa .wers_wciety[x-a-wl-typ='6'] { margin-left: 6em; } diff --git a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js index 7baa00da..2f510a24 100644 --- a/src/redakcja/static/js/wiki/view_editor_wysiwyg.js +++ b/src/redakcja/static/js/wiki/view_editor_wysiwyg.js @@ -505,7 +505,7 @@ if($box.attr("x-edit-attribute")) { source = $(''); - source.text($box.attr("data-wlf-" + $box.attr("x-edit-attribute"))); + source.text($box.attr("x-a-wl-" + $box.attr("x-edit-attribute"))); source = source[0]; } else { source = $box[0]; diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 63dd39de..eeddf678 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -72,7 +72,11 @@ } if ($input.data("edited")) { - $input.data("edited").text(inputval); + if ($input.data("edited-attr")) { + $input.data("edited").attr($input.data("edited-attr"), inputval); + } else { + $input.data("edited").text(inputval); + } return; } @@ -102,6 +106,37 @@ self.$edited; }); + + self.$pane.on('click', '.meta-add', function() { + // create a metadata item + let $fg = $(this).parent(); + let ns = $fg.data('ns'); + let tag = $fg.data('tag'); + let field = $fg.data('field'); + let span = $(''); + span.attr('x-node', tag); + span.attr('x-ns', ns) + if (field.value_type.hasLanguage) { + span.attr('x-a-xml-lang', 'pl'); + } + span.appendTo( + $("> [x-node='RDF'] > [x-node='Description']", self.$edited) + ); + + self.displayMetaProperty($fg); + + return false; + }); + + self.$pane.on('click', '.meta-delete', function() { + let $fg = $(this).closest('.form-group'); + $('input', $fg).data('edited').remove(); + self.displayMetaProperty($fg); + return false; + }); + + + self.$pane.on('click', '.current-convert', function() { self.convert($(this).attr('data-to')); }); @@ -150,25 +185,36 @@ let nodeDef = elementDefs[node]; if (nodeDef && nodeDef.attributes) { $.each(nodeDef.attributes, function(i, a) { - self.addEditField(a, $(element).attr('data-wlf-' + a.name)); // ... + self.addEditField(a, $(element).attr('x-a-wl-' + a.name)); // ... }) } - // Only utwor can has matadata now. if (node == 'utwor') { - // Let's find all the metadata. - $("> [x-node='RDF'] > [x-node='Description'] > [x-node]", $node).each(function() { - $meta = $(this); - self.addEditField( - {"name": $meta.attr('x-node'),}, - $meta.text(), - $meta, - ); - }); - } + $('
').appendTo($("#properties-form", self.$pane)) + META_FIELDS.forEach(function(field) { + let $fg = $("
"); + $("