From 59b89d3c4ce13af5329604e07e60784cd0895b20 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 8 Mar 2018 09:01:06 -0500 Subject: [PATCH] Most of admin assets dashboard coming up. --- classes/data/dataFacilities.php | 20 +- setup/validActions.php | 3 + views/admin/assets/index.html | 406 +++++++++++++++++++++----------- 3 files changed, 287 insertions(+), 142 deletions(-) diff --git a/classes/data/dataFacilities.php b/classes/data/dataFacilities.php index 982d307..b2b0452 100644 --- a/classes/data/dataFacilities.php +++ b/classes/data/dataFacilities.php @@ -121,6 +121,7 @@ class GlmDataAssetsFacilities extends GlmDataAbstract 'field' => 'name', 'type' => 'text', 'required' => true, + 'unique' => true, 'use' => 'a' ), @@ -142,10 +143,10 @@ class GlmDataAssetsFacilities extends GlmDataAbstract 'city' => array ( 'field' => 'city', 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities', - 'p_field' => 'name', - 'p_orderby' => 'name', - 'p_blank' => true, + 'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities', + 'p_field' => 'name', + 'p_orderby' => 'name', + 'p_blank' => true, 'force_list' => true, 'use' => 'a' ), @@ -154,9 +155,8 @@ class GlmDataAssetsFacilities extends GlmDataAbstract 'state' => array ( 'field' => 'state', 'type' => 'list', - 'list' => $this->config['states'], - 'default' => 'MI', - 'force_list' => true, + 'list' => $this->config['states'], + 'default' => $this->config['settings']['default_state'], 'use' => 'a' ), @@ -171,12 +171,12 @@ class GlmDataAssetsFacilities extends GlmDataAbstract 'country' => array ( 'field' => 'country', 'type' => 'list', - 'list' => $this->config['countries'], + 'list' => $this->config['countries'], 'default' => 'US', - 'force_list' => true, 'use' => 'a' ), +/* // Latitude 'lat' => array( 'field' => 'lat', @@ -192,7 +192,7 @@ class GlmDataAssetsFacilities extends GlmDataAbstract 'default' => $this->config['settings']['maps_default_lon'], 'use' => 'a' ), - +*/ // Phone 'phone' => array ( 'field' => 'phone', diff --git a/setup/validActions.php b/setup/validActions.php index cecc3c9..a518251 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -59,6 +59,9 @@ $glmMembersAssetsAddOnValidActions = array( 'adminActions' => array( + 'ajax' => array( + 'assetManagement' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG + ), 'assets' => array( 'index' => GLM_MEMBERS_ASSETS_PLUGIN_SLUG ), diff --git a/views/admin/assets/index.html b/views/admin/assets/index.html index 9652e34..a6d3f23 100644 --- a/views/admin/assets/index.html +++ b/views/admin/assets/index.html @@ -15,7 +15,20 @@ .assets-colum-title { font-weight: bold; } - + .assets-dialog-box { + display: grid; + grid-gap: 5px 5px; + grid-template-columns: 8rem auto; + } + .assets-facility-descr { + width: 30em !important; + } + .assets-facility-input-prompt { + padding: 5px 0 0 5px; + } + .assetsFacilityInputMsg { + color: red; + } @@ -26,140 +39,161 @@
- Add a Facility + Add a Facility {if $haveFacilities} -
+
{foreach $facilities as $facility} -
(Facility Name)
- - - -
Asset Type
-
Name
-
Number
-
Quantity
+
{$facility.name}
+ + {* First indent here *} + + + +
Asset Type
+
Name
+
Number
+
Quantity
{foreach $facility.assets as $asset} -
Room
-
Ballroom
-
101
-
1
- - +
Room
+
Ballroom
+
101
+
1
+ + {* Second indent here *} -
Start
-
End
-
Account
-
Quantity
+ + +
Start
+
End
+
Account
+
Quantity
{foreach $asset.assignments as $assignment} -
1/1/2018 07:00 AM
-
1/1/2018 05:00 PM
-
Gaslight Media
-
1
+ +
1/1/2018 07:00 AM
+
1/1/2018 05:00 PM
+
Gaslight Media
+
1
+ + {* Third indent here *} + + + {/foreach} {* assignments *} - - {/foreach} + {/foreach} {* assets *} + + {/foreach} {* facilities *} - {/foreach} - {/foreach} -{else} -
No Facilities Listed
-{/if} +{else} {* if haveFacilities *} + +
No Facilities Listed
+ +{/if} {* if haveFacilities *} +
{* assets-admin-content *} + +
{* glm-admin-table-inner *} +
{* glm-admin-table *} + {* New Facility Dialog Box *} +
+
+ +
+ +
Name:
+
+ +
Description:
+
+ +
Address:
+
+ +
City:
+
+ +
+ +
State:
+
+ +
+ +
ZIP / Postal Code:
+
+ +
Country:
+
+ +
+ + + +
Phone:
+
+ +
URL:
+
+ +
E-Mail Address:
+
+ +
Facility Map:
+
+

+ Facility map file must be a standard image file such as JPG, PNG, or GIF and + of adequate size and resolution. Images larger than 1200 pixels wide may be + too large for the page. +

+ (image url here)
+ Delete Image
+ New image: +
+ +
 
 
+ +
* Required
+ + +
{* assetsFacilityDialog *} + + +
+
+
+
{* facility_name *}
+ +
- -
- - @@ -167,24 +201,132 @@ jQuery(document).ready(function($){ - // Copy an element to the clipboard - function copyToClipboard(text) { - var $temp = $(""); - $("body").append($temp); - $temp.val(text).select(); - document.execCommand("copy"); - $temp.remove(); + // Facility dialog box + $('#assetsFacilityDialog').dialog({ + autoOpen: false, + width: 600, + minWidth: 300, + dialogClass: 'glm-dialog-no-close' + }); + + // Add a facility + $('#glm-assets-add-facility-button').on('click', function() { + $('#assetsFacilityDialog').dialog('open'); + $('#assetsFacilityForm')[0].reset(); + }) + + // Hide "No facilities" + function hideNoFacilities() { + $('#glm-assets-no-facilities').hide(); } + + // Cancel facility dialog box + $('#assetsFacilityCancel').on('click', function() { + $('#assetsFacilityDialog').dialog('close'); + }) + + // Save facility data + $('#assetsFacilitySubmit').on('click', function(e){ + +// var facilityData = $('#assetsFacilityForm').serializeArray(); + var facilityData = new FormData(); + facilityData.append('option', 'addNewFacility'); + facilityData.append('facility_map_new', $('#assetFacilityMap')[0].files[0]); + var formFields = $('#assetsFacilityForm').serializeArray(); + for (var i = 0; i < formFields.length; i++) { + facilityData.append(formFields[i].name, formFields[i].value); + } + + $.ajax({ + context: this, + type: 'POST', + url: '{$ajaxUrl}?action=glm_members_admin_ajax', + data : facilityData, + processData: false, + contentType: false, + }).done(function(msg){ +alert(msg); + // Get response message + var response = JSON.parse(msg); + + // Clear any submission error messages + $('.assetsFacilityInputMsg').html(''); + + // If there was a submission problem + if (!response.status) { + + // For each input field + for (var key in response.fieldFail) { + + // If this field was a problem + if (response.fieldFail[key]) { - $('body').on('click', '.glm-file-library-copy', function(e) { + // Put a highlighted message under this field. + $('#assetsFacilityInput_' + key).addClass('assets-facility-input-fail'); + $('#assetsFacilityInputMsg_' + key).html('
' + response.fieldFail[key]); + + } + } + alert('Facility not saved. Please check the indicated fields.'); + } else { + $('#assetsFacilityDialog').dialog('close'); + hideNoFacilities(); + var facilityTemplate = templateParse($('#assetsFailityTemplate').html(), 'facility_', response.fieldStore); + $('#assets-facilities-container').prepend(facilityTemplate); + + + } + + function templateParse(template, prefix, data) { +alert(data.name); + for (var key in data) { +alert(data[key]); + template = template.replace('{* ' + prefix + key + ' *}', data[key]); + } + return template; + } + + }).fail(function(){ + alert('Unable to store this facility at this time. Please try again.'); + }); + +/* e.preventDefault(); - copyToClipboard($(this).attr('data-link')); - var fileId = $(this).attr('data-file'); - lastFileTouched(fileId); - flashNotice($('#FileCopied_' + fileId)); - return false; + var fileId = $(this).data('file'); + + // Get possible custom field data + var fileFormData = $('#glm-file-form-' + fileId).serialize(); + console.log(fileFormData); + + var fileTitle = $('#InputTitle_' + fileId).val().trim(); + var fileDescr = $('#InputDescr_' + fileId).val().trim(); + + $.ajax({ + context: this, + type: 'POST', + url: '{$ajaxUrl}?action=glm_members_admin_ajax', + dataType: 'text', + data: { + glm_action: 'fileLibraryUpdate', + fileId: fileId, + title: fileTitle, + descr: fileDescr + } + }).done(function(){ + $('.glm-edit-form-' + $(this).data('file')).hide(); + $('.glm-file-' + $(this).data('file')).show(); + $('#fileTitle_' + fileId).text(fileTitle); + clearFileLinks(); + }).fail(function(msg){ + alert('Unable to update file: ' + msg); + }); +*/ }); + +/* + + $('.glm-edit').live('click', function(e){ e.preventDefault(); fileLinksEditSelected(); @@ -200,11 +342,6 @@ jQuery(document).ready(function($){ $('.glm-file-' + $(this).data('file')).show(); }); - $('.file-download-link').live('click', function(e) { - var fileId = $(this).data('file'); - lastFileTouched(fileId); - }); - // File Line Hover Action var fileEditFlag = false; var fileHoverId = false; @@ -299,6 +436,11 @@ jQuery(document).ready(function($){ $('.glm-file-line').removeClass('last-file-touched'); $('#filenameLine_' + fileId).addClass('last-file-touched file-been-touched'); } +*/ + + function flashNotice(notice) { + notice.fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500).fadeIn(500).fadeOut(500); + } }); -- 2.17.1