diff --git a/index.php b/index.php index 9468d65..1f1a8bf 100644 --- a/index.php +++ b/index.php @@ -25,6 +25,7 @@ include 'db_picker.php'; include $db_location; + // soft deletes a database entry if ($_SERVER["REQUEST_METHOD"] == "POST") { @@ -149,20 +150,12 @@ +
- - -
New Application
@@ -242,41 +235,4 @@ - - - - - $adate - $jname - $ename - $astatus - -
- - -
- - - - "; - } -} -*/ -?> \ No newline at end of file + \ No newline at end of file diff --git a/js/dashboard.js b/js/dashboard.js index 9edd336..32e2427 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -107,91 +107,52 @@ function populateAppList(){ //console.log("POPULATING LIST"); //console.log("App Cnt to Load: " + appCntToLoad); if (sortedApps.length === 0){ - appListDiv.append("\n" + - ' \n' + - ' \n' + - ' No Results\n' + - ' \n' + - ' \n' + - " "); + const noResults = '\n' + + '\n' + + '\n' + + 'No Results\n' + + '\n' + + '\n' + + ''; + appListDiv.append(noResults); }else{ $('#more-apps').show(); } for(let i = 0; i < sortedApps.length; i++){ - //if (sortedApps[i].length === 0){continue} // don't show item if it's empty. for some reason the array has an empty item in it + //if (appData.length === 0){continue} // don't show item if it's empty. for some reason the array has an empty item in it - // Hide the "More" button if all apps are loaded - if (i === (sortedApps.length-1)) $('#more-apps').hide(); + if (i === (sortedApps.length-1)) $('#more-apps').hide(); // Hide the "More" button if all apps are loaded + if (appShowingCnt === appCntToLoad) return; // Stop creating app items if max app count has been reached - // Stop creating app items if max app count has been reached - if (appShowingCnt === appCntToLoad) return; - - // Create Table Row - const tRow = $(document.createElement('tr')); - tRow.addClass('app-list-item'); - tRow.attr('id', 'app-' + sortedApps[i].application_id); - appListDiv.append(tRow); - // Create Table Data for App Date, Job Title, and Employer Name - tRow.append('' + sortedApps[i].adate + ''); - tRow.append('' + sortedApps[i].jname + ''); - tRow.append('' + sortedApps[i].ename + ''); - // Create Table Data for the Status - const statusOuter = $(document.createElement('td')); - statusOuter.addClass('status status-'+sortedApps[i].astatus); - statusOuter.append(''); - statusOuter.append(''+sortedApps[i].astatus+''); - tRow.append((statusOuter)); - // Create Table Data for the App Button Outer - const appBtnOuter = $(document.createElement('td')); - appBtnOuter.addClass('app-button-outer'); - // Create a form to POST on submit (update button submits) - const form = $(document.createElement('form')); - form.attr('method', 'post'); - form.attr('action', 'application_edit.php'); - // Create hidden input - const input = $(document.createElement('input')); - input.attr('type', 'hidden'); - input.attr('name', 'application-id'); - input.val(sortedApps[i].application_id); - form.append(input); - // Create Edit Button (submits to POST onclick) - const editBtn = $(document.createElement('button')); - editBtn.attr('type', 'submit'); - editBtn.addClass('app-button-inner btn btn-sm btn-update'); - editBtn.append(''); - form.append((editBtn)); - appBtnOuter.append((form)); - // Create Delete Button - const deleteBtn = $(document.createElement('button')); - deleteBtn.addClass('app-button-inner btn btn-sm btn-delete'); - deleteBtn.attr('data-bs-toggle', 'modal'); - deleteBtn.attr('data-bs-target', '#delete-modal'); - deleteBtn.click(() => deleteAppBtnClicked(sortedApps[i].application_id, sortedApps[i].ename)); - deleteBtn.append(''); - - appBtnOuter.append((deleteBtn)); - tRow.append(appBtnOuter); - - appShowingCnt++; + createAppFromData(sortedApps[i]); } +} - /* - appListDiv.append("\n" + - ' ' + app.adate + '\n' + - ' ' + app.jname + '\n' + - ' ' + app.ename + '\n' + - ' '+app.astatus+'\n' + - ' \n' + - '
\n' + - ' \n' + - ' \n' + - '
\n' + - ' \n' + - ' \n' + - " ") - - */ +function createAppFromData(appData){ + // Create a list item with the application data filled in + const app = `\n` + + `${appData.adate}\n` + + `${appData.jname}\n` + + `${appData.ename}\n` + + `\n` + + `\n` + + `${appData.astatus}\n` + + `\n` + + `\n` + + `
` + + `` + + `
\n` + + `\n` + + ``; + appListDiv.append(app); + appShowingCnt++; } // Remove children from application list