Showcase: Dynamic ServerConnect.load(), Dynamic Modal Proloader, Dynamic Modal Confirmation

Hey guys,

Thanks to Wappler I completed my first very complicated project (for my standards/knowledge) and I’m very happy about it.
Thank you all for everything you have tαught me and THANK YOU WAPPLER!

Now, the only part missing from my project is a page where I will be able to permanently delete the records οff all the tables used in my project (the most deletions that are done in my app are just “flaged” as DELETED records and this way exclude them form my queries).
Of course it will be a page strictly used only by the administrator/me.

So, the last couple of days I’m trying to find a way to deal with it dynamically.
With the little knowlwdge I have gotten in this community, I got it solved and I would like to share it with you.
(At the end of my post I have the code for the whole page)

A) I have a main variable (var_Sel_Table) that holds the selected table.
<dmx-value id="var_Sel_Table"></dmx-value>

B) I have a main Button Group (selectedGroup) that selects the table in which I want to work on (delete records).
This is a Button Group with 6 nested radio groups, tatal 18 buttons (tables). On clicking of any button the selectedGroup gets the value of the radio label (which value in purpose I have set it to the name of the table and the serverConnects that I have to load, see next steps)

<div id="selectedGroup" class="d-flex flex-wrap btn-group gap-2 px-0" role="group" is="dmx-radio-group" aria-label="Tables Group" dmx-on:updated.debounce:50="run({condition:{if:`selectedGroup.value`,then:{steps:[{run:{action:`var_Sel_Table.setValue(value)`,outputType:'text'}},{runJS:{function:'loadSelTable',args:[`var_Sel_Table.value`],name:'loadSelTable',outputType:'text'}},{condition:{if:`var_Sel_Table.value`,then:{steps:{run:{action:`modal_Loader.show()`,outputType:'text'}}},outputType:'boolean'}}]},outputType:'boolean'}})">
                        <div class="d-flex px-2 mb-1 flex-wrap align-content-start flex-column">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-danger rounded-top border-top border-start border-end border-danger border-2 fst-italic small shadow-sm">Orders:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option1" value="Orders" autocomplete="off">
                                <label class="btn btn-danger text-white lh-sm border border-dark rounded" for="option1">Orders</label>

                                <input type="radio" class="btn-check" name="options" id="option2" value="Shipments" autocomplete="off">
                                <label class="btn btn-danger text-white lh-sm border border-dark rounded" for="option2">Shipments</label>

                            </div>
                        </div>

What happens onUpdate of the Button Group:

  1. Assign the value of the selectedGroup to the variable var_Sel_Table,
  2. call the loadSelTable javascript function and pass the var_Sel_Table.value to it in order to load the according serverConnect
function loadSelTable(tbl) {
   // if condition prevents trigger on buttonGroup initialization
   if(tbl) {            
      dmx.parse("srvc_Del" + tbl + ".load()");
   }
}
  1. Show the modal_Loader (the preloader modal)
    1_modal_Loader picture

Every ServerConnect that loads a table has a success event to hide the modal_Loader (the preloader modal) <dmx-serverconnect id="srvc_DelOrders" url="dmxConnect/api/admin/deletions/orders/getOrders.php" noload="true" dmx-on:success="modal_Loader.hide()"></dmx-serverconnect>

  1. Call the modal_Loader.show() (the dynamic preloader for all the serverconnects)

the Loading table name is shown based on the var_Sel_Table,value
<p class="mb-0 text-muted position-absolute top-0 start-50 translate-middle w-auto text-nowrap lh-1 txt-shadow-black fw-light" style="margin-top: -15px;" dmx-text="'Loading '+var_Sel_Table.value+'...'">Loading...</p>

C) All the tableRepeats that keep the data of my tables, are in columns with a conditional region in all of them in order not to render if they are not selected
<div class="col-12 mb-2 px-2 h-100" id="conditionalOrders" is="dmx-if" dmx-bind:condition="var_Sel_Table.value=='Orders'">

D) I created an AppFLow (pass_params.jsom) in order to pass the parameters/values that I need to the modal_ConfirmDel to describe what is deleted (see next steps)


In this AppFlow I:

  1. Add an array $param (inp_params) with a variable p_name. In this array we can assign as many fields we need and their values (see next steps)
  2. Add a repeat based on the inp_params and inside it I assigned 2 vars AND ENABLE OUTPUT for both of them:
  • param_name (hold the name of the parameter, Caption)
  • param_value (holds the value for the param_name)

E) So, on click of a table’s record btn-Delete, I run a flow:


In this flow I:

  1. Call the pass_params.jsom AppFlow and pass the parameters I need to be shown in modal_ConfirmDel (I can pass as many and whatever parameters I need for each table)
  2. Assign to the modal_Confirm 2 hidden inputs the values (rec_name and rec_id) of the current tableRepeat’s record that was clicked. This is used when I call the delete ServerConnect (the column name and its value).
  3. Ass a wait 100ms in order the AppFlow to be completed when the modal_ConfirmDel is shown in the next step (maybe we can go less than 100…)
  4. Show the modal_ConfirmDel (Delete Conformation Modal for all the tables)

F) Now, the modal_ConfirmDel is shown and waits for a confirmation to Delete the specific record:


Inside this modal we have a formrepeat based on the AppFlow paramsRepeat (the array with the necessary Caption/Value pairs) <div is="dmx-form-repeat" id="delDetailsRepeat" class="rounded bg-white" dmx-bind:items="flow_PassParams.data.repeatParams">
2) Inside the repat I added 2 paragraphs and assigned the param_name and param_value values.

G) On click of the Conirmation button:


Here I call a flow and add a Run Javascript step. I call the deleteSelRecord function and pass 3 arquments:

  • the var_Sel_Table.value (in order to call the according serverConnect)
  • the 2 hidden inputs that we assigned here back in step E2

H) I have assigned the same exactly success event for all the delete serveractions:

  1. hide the modal_ConfirmDel
  2. Show a Success Notification var_Sel_Table.value.toString().substr(0, var_Sel_Table.value.toString().length()-1)+' #'+modal_ConfirmDel.rec_id.value+' has been Deleted'
  3. reLoad the serverConnect . This can be done with the step B2 (haven’t apllied yet by the time writing this post))

That’s it

I will add the whole page code in next post and a small demo video

This is for a backend admin page and a security rescrict for Admin only is applied:

  • On The page itseld
  • On All the serverConnects***

*Unfortunatelly it is an admin backend web app handling orders, clients, products etc and it is restricted to registered users/administrator only so there is no way for you to visit and examine it.

Any advisements, corrections or improvements are most welcome!!

Thanks for reading,
Wish you all health, happyness & success!!

Here is all the page code (with only 2 of 18 tables demonstrated):

<?php
require('dmxConnectLib/dmxConnect.php');

$app = new \lib\App();

$app->exec(<<<'JSON'
{
	"steps": [
		"Connections/conn_stock",
		"SecurityProviders/security",
		{
			"module": "auth",
			"action": "restrict",
			"options": {"permissions":"Administrator","loginUrl":"login.php","forbiddenUrl":"index.php","provider":"security"}
		}
	]
}
JSON
, TRUE);
?>
<!doctype html>
<html is="dmx-app">

<head>
    <script src="dmxAppConnect/dmxAppConnect.js"></script>
    <meta charset="UTF-8">
    <title>Deletions</title>

    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.14.0/css/all.css" integrity="sha384-HzLeBuhoNPvSl5KYnjx0BT+WB0QEEqLprO+NBkkk5gbc67FTaL7XIGa2w1L0Xbgc" crossorigin="anonymous" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="bootstrap/5/css/bootstrap.min.css" />
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="css/style.css" />
    <script src="dmxAppConnect/dmxScheduler/dmxScheduler.js" defer></script>
    <script src="dmxAppConnect/dmxBootstrap5Navigation/dmxBootstrap5Navigation.js" defer></script>
    <script src="dmxAppConnect/dmxBrowser/dmxBrowser.js" defer></script>
    <link rel="stylesheet" href="dmxAppConnect/dmxNotifications/dmxNotifications.css" />
    <script src="dmxAppConnect/dmxNotifications/dmxNotifications.js" defer></script>
    <script src="dmxAppConnect/dmxDataTraversal/dmxDataTraversal.js" defer></script>
    <script src="dmxAppConnect/dmxFormatter/dmxFormatter.js" defer></script>
    <link rel="stylesheet" href="dmxAppConnect/dmxBootstrap5TableGenerator/dmxBootstrap5TableGenerator.css" />
    <script src="dmxAppConnect/dmxBootstrap5Modal/dmxBootstrap5Modal.js" defer></script>
    <link rel="stylesheet" href="dmxAppConnect/dmxValidator/dmxValidator.css" />
    <script src="dmxAppConnect/dmxValidator/dmxValidator.js" defer></script>
    <script src="dmxAppConnect/dmxBootbox5/bootstrap-modbox.min.js" defer></script>
    <script src="dmxAppConnect/dmxBootbox5/dmxBootbox5.js" defer></script>
    <link rel="stylesheet" href="dmxAppConnect/dmxPreloader/dmxPreloader.css" />
    <script src="dmxAppConnect/dmxPreloader/dmxPreloader.js" defer></script>
    <link rel="stylesheet" href="dmxAppConnect/dmxAnimateCSS/animate.min.css" />
    <script src="dmxAppConnect/dmxAnimateCSS/dmxAnimateCSS.js" defer></script>
    <script src="dmxAppConnect/dmxBootstrap5Toasts/dmxBootstrap5Toasts.js" defer></script>
    <script src="dmxAppConnect/dmxFormRepeat/dmxFormRepeat.js" defer></script>
</head>

<body id="Deletions">
    <script is="dmx-flow" id="flow_PassParams" type="text/dmx-flow" src="app/flows/pass_params.json"></script>

    <dmx-preloader id="preloaderPage" color="#dc3545" spinner="fadingCircle"></dmx-preloader>

    <dmx-notifications id="notifies1" opacity="1"></dmx-notifications>
    <div is="dmx-browser" id="browser1"></div>

    <dmx-serverconnect id="srvc_DelOrders" url="dmxConnect/api/admin/deletions/orders/getOrders.php" noload="true" dmx-on:success="modal_Loader.hide()"></dmx-serverconnect>
    <dmx-serverconnect id="srvc_permDeleteOrders" url="dmxConnect/api/admin/deletions/orders/permDeleteOrder.php" noload="true" dmx-on:success="run([{run:{action:`modal_ConfirmDel.hide()`,outputType:'text'}},{run:{action:`notifies1.success(var_Sel_Table.value.toString().substr(0, var_Sel_Table.value.toString().length()-1)+\' #\'+modal_ConfirmDel.rec_id.value+\' has been Deleted\')`,outputType:'text'}},{runJS:{function:'loadSelTable',args:[`var_Sel_Table.value`],name:'loadSelTable',outputType:'text'}}])"></dmx-serverconnect>

    <dmx-serverconnect id="srvc_DelShipments" url="dmxConnect/api/admin/deletions/shipments/getShipments.php" noload="true" dmx-on:success="modal_Loader.hide()"></dmx-serverconnect>
    <dmx-serverconnect id="srvc_permDeleteShipments" url="dmxConnect/api/admin/deletions/shipments/permDeleteShipment.php" noload="true" dmx-on:success="run([{run:{action:`modal_ConfirmDel.hide()`,outputType:'text'}},{run:{action:`notifies1.success(var_Sel_Table.value.toString().substr(0, var_Sel_Table.value.toString().length()-1)+\' #\'+modal_ConfirmDel.rec_id.value+\' has been Deleted\')`,outputType:'text'}},{runJS:{function:'loadSelTable',args:[`var_Sel_Table.value`],name:'loadSelTable',outputType:'text'}}])"></dmx-serverconnect>

    <div class="modal" id="modal_Loader" is="dmx-bs5-modal" tabindex="-1">
        <div class="modal-dialog modal-fullscreen" role="document">
            <div class="modal-content">
                <div class="modal-header lh-lg py-0 bg-primary">
                    <span class="fs-4 lh-base me-auto ms-3 p-1 lead text-white fw-bold txt-shadow-black">StorM</span>
                </div>
                <div class="modal-body p-0 mh-100">
                    <dmx-value id="var_LoadingProgress" dmx-bind:value="srvc_DelOrders.downloadProgress.percent"></dmx-value>
                    <div class="d-flex align-items-center w-100 justify-content-center flex-column fw-bold text-primarymh-100">
                        <div class="d-flex position-absolute top-50 translate-middle flex-column">
                            <p class="mb-0 text-muted position-absolute top-0 start-50 translate-middle w-auto text-nowrap lh-1 txt-shadow-black fw-light" style="margin-top: -15px;" dmx-text="'Loading '+var_Sel_Table.value+'...'">Loading...</p>
                            <i class="fas fa-circle-notch fa-spin fa-3x text-primary txt-shadow-black bg-secondar rounded-circle"></i>
                            <p class="mb-0 text-primary position-absolute top-100 start-50 translate-middle w-auto text-nowrap lh-1 txt-shadow-black fw-light small" style="margin-top: 15px;">Please wait...</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal" id="modal_ConfirmDel" is="dmx-bs5-modal" tabindex="-1">
        <div class="modal-dialog modal-fullscreen-sm-down" role="document">
            <div class="modal-content">
                <div class="modal-header lh-lg py-0 bg-danger">
                    <h6 class="lh-base me-auto mb-0 lh-lg lead text-white fw-bold txt-shadow-black">DELETE RECORD</h6>
                    <button type="button" class="btn-close bg-white rounded" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body pt-0 pb-2 px-2 mh-100 bg-dark">
                    <h6 class="mb-0 p-2 ps-2 w-auto text-nowrap lh-1 txt-shadow-black text-white">You're about to Delete:</h6>

                    <div is="dmx-form-repeat" id="delDetailsRepeat" class="rounded bg-white" dmx-bind:items="flow_PassParams.data.repeatParams">
                        <div class="row g-0 px-2 py-2">
                            <div class="col-auto px-1">
                                <p class="mb-0 fw-light lh-1" dmx-text="param_name+': '" id="Record_Caption">Caption:</p>
                            </div>
                            <div class="col px-1">
                                <p class="mb-0 text-danger fw-bold lh-1" dmx-text="param_value" id="Record_Value">Value</p>
                            </div>
                        </div>
                    </div>
                    <div class="d-flex align-items-center w-100 justify-content-center flex-column fw-bold text-primarymh-100">
                        <div class="d-flex flex-column">

                            <h4 class="my-3  w-auto text-nowrap lh-1 txt-shadow-black text-danger fw-bold">Are you sure?</h4>
                        </div>
                    </div>
                </div>
                <input id="rec_id" name="rec_id" class="form-control" type="hidden">
                <input id="rec_name" name="rec_name" class="form-control" type="hidden">
                <div class="modal-footer justify-content-between py-1">
                    <button type="button" class="btn btn-secondary border-dark shadow" data-bs-dismiss="modal">No, Cancel</button>
                    <button class="btn btn-danger border-dark shadow" dmx-on:click="run({runJS:{function:'deleteSelRecord',args:[`var_Sel_Table.value`,`rec_id.value`,`rec_name.value`],outputType:'text'}})">YES, DELETE</button>
                </div>
            </div>
        </div>
    </div>

    <?php include 'inc_header.php'; ?><main class="mh-100">
        <div class="container-fluid">
            <div class="row mt-4">
                <div class="col">
                    <h1 class="h3 text-uppercase">DELETE RECORDS (PERMANENT)</h1>
                </div>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row mt-4">
                <div class="pb-2 pt-1 px-0 col border-top small border-1 border-danger shadow-sm">
                    <div class="col-12 mt-0 position-relative py-1 mb-1 text-center border-bottom fw-normal border-light text-dark bg-white lh-1 fst-italic small">
                        <small class="position-absolute start-0 rounded-pill py-1 px-3 bg-primary text-light border border-danger shadow-sm" style="margin-top: -20px; margin-left: 10px;">Actions</small>
                    </div>
                    <a id="btn_newClient" class="btn btn-danger btn-sm border mt-0 ms-1 rounded shadow-sm" href="javascript:void(0);" data-bs-toggle="modal" data-bs-target="#modal_createSeason">An action here</a>

                </div>
            </div>
        </div>
        <div class="mt-4 pb- container-fluid h-100">
            <div class="row mb-3">

                <div class="col-12 py-2 px-0">
                    <div id="selectedGroup" class="d-flex flex-wrap btn-group gap-2 px-0" role="group" is="dmx-radio-group" aria-label="Tables Group" dmx-on:updated.debounce:50="run({condition:{if:`selectedGroup.value`,then:{steps:[{run:{action:`var_Sel_Table.setValue(value)`,outputType:'text'}},{runJS:{function:'loadSelTable',args:[`var_Sel_Table.value`],name:'loadSelTable',outputType:'text'}},{condition:{if:`var_Sel_Table.value`,then:{steps:{run:{action:`modal_Loader.show()`,outputType:'text'}}},outputType:'boolean'}}]},outputType:'boolean'}})">
                        <div class="d-flex px-2 mb-1 flex-wrap align-content-start flex-column">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-danger rounded-top border-top border-start border-end border-danger border-2 fst-italic small shadow-sm">Orders:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option1" value="Orders" autocomplete="off">
                                <label class="btn btn-danger text-white lh-sm border border-dark rounded" for="option1">Orders</label>

                                <input type="radio" class="btn-check" name="options" id="option2" value="Shipments" autocomplete="off">
                                <label class="btn btn-danger text-white lh-sm border border-dark rounded" for="option2">Shipments</label>

                            </div>
                        </div>
                        <div class="d-flex px-2 mb-1 flex-column flex-wrap w-auto align-content-start">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-info rounded-top border-top border-start border-end border-info border-2 fst-italic small shadow-sm">Products:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option3" value="Products" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option3">Products</label>

                                <input type="radio" class="btn-check" name="options" id="option4" value="Categories" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option4">Categories</label>

                                <input type="radio" class="btn-check" name="options" id="option5" value="Groups" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option5">Groups</label>

                                <input type="radio" class="btn-check" name="options" id="option6" value="Units" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option6">Units</label>

                                <input type="radio" class="btn-check" name="options" id="option7" value="Vatiations" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option7">Vatiations</label>

                                <input type="radio" class="btn-check" name="options" id="option8" value="Tags" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option8">Tags</label>

                                <input type="radio" class="btn-check" name="options" id="option9" value="Temp_Products" autocomplete="off">
                                <label class="btn btn-info text-white lh-sm border border-dark rounded" for="option9">Temp_Products</label>

                            </div>

                        </div>
                        <div class="d-flex px-2 mb-1 flex-column flex-wrap align-content-start w-auto">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-success rounded-top border-top border-start border-end border-success border-2 fst-italic small shadow-sm">Clients:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option10" value="Clients" autocomplete="off">
                                <label class="btn btn-success text-white lh-sm border border-dark rounded" for="option10">Clients</label>

                                <input type="radio" class="btn-check" name="options" id="option11" value="Payments" autocomplete="off">
                                <label class="btn btn-success text-white lh-sm border border-dark rounded" for="option11">Payments</label>

                                <input type="radio" class="btn-check" name="options" id="option12" value="Destinations" autocomplete="off">
                                <label class="btn btn-success text-white lh-sm border border-dark rounded" for="option12">Destinations</label>

                                <input type="radio" class="btn-check" name="options" id="option13" value="Tax_Details" autocomplete="off">
                                <label class="btn btn-success text-white lh-sm border border-dark rounded" for="option13">Tax_Details</label>

                                <input type="radio" class="btn-check" name="options" id="option14" value="Agents" autocomplete="off">
                                <label class="btn btn-success text-white lh-sm border border-dark rounded" for="option14">AGENTS</label>
                            </div>
                        </div>
                        <div class="d-flex px-2 mb-1 flex-wrap align-content-start flex-column">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-muted rounded-top border-top border-start border-end border-warning border-2 fst-italic small shadow-sm">Users:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option15" value="Users" autocomplete="off">
                                <label class="btn btn-warning text-dark lh-sm border border-dark rounded" for="option15">Users</label>

                                <input type="radio" class="btn-check" name="options" id="option16" value="Registartions" autocomplete="off">
                                <label class="btn btn-warning text-dark lh-sm border border-dark rounded" for="option16">Registartions</label>

                            </div>

                        </div>
                        <div class="d-flex px-2 mb-1 flex-wrap align-content-start flex-column">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-muted rounded-top border-top border-start border-end border-primary border-2 fst-italic small shadow-sm">Pages:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option17" value="Pages" autocomplete="off">
                                <label class="btn btn-primary text-white lh-sm border border-dark rounded" for="option17">Pages</label>

                            </div>

                        </div>
                        <div class="d-flex px-2 mb-1 flex-wrap align-content-start flex-column">
                            <div class="d-flex">
                                <p class="ms-1 mb-0 lh-sm fw-bol px-1 txt-shadow-black text-muted rounded-top border-top border-start border-end border-dark border-2 fst-italic small shadow-sm">Notifications:</p>
                            </div>
                            <div class="d-flex bg-white rounded border border-dark flex-row flex-wrap shadow justify-content-center" style="padding: 2px;">
                                <input type="radio" class="btn-check" name="options" id="option18" value="Notifications" autocomplete="off">
                                <label class="btn btn-secondary text-dark lh-sm border border-primary rounded" for="option18">Notifications</label>

                            </div>

                        </div>
                    </div>

                </div>
            </div>

            <div class="row bg-danger bg-opacity-50 h-100" dmx-show="var_Sel_Table.value">
                <dmx-value id="var_Sel_Table"></dmx-value>

                <div class="col-12 p-0 mb-4 shadow">
                    <h5 class="fw-bold txt-shadow-black px-3 lh-lg mb-0 border-2 border-top border-bottom border-dark text-light bg-dark bg-opacity-50">Selected Table:</h5>
                </div>
                <div class="col-12 mb-2 px-2 h-100" id="conditionalOrders" is="dmx-if" dmx-bind:condition="var_Sel_Table.value=='Orders'">
                    <div class="card shadow rounded mb-4 pb-0 bg-white border border-secondary" style="overflow: hidden;">
                        <div class="card-header p-0 ps-3 fw-bold bg-secondary text-uppercase border-2 border-bottom rounded-0 border-dark lh-lg text-dark">ORDERS</div>
                        <div class="card-body px-1 py-1 bg-white">
                            <div class="row h-100 align-items-lg-end g-0 pb-2">
                                <div class="table-responsive">
                                    <table class="table table-hover table-bordered table-sm border-primary">
                                        <thead class="small">
                                            <tr class="text-center bg-secondary bg-opacity-50 text-dark align-bottom lh-1">
                                                <th class="py-0">
                                                    <button id="btn_DelSeasonHeader" class="btn btn-sm m-0 text-dark disabled">
                                                        <i class="far fa-trash-alt fa-fw"></i>
                                                    </button>
                                                </th>
                                                <th>ID</th>
                                                <th>Client Name</th>
                                                <th>Order Date</th>
                                                <th>Total Amount</th>
                                                <th class="text-break">Sent to production</th>
                                                <th>Status</th>
                                                <th>Deleted</th>
                                            </tr>
                                        </thead>
                                        <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="srvc_DelOrders.data.qr_Del_getOrders" id="ordersRepeat" class="small">
                                            <tr class="text-center align-middle bg-opacity-10 py-0 lh-sm" dmx-class:bg-danger="ord_Deleted==1" dmx-class:bg-dark="ord_Status=='CANCELED'">
                                                <td class="py-0">
                                                    <form id="frm_DelOrders" is="dmx-serverconnect-form" method="post" action="dmxConnect/api/admin/deletions/orders/permDeleteOrder.php" dmx-on:success="notifies1.success('ORDER WAS DELETED ');srvc_DelOrders.load({})">
                                                        <input id="del_order_id" name="del_order_id" type="hidden" class="form-control" required="" dmx-bind:value="ord_id">
                                                        <button id="btn_DelOrder" title="Permanent Delete" class="btn m-0 btn-outline-danger bg-dark btn-sm" dmx-on:click="run([{run:{action:`flow_PassParams.run({inp_params: [{p_name: \'Order\', value: ord_id}, {p_name: \'Client\', value: cln_Name}]})`,name:'runFlow',outputType:'text'}},{run:{action:`modal_ConfirmDel.rec_id.setValue(ord_id)`,outputType:'text'}},{run:{action:`modal_ConfirmDel.rec_id.setValue(ord_id);modal_ConfirmDel.rec_name.setValue(\'ord_id\')`,outputType:'text'}},{wait:{delay:100}},{run:{action:`modal_ConfirmDel.show()`,name:'showModal',outputType:'text'}}])">
                                                            <i class="far fa-trash-alt fa-fw"></i>
                                                        </button>
                                                    </form>

                                                </td>
                                                <td dmx-text="ord_id" class="text-muted"></td>
                                                <td dmx-text="cln_Name" class="fw-bold text-nowrap text-body"></td>
                                                <td dmx-text="ord_Date.formatDate('dd-MM-yyyy')" class="text-nowrap"></td>
                                                <td dmx-text="ord_Total.toNumber().formatCurrency('€', ',', '.', 2)" class="text-nowrap text-end"></td>
                                                <td class="text-center">
                                                    <i class="fas fa-lg fa-fw" dmx-class:fa-times="ord_SentToProd==0" dmx-class:text-danger="ord_SentToProd==0" dmx-class:fa-check="ord_SentToProd==1" dmx-class:text-success="ord_SentToProd==1"></i>
                                                </td>
                                                <td class="text-center">
                                                    <span class="text-white shadow-sm rounded-pill lh-lg small px-1 border border-dark" dmx-text="ord_Status" dmx-class:bg-danger="ord_Status=='PENDING'" dmx-class:bg-info="ord_Status=='PARTLY'" dmx-class:bg-success="ord_Status=='COMPLETED'" dmx-class:bg-primary="ord_Status=='CANCELED'">Status</span>
                                                </td>
                                                <td class="text-danger text-center">
                                                    <i class="far fa-trash-alt bg-white py-1 px-2 rounded-pill shadow" dmx-show="ord_Deleted==1"></i>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-12 mb-2 px-2 h-100" id="conditionalShipments" is="dmx-if" dmx-bind:condition="var_Sel_Table.value=='Shipments'">
                    <div class="card shadow rounded mb-4 pb-0 bg-white border border-secondary" style="overflow: hidden;">
                        <div class="card-header p-0 ps-3 fw-bold bg-secondary text-uppercase border-2 border-bottom rounded-0 border-dark text-dark lh-lg">SHIPMENTS</div>
                        <div class="card-body px-1 py-1 bg-white">
                            <div class="row h-100 align-items-lg-end g-0 pb-2">
                                <div class="table-responsive">
                                    <table class="table table-hover table-bordered table-sm border-primary">
                                        <thead class="small">
                                            <tr class="text-center bg-secondary bg-opacity-50 text-dark align-bottom lh-1">
                                                <th class="py-0"><button id="btn_DelOrderHeader" class="btn btn-sm m-0 text-dark disabled">
                                                        <i class="far fa-trash-alt fa-fw"></i>
                                                    </button></th>
                                                <th>ID</th>
                                                <th class="text-primary">Order</th>
                                                <th>Client Name</th>
                                                <th>Shipment Date</th>
                                                <th>Total Amount</th>
                                                <th>Deleted</th>
                                            </tr>
                                        </thead>
                                        <tbody is="dmx-repeat" dmx-generator="bs5table" dmx-bind:repeat="srvc_DelShipments.data.qr_Del_getShipments" id="shipmentsRepeat" class="small">
                                            <tr class="text-center align-middle bg-opacity-10 py-0 lh-sm" dmx-class:bg-danger="shp_Deleted==1">
                                                <td class="py-0">
                                                    <form id="frm_DelShipments" is="dmx-serverconnect-form" method="post" action="dmxConnect/api/admin/deletions/shipments/permDeleteShipment.php" dmx-on:success="notifies1.success('SHIPMENT WAS DELETED ');srvc_DelShipments.load({})">
                                                        <input id="del_order_id1" name="del_ship_id" type="hidden" class="form-control" required="" dmx-bind:value="ord_id">
                                                        <button id="btn_DelShipment" title="Permanent Delete" class="btn m-0 btn-outline-danger bg-dark btn-sm" dmx-on:click="run([{run:{action:`flow_PassParams.run({inp_params: [{p_name: \'Shipment\', value: shp_id}, {p_name: \'Client\', value: cln_Name}]})`,name:'runFlow',outputType:'text'}},{run:{action:`modal_ConfirmDel.rec_id.setValue(shp_id)`,outputType:'text'}},{run:{action:`modal_ConfirmDel.rec_id.setValue(shp_id);modal_ConfirmDel.rec_name.setValue(\'shp_id\')`,outputType:'text'}},{wait:{delay:100}},{run:{action:`modal_ConfirmDel.show()`,name:'showModal',outputType:'text'}}])">
                                                            <i class="far fa-trash-alt fa-fw"></i></button>

                                                    </form>

                                                </td>
                                                <td dmx-text="shp_id" class="py-0 text-muted"></td>
                                                <td dmx-text="shp_Ord_id" class="p- text-muted"></td>
                                                <td dmx-text="cln_Name" class="p-0 fw-bold text-nowrap text-body"></td>
                                                <td dmx-text="shp_Date.formatDate('dd-MM-yyyy')" class="p-0 text-nowrap"></td>
                                                <td dmx-text="shp_Total.toNumber().formatCurrency('€', ',', '.', 2)" class="py-0 text-nowrap text-end"></td>
                                                <td class="text-danger text-center">
                                                    <i class="far fa-trash-alt bg-white py-1 px-2 rounded-pill shadow" dmx-show="shp_Deleted==1"></i>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
    <script src="bootstrap/5/js/bootstrap.bundle.min.js"></script>
    <script>
        function loadSelTable(tbl) {
            // if condition prevents trigger on buttonGroup initialization
            if(tbl) {            
                dmx.parse("srvc_Del" + tbl + ".load()");
            }
        }

        function deleteSelRecord(tbl, rec_id, rec_name) {            
            if(tbl && rec_id && rec_name) {
                dmx.parse("srvc_permDelete" + tbl + ".load({" + rec_name +": " + rec_id + "})");
            }
        }
    </script>
</body>

</html>

Here is a demo video…

*Have in mind that in this demo video, the delete serverActions don’t actually delete the records…
I have tested it and works fine deleting the records. But I disabled the delete step of the serverAction for not eliminating my test records and have to add test records again…

dynamic-serverconnectload-google-chrome-2023-11-20-08-39-19_JgVmRonJ

Thank you for sharing.

FYI: Change {{qr_checkOrder.count()==1}} to {{qr_checkOrder}} will achieve the same outcome.

1 Like