FriendsOfREDAXO / yform_quick_edit

YForm QuickEdit
MIT License
17 stars 0 forks source link

Nicht mit geocode-Addon kompatibel #12

Open alxndr-w opened 1 year ago

alxndr-w commented 1 year ago

Description / Beschreibung Die Karte wird nicht angezeigt, wenn per Quick Edit das Formular eingeblendet wird.

eaCe commented 1 year ago

Ich habe das Addon noch nie genutzt, kannst du mir sagen wie ich das in YForm anzeige?

alxndr-w commented 1 year ago

Ich kanns dir mal per Screencast demonstrieren, ja.

eaCe commented 1 year ago

Zum debuggen wäre das schon gut selbst einzubauen. Können wir die Tage mal probieren

alxndr-w commented 1 year ago

Evtl. reicht's, das Adodn events von mir zu installieren. Da werden gleich passende Tablesets mitinstalliert

eaCe commented 1 year ago

Nein, da sehe ich zwar locations, aber finde nicht heraus wie ich eine Map angezeigt bekomme

eaCe commented 10 months ago

@alxndr-w ich habe hier aktuell keine API Key. Kannst du folgendes JS einfach mal testen:

$(document).one("rex:ready",function(){new QuickEdit});class QuickEdit{constructor(){this.ADD_CLASS=1,this.REMOVE_CLASS=2,this.activeId=null,this.activeRowSelector=null,this.qeId=null,this.$activeQuickEdit=null,this.$activeForm=null,this.$rexAjaxLoader=$("#rex-js-ajax-loader"),this.$fixedNavbar=$(".rex-nav-top-is-fixed"),this.attachEventHandler(),$(document).on("keyup",t=>{"Escape"===t.key&&this.closeQuickEdit()})}attachEventHandler(){let t=$("a.yform-quick-edit");t.off("click"),t.on("click",t=>{t.preventDefault();let i=$(t.currentTarget),e=i.data("id"),a=i.parents("tr"),s=a.find("td").length;if(this.showLoading(),this.activeId===e){this.closeQuickEdit(),this.hideLoading();return}this.activeId!==e&&(this.closeQuickEdit(),this.activeId=e,this.qeId="yform-quick-edit-"+(200*Math.random()).toString(36).replace(".",""),this.activeRowSelector="tr.quick-edit-row-"+this.activeId,this.changeActiveRowClass("active",this.ADD_CLASS),a.after('<tr><td style="padding: 0;" colspan="'+s+'"><div class="yqu-wrapper" id="'+this.qeId+'"></div></td></tr>'),this.showQuickEdit(i.attr("href"),a))})}showQuickEdit(t,i){this.showLoading(),$.pjax({url:t,container:"#"+this.qeId,fragment:"#rex-yform",push:!1}),this.$activeQuickEdit=$("#"+this.qeId),this.$activeQuickEdit.on("pjax:end",()=>{this.$activeForm=this.$activeQuickEdit.find("form.rex-yform"),this.attachSubmitHandler(),this.initializeSctipts();let t=i.offset().top;this.$fixedNavbar.length&&(t-=this.$fixedNavbar.height()),$(window).scrollTop(t)}),this.$activeQuickEdit.on("pjax:beforeReplace",(t,i)=>{let e=$(i);e.find(".yqe-ignore").each((t,i)=>{let e=$(i),a=e.closest(".form-group, .form-check-group");a.length?a.remove():e.remove()}),e.find(".btn-toolbar").append('<a href="#" class="btn btn-danger" id="yqe-cancel">'+rex.yform_quick_edit_cancel+"</a>");let a=e.find("#yqe-cancel");a.on("click",t=>{t.preventDefault(),this.closeQuickEdit()})})}attachSubmitHandler(){this.$activeForm.on("submit",t=>{if(t.preventDefault(),"undefined"!=typeof ckeditors)for(let i in ckeditors)ckeditors[i].updateSourceElement();$.ajax({type:"post",url:this.$activeForm.attr("action"),data:this.$activeForm.serialize(),success:t=>{let i=$(t),e=i.find("form.rex-yform .form-group.has-error"),a=this.$activeForm.find(".alert-danger"),s=i.find("form.rex-yform .alert-danger");e.length?($(".has-error").removeClass("has-error"),this.addError(),e.each((t,i)=>{let e=$(i);this.$activeForm.find("#"+e.attr("id")).addClass("has-error")}),a.length?a.replaceWith(s):this.$activeForm.prepend(s)):this.success=!0},error(t){console.error("YForm QuickEdit","  ↴","\n",t)},complete:()=>{this.hideLoading(),this.success&&this.closeQuickEdit(!0)}})})}initializeSctipts(){"function"==typeof rex_geo_coder&&setTimeout(()=>{rex_geo_coder()},300)}closeQuickEdit(t){this.$activeQuickEdit&&(this.removeQuickEdit(),this.changeActiveRowClass("active",this.REMOVE_CLASS),this.changeActiveRowClass("error",this.REMOVE_CLASS),t?$.get(window.location.href,t=>{let i=$(t).find(this.activeRowSelector+" > *"),e=$(this.activeRowSelector+" > *");for(let a=0;a<i.length;a++){let s=e.eq(a),r=$(s.html());try{if("a"===r.prop("nodeName").toLowerCase()||s.hasClass("rex-table-action"))continue}catch(c){}s.html(i.eq(a).html())}this.resetQuickEdit()}):this.resetQuickEdit())}removeQuickEdit(){this.$activeQuickEdit&&this.$activeQuickEdit.parents("tr").remove()}resetQuickEdit(){this.activeId=null,this.activeRowSelector=null,this.$activeForm=null,this.$activeQuickEdit=null}addError(){this.changeActiveRowClass("error",this.ADD_CLASS)}changeActiveRowClass(t,i){i===this.ADD_CLASS?$(this.activeRowSelector).addClass(t):i===this.REMOVE_CLASS&&$(this.activeRowSelector).removeClass(t)}showLoading(){this.$rexAjaxLoader.addClass("rex-visible")}hideLoading(){this.$rexAjaxLoader.removeClass("rex-visible")}}

Einfach mal in die scripts.js vom Addon packen

eaCe commented 10 months ago

@alxndr-w magst du das vielleicht einmal testen?

alxndr-w commented 10 months ago

Uncaught SyntaxError: Identifier 'QuickEdit' has already been declared

Ich kann dir aber einen API-Key anbieten.

eaCe commented 10 months ago

Schade eigentlich :D Ich schau noch mal rein, danke