X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/0dd00c51dfdbda93e1b9c4612477cd05109d4517..17ed87c493556adae66975e6cee1454b74e0c904:/src/redakcja/static/js/wiki/view_properties.js diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 63dd39de..204a4dec 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,52 @@ 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'); + } + + rdf = $("> [x-node='RDF']", self.$edited); + if (!rdf.length) { + rdf = $(""); + self.$edited.prepend(rdf); + self.$edited.prepend('\n '); + + } + rdfdesc = $("> [x-node='Description']", rdf); + if (!rdfdesc.length) { + rdfdesc = $(""); + rdf.prepend(rdfdesc); + rdf.prepend('\n '); + rdfdesc.append('\n '); + rdf.append('\n '); + } + span.appendTo(rdfdesc); + rdfdesc.append('\n '); + + 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')); }); @@ -121,10 +171,18 @@ PropertiesPerspective.prototype.edit = function(element) { let self = this; - let $node = $(element); $("#parents", self.$pane).empty(); $("#bubbles").empty(); + $f = $("#properties-form", self.$pane); + $f.empty(); + + if (element === null) { + self.$edited = null; + return; + } + + let $node = $(element); let b = $("
").text($node.attr('x-node')); b.data('node', element); $("#bubbles").append(b); @@ -143,32 +201,41 @@ node = $(element).attr('x-node'); $("h1", self.$pane).text(node); - $f = $("#properties-form", self.$pane); - $f.empty(); self.$edited = $(element); 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 = $("
"); + $("