From: Anthony Talarico Date: Thu, 8 Nov 2018 20:56:06 +0000 (-0500) Subject: adding admin settings to add a hover color and a page to link to X-Git-Tag: v1.0.0^2~38 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=45db5d06293b1404dbf1a25a4621d90b5962c6dd;p=WP-Plugins%2Fglm-member-db-county-map.git adding admin settings to add a hover color and a page to link to --- diff --git a/css/admin.min.css b/css/admin.min.css index e853d85..500d42c 100644 --- a/css/admin.min.css +++ b/css/admin.min.css @@ -1 +1 @@ -#new-area-section{background-color:white}#new-area-section .input-container{margin-bottom:0;padding:0 10px 0 10px}#new-area-section .input-container input.area-name{margin:10px 10px 0 10px}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child){line-height:1;min-height:20px}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) span,#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) a{line-height:1;padding:2px 10px} +#new-area-section{background-color:white}#new-area-section .input-container{margin-bottom:0;padding:0 10px 0 10px}#new-area-section .input-container input.area-name{margin:10px 10px 0 0px}#new-area-section .input-container input.area-name+label{top:15px !important}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child){line-height:1;min-height:20px}#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) span,#new-area-section .map-page-selection .select-wrapper .dropdown-content.select-dropdown li:not(:first-child) a{line-height:1;padding:2px 10px}#new-area-section .map-color-selection{margin-top:20px}#new-area-section .map-color-selection label{margin-left:15px;font-size:16px}#list-header{padding:5px;background-color:#003366;color:white}#list-header .area-header{color:inherit}#area-list .record-container{margin-bottom:2px}#area-list .record-container .area-record{padding:5px;background-color:white}#area-list .record-container .area-record .area-record-delete{position:relative;right:15px}#area-list .record-container .area-record .area-record-delete:hover{cursor:pointer} diff --git a/models/admin/ajax/mapSettingsAjax.php b/models/admin/ajax/mapSettingsAjax.php index 5aca237..bf59cee 100644 --- a/models/admin/ajax/mapSettingsAjax.php +++ b/models/admin/ajax/mapSettingsAjax.php @@ -57,6 +57,10 @@ class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings //parent::__construct(false, false); } + private function getAreas(){ + $sql = "SELECT * FROM " . GLM_MEMBERS_COUNTY_MAP_PLUGIN_DB_PREFIX . 'areas'; + return $this->wpdb->get_results($sql); + } function write_log ( $log ) { if ( true === WP_DEBUG ) { if ( is_array( $log ) || is_object( $log ) ) { @@ -81,11 +85,14 @@ class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings public function modelAction ($actionData = false) { global $wpdb; - $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING); - $numbObits = 0; - $namesList = false; - $areas = false; - $test = "start"; + $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING); + $numbObits = 0; + $namesList = false; + $areas = false; + $test = "start"; + $area_name = false; + $page_id = false; + // Check if an ID is supplied $id = 0; if ( isset( $_REQUEST['id'] ) ) { @@ -96,8 +103,24 @@ class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings switch( $option ) { case 'add': - $return = $this->insertEntry(); - $id = $return['fieldData']['id']; + + $area_name = filter_var($_REQUEST['area_name'], FILTER_SANITIZE_STRING); + $page_id = (isset($_REQUEST['page_id'])) ? filter_var($_REQUEST['page_id'], FILTER_SANITIZE_STRING) : 0; + $hover_color = filter_var($_REQUEST['hover_color'], FILTER_SANITIZE_URL); + $this->wpdb->insert( + GLM_MEMBERS_COUNTY_MAP_PLUGIN_DB_PREFIX . 'areas', + array( + 'area_name' => $area_name, + 'page_id' => $page_id, + 'hover_color' => $hover_color, + ), + array( + '%s', + '%d', + '%s' + ) + ); + $areas = $this->getAreas(); break; case 'update': @@ -108,12 +131,23 @@ class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings case 'delete': if ( $id > 0 ) { - $this->deleteEntry( $id, true ); + $test = $id; + $wpdb->delete( + GLM_MEMBERS_COUNTY_MAP_PLUGIN_DB_PREFIX . 'areas', // table to delete from + array( + 'id' => $id // value in column to target for deletion + ), + array( + '%d' // format of value being targeted for deletion + ) + ); + $areas = $this->getAreas(); } break; case 'list': - $areas = $this->getList(); + $areas = $this->getAreas(); + break; default: @@ -123,12 +157,12 @@ class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings } } $data['list'] = $areas; - $data['test'] = $this->wpdb->insert_id; // Get number of obits $return = array( - 'searchData' => $data // Where our events list will go + 'areas' => $data, + 'test' => $test // Where our events list will go ); header('Content-type:application/json;charset=utf-8', true); diff --git a/models/admin/settings/mapSettings.php b/models/admin/settings/mapSettings.php index d2ca2f2..7f1a414 100644 --- a/models/admin/settings/mapSettings.php +++ b/models/admin/settings/mapSettings.php @@ -107,13 +107,16 @@ class GlmMembersAdmin_settings_mapSettings extends GlmDataMapSettings GLM_MEMBERS_PLUGIN_VERSION ); $args = array( - 'sort_order' => 'asc', - 'sort_column' => 'post_title', - 'hierarchical' => 0, - 'post_type' => 'page', - 'post_status' => 'publish' + 'sort_order' => 'asc', + 'sort_column' => 'post_title', + 'hierarchical' => 0, + 'post_type' => 'page', + 'post_status' => 'publish' ); - $pages = get_pages($args); + $results = get_pages($args); + foreach($results as $page){ + $pages[$page->ID] = $page->post_title; + } wp_enqueue_script('materialize', false, array('jquery'), false, true); wp_enqueue_style('materialize-css', GLM_MEMBERS_PLUGIN_URL . 'css/materialize.min.css'); wp_enqueue_style('admin-css', GLM_MEMBERS_COUNTY_MAP_PLUGIN_URL . 'css/admin.min.css'); diff --git a/sass/admin/_settings.scss b/sass/admin/_settings.scss index 6dd5206..862cff6 100644 --- a/sass/admin/_settings.scss +++ b/sass/admin/_settings.scss @@ -4,7 +4,10 @@ margin-bottom: 0; padding: 0 10px 0 10px; input.area-name{ - margin: 10px 10px 0 10px; + margin: 10px 10px 0 0px; + } + input.area-name + label{ + top: 15px !important; } } .map-page-selection{ @@ -21,4 +24,36 @@ } } } + .map-color-selection{ + margin-top: 20px; + label{ + margin-left: 15px; + font-size: 16px; + } + } +} +#list-header{ + padding: 5px; + background-color: #003366; + color: white; + .area-header{ + color: inherit; + } +} +#area-list{ + + .record-container{ + margin-bottom: 2px; + .area-record{ + padding: 5px; + background-color: white; + .area-record-delete{ + position: relative; + right: 15px; + &:hover{ + cursor: pointer; + } + } + } + } } \ No newline at end of file diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 4bc99a9..4282b6e 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -24,4 +24,3 @@ * }); * * Also note that parameters will be in the context of the main admin controller constructor. - */ diff --git a/setup/databaseScripts/create_database_V0.0.1.sql b/setup/databaseScripts/create_database_V0.0.1.sql index 8f06e76..cb02a96 100644 --- a/setup/databaseScripts/create_database_V0.0.1.sql +++ b/setup/databaseScripts/create_database_V0.0.1.sql @@ -17,8 +17,8 @@ CREATE TABLE {prefix}areas ( id INT NOT NULL AUTO_INCREMENT, area_name TINYTEXT NOT NULL, lat FLOAT NOT NULL DEFAULT 0, - lng FLOAT NOT NULL DEFAULT 0, -- Birth Year - page_id SMALLINT NOT NULL DEFAULT 0, -- Birth Year Range (use the start of the decade like 2010 or 2000) - hover_color TINYTEXT NOT NULL, -- Death Year + lng FLOAT NOT NULL DEFAULT 0, + page_id SMALLINT NOT NULL DEFAULT 0, + hover_color TINYTEXT NOT NULL, PRIMARY KEY (id) ); \ No newline at end of file diff --git a/views/admin/settings/mapSettings.html b/views/admin/settings/mapSettings.html index aa291d0..abe75f6 100644 --- a/views/admin/settings/mapSettings.html +++ b/views/admin/settings/mapSettings.html @@ -1,29 +1,57 @@
-
- -
-
-
- +
+
+
+
+ + Required + +
+
+ +
+
+ +
+
+
+
+
+
+ + +
+
+
+
Area Name
+
Attached Page
+
Hover Color
+
+
-