X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ed7cd4d7271acd67bf366e4d320f9c49f07a50ea..fbedc8f26f2879a46629edc72ce20e3e85135523:/src/redakcja/static/js/wiki/view_properties.js?ds=sidebyside diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 3495197c..204a4dec 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -119,9 +119,24 @@ if (field.value_type.hasLanguage) { span.attr('x-a-xml-lang', 'pl'); } - span.appendTo( - $("> [x-node='RDF'] > [x-node='Description']", self.$edited) - ); + + 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); @@ -156,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); @@ -178,8 +201,6 @@ node = $(element).attr('x-node'); $("h1", self.$pane).text(node); - $f = $("#properties-form", self.$pane); - $f.empty(); self.$edited = $(element); let nodeDef = elementDefs[node]; @@ -252,7 +273,15 @@ } else { $aninput = $(""); if (field.value_type.autocomplete) { - $aninput.autocomplete(field.value_type.autocomplete); + let autoOptions = field.value_type.autocomplete; + $aninput.autocomplete(autoOptions).autocomplete('instance')._renderItem = function(ul, item) { + let t = item.label; + if (item.name) t += '
' + item.name + ''; + if (item.description) t += '
' + item.description + ''; + return $( "
  • " ) + .append( "
    " + t + "
    " ) + .appendTo( ul ); + }; } } $aninput.data('edited', $(element)) @@ -349,6 +378,16 @@ this.edit(p); } + PropertiesPerspective.prototype.onEnter = function(success, failure){ + var self = this; + $.wiki.SidebarPerspective.prototype.onEnter.call(this); + + if ($.wiki.activePerspective() != 'VisualPerspective') + $.wiki.switchToTab('#VisualPerspective'); + + self.edit($('[x-node="utwor"]')[0]); + }; + $.wiki.PropertiesPerspective = PropertiesPerspective; })(jQuery);