File manager - Edit - /home/gzbnyc5/pty-app/realstate/public/js/pty.v2.admin.listings.table.js
Back
const tableColumnTemplateOverride = { images: function (row, index, datatable) { let photosHtml = ""; if (row.images) { let photos = []; try { photos = JSON.parse(row.images); if (photos.length == 0) { return photosHtml; } } catch (error) {} const $imageLightBox = $("<div/>", { class: "pty-row-image-lightbox", style: "display: none;", }); for (const photo of photos) { const $imgLB = $("<a/>", { href: "/images/properties/" + photo, "data-lightbox": "pty-lightbox-" + row.id, }); $imageLightBox.append($imgLB); } const $img = $("<img/>", { src: "/images/properties/" + photos[0], "data-test": 1, }); photosHtml = $("<div/>", { class: "pty-row-listing-image", }) .append($img) .append($imageLightBox)[0].outerHTML; } return photosHtml; }, reference: function (row, index, datatable) { const title = `<h4>${row.street}</h4>`; const fee = row.fee == "Y" ? "<strong>Fee</strong>" : "<strong>No fee</strong>"; const apt = `<div><strong>Apt #:</strong> ${row.apt}</div>`; const beds = `<div><strong>Beds:</strong> ${roundNumber( row.beds, 0 )} | ${fee}</div>`; const price = `<div><strong>Price:</strong> $ ${formatNumber( row.price, 2 )}</div>`; const listingId = `<div><strong>Listing ID:</strong> ${row.mls_id}</div>`; const row1 = `<div class="pty-flex-50 pty-strong-bolder">${ apt + beds }</div>`; const row2 = `<div class="pty-flex-50 pty-strong-bolder">${ price + listingId }</div>`; return title + row1 + row2; }, feeds: function (row, index, datatable) { const rhClass = `btn btn-${ row.in_xml_1 == "Y" ? "primary" : "secondary" } m-2`; const zprClass = `btn btn-${ row.in_xml_3 == "Y" ? "primary" : "secondary" } m-2`; const rh = `<button data-kt-table-row-action="feed_1" class="${rhClass}" data-record-id="${row.recordID}">RH</button>`; const zpr = `<button data-kt-table-row-action="feed_3" class="${zprClass}" data-record-id="${row.recordID}">ZPR</button>`; return rh + zpr; }, }; const tableRowActionTemplateOverride = { "send-link": function (row) { return `<!--begin::Claim Item--> <button class="btn btn-icon btn-active-light-primary w-30px h-30px" data-kt-table-row-action="send-link" data-record-id="${row.recordID}"> <span class="svg-icon svg-icon-3"> ${SvgIcons.mail} </span> <!--end::Svg Icon--> </button> <!--end::Claim Item-->`; }, preview: function (row) { return `<!--begin::Claim Item--> <button class="btn btn-icon btn-active-light-primary w-30px h-30px" data-kt-table-row-action="preview" data-record-id="${row.recordID}"> <span class="svg-icon svg-icon-3"> ${SvgIcons.size} </span> <!--end::Svg Icon--> </button> <!--end::Claim Item-->`; }, "copy-link": function (row) { return `<!--begin::Claim Item--> <button class="btn btn-icon btn-active-light-primary w-30px h-30px" data-kt-table-row-action="copy-link" data-record-id="${row.recordID}"> <span class="svg-icon svg-icon-3"> ${SvgIcons.clipboardList} </span> <!--end::Svg Icon--> </button> <!--end::Claim Item-->`; }, feature: function (row) { const className = row.is_featured === "Y" ? "svg-icon-primary" : ""; return `<!--begin::Claim Item--> <button class="btn btn-icon btn-active-light-primary w-30px h-30px" data-kt-table-row-action="feature" data-record-id="${row.recordID}"> <span class="svg-icon svg-icon-3 ${className}"> ${SvgIcons.star} </span> <!--end::Svg Icon--> </button> <!--end::Claim Item-->`; }, "quick-edit": function (row) { return `<!--begin::Claim Item--> <button class="btn btn-icon btn-active-light-primary w-30px h-30px" data-kt-table-row-action="quick-edit" data-record-id="${row.recordID}"> <span class="svg-icon svg-icon-3"> ${SvgIcons.bulletList} </span> <!--end::Svg Icon--> </button> <!--end::Claim Item-->`; }, }; const tableRowTemplateOverride = function (row, data, dataIndex) { if ( data.claimed_by_user_id && Number(data.claimed_by_user_id) === globalConsts.userID ) { $(row).addClass("pty-row-important"); } }; const PtyListingService = (function () { let $table; let modalPreview; let modalQuickEdit; let modalSendLinks; let rowData; const initLightBox = function () { $table.DataTable().on("draw", function () { $.getScript(lightBoxScriptURL); }); $(document).on("click", ".pty-row-listing-image", function () { $(this).find("a:eq(0)").click(); }); }; const btnActionCopyLink = function (e) { rowData = getDataFromDataTable(this, $table); copyTextToClipboard(viewUrls["front-url"] + rowData.alias); e.preventDefault(); }; const btnActionPreview = function () { var iframe = modalPreview.find(".modal-body iframe"); rowData = getDataFromDataTable(this, $table); iframe.attr("src", viewUrls["front-url"] + rowData.alias); modalPreview.modal("show"); }; const btnActionPreviewOpen = function () { window.open(viewUrls["front-url"] + rowData.alias, "_blank"); }; const btnActionFeature = function () { rowData = getDataFromDataTable(this, $table); const isFeature = rowData.is_featured === "Y" ? "N" : "Y"; $.ajax({ url: viewUrls["row-options"], data: { ids: [rowData.recordID], option: "featured", new_value: isFeature, }, method: "POST", dataType: "JSON", success: function (data) { if (data.error === 0) { $table.DataTable().draw(); } }, }); }; const btnActionQuickEdit = function () { rowData = getDataFromDataTable(this, $table); const beds = isNaN(rowData.beds) ? 0 : Number(rowData.beds); setValueToElement("#apt", rowData.apt, true); setValueToElement("#fee", rowData.fee, true); setValueToElement("#price", formatNumber(rowData.price), true); setValueToElement("#beds", beds, true); modalQuickEdit.modal("show"); }; const btnActionSendLink = function () { let html = "<p>Hello,</p>"; KTAppEditor.setValue( Quill.find(document.getElementById("kt_form_editor_email_body")), html ); modalSendLinks.modal("show"); }; const initOnLayoutUpdate = function () {}; const initRowOptions = function () { $(document).on( "click", '[data-kt-table-row-action="preview"]', btnActionPreview ); $("#kt_modal_listings_preview_open").click(btnActionPreviewOpen); $(document).on( "click", '[data-kt-table-row-action="copy-link"]', btnActionCopyLink ); $(document).on( "click", '[data-kt-table-row-action="feature"]', btnActionFeature ); $(document).on( "click", '[data-kt-table-row-action="quick-edit"]', btnActionQuickEdit ); $(document).on( "click", '[data-kt-table-row-action="send-link"]', btnActionSendLink ); }; const initQuickEditModal = function () { $("#opToGzb, #cpToGzb").on("change", function () { const amountInput = $(`#${$(this).attr("id")}Amount`); if (this.value == "Full") { amountInput.val(rowData.final_gross); } else { amountInput.val(0.0); } }); $("#kt_modal_listings_quick_edit_submit").click(function (e) { e.preventDefault(); const beds = getValueFromElement("#beds"); const price = stringToNumber(getValueFromElement("#price")); const apt = getValueFromElement("#apt"); const fee = getValueFromElement("#fee"); $.ajax({ url: viewUrls["quick-edit"], data: { id: rowData.recordID, beds, price, apt, fee, }, method: "POST", dataType: "JSON", success: function (data) { if (data.error == 0) { modalQuickEdit.modal("hide"); KTDatatablesServerSide.refreshTable(); } else { swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); } }, error: function (data) { swal.fire({ text: "Sorry, looks like there are some errors detected, please try again.", icon: "error", buttonsStyling: false, confirmButtonText: "Ok, got it!", customClass: { confirmButton: "btn fw-bold btn-light-primary", }, }); }, }); }); }; return { init: function () { $table = $("table#kt_table_my_listings"); modalPreview = $("#kt_modal_listings_preview"); modalQuickEdit = $("#kt_modal_listings_quick_edit"); modalSendLinks = $("#kt_modal_listings_send_links"); initLightBox(); initRowOptions(); initQuickEditModal(); }, }; })();
| ver. 1.4 |
Github
|
.
| PHP 8.2.31 | Generation time: 0 |
proxy
|
phpinfo
|
Settings