X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/5dbd487fb7e64aa968da9c3fcbe8a0215d2b3298..11135898543370ecf4ffa95dbea14cba4c33f57c:/src/redakcja/static/js/wiki/view_properties.js?ds=inline diff --git a/src/redakcja/static/js/wiki/view_properties.js b/src/redakcja/static/js/wiki/view_properties.js index 56bd84d3..7101c5cf 100644 --- a/src/redakcja/static/js/wiki/view_properties.js +++ b/src/redakcja/static/js/wiki/view_properties.js @@ -139,6 +139,9 @@ rdfdesc.append('\n '); rdf.append('\n '); } + if (field.filter && field.filter.startswith) { + span.text(field.filter.startswith[0]); + } span.appendTo(rdfdesc); rdfdesc.append('\n '); @@ -162,12 +165,17 @@ modal.data('target-input', input); var imglist = modal.find('.modal-body'); imglist.html(''); - $.each(self.doc.galleryImages, (i, imgItem) => { - img = $("").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() { - imglist.find('img').removeClass('active'); - $(this).addClass('active'); - }); - imglist.append(img); + + self.doc.refreshImageGallery({ + success: function(galleryImages) { + $.each(self.doc.galleryImages, (i, imgItem) => { + let img = $("").attr("src", imgItem.thumb).attr('title', imgItem.url).data('url', imgItem.url).on('click', function() { + imglist.find('img').removeClass('active'); + $(this).addClass('active'); + }); + imglist.append(img); + }); + } }); }) $('#media-chooser .ctrl-ok').on('click', function (event) { @@ -225,6 +233,7 @@ $.ajax({ url: field.value_type.chooser.source, + data: field.filter ? {'filter': JSON.stringify(field.filter)} : '', success: function(data) { add_options(body, data, input.val()); } @@ -379,6 +388,18 @@ // lang } + applyFilter(filter, text) { + if (filter.not) { + return !this.applyFilter(filter.not, text) + } else if (filter.startswith) { + for (prefix of filter.startswith) { + if (text.startsWith(prefix)) + return true; + } + return false; + } + } + displayMetaProperty($fg) { let self = this; let ns = $fg.data('ns'); @@ -393,6 +414,11 @@ selector += "[x-ns='"+ns+"']"; } $(selector, self.$edited).each(function() { + if (field.filter) { + let text = $(this).text(); + if (!self.applyFilter(field.filter, text)) + return; + } self.addMetaInput( $('.c', $fg), field,