From: Anthony Talarico Date: Wed, 7 Nov 2018 21:33:15 +0000 (-0500) Subject: adding pages from a dropdown list to select a page to attach an area to from the... X-Git-Tag: v1.0.0^2~39 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=35b6942d91edd972091fcdda6ce3731d9efa6c80;p=WP-Plugins%2Fglm-member-db-county-map.git adding pages from a dropdown list to select a page to attach an area to from the settings menu --- diff --git a/css/admin.min.css b/css/admin.min.css index e69de29..e853d85 100644 --- a/css/admin.min.css +++ b/css/admin.min.css @@ -0,0 +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} diff --git a/models/admin/ajax/mapSettings.php b/models/admin/ajax/mapSettings.php deleted file mode 100644 index fd59af5..0000000 --- a/models/admin/ajax/mapSettings.php +++ /dev/null @@ -1,138 +0,0 @@ - - * @license http://www.gaslightmedia.com Gaslightmedia - * @version 0.1 - */ -require_once GLM_MEMBERS_COUNTY_MAP_PLUGIN_CLASS_PATH.'/data/dataMapSettings.php'; -/** - * - * This class exports the currently selected members list - * to a printable HTML file, to a CSV file, or otherwise. - */ -class GlmMembersAdmin_ajax_mapSettings extends GlmDataMapSettings -{ - - /** - * WordPress Database Object - * - * @var $wpdb - * @access public - */ - public $wpdb; - /** - * Plugin Configuration Data - * - * @var $config - * @access public - */ - public $config; - - /** - * Constructor - * - * This constructor sets up this model. At this time that only includes - * storing away the WordPress data object. - * - * @return object Class object - * - */ - public function __construct ($wpdb, $config) - { - - // Save WordPress Database object - $this->wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - //parent::__construct(false, false); - - } - function write_log ( $log ) { - if ( true === WP_DEBUG ) { - if ( is_array( $log ) || is_object( $log ) ) { - error_log( print_r( $log, true ) ); - } else { - error_log( $log ); - } - } - } - /** - * Perform Model Action - * - * This modelAction takes an AJAX image upload and stores the image in the - * media/images directory of the plugin. - * - * This model action does not return, it simply does it's work then calls die(); - * - * @param $actionData - * - * Echos JSON string as response and does not return - */ - public function modelAction ($actionData = false) - { - global $wpdb; - $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING); - $numbObits = 0; - $namesList = false; - $areas = false; - $test = "testa"; - // Check if an ID is supplied - $id = 0; - if ( isset( $_REQUEST['id'] ) ) { - $id = $_REQUEST['id'] - 0; - } - // If there's an action option - if ( $option ) { - switch( $option ) { - - case 'add': - $return = $this->insertEntry(); - $id = $return['fieldData']['id']; - break; - - case 'update': - if ( $id > 0 ) { - $this->updateEntry( $id ); - } - break; - - case 'delete': - if ( $id > 0 ) { - $this->deleteEntry( $id, true ); - } - break; - - case 'list': - $areas = $this->getList(); - break; - - default: - $option2 = false; - break; - - } - } - $data['list'] = $areas; - $data['test'] = $test; - // Get number of obits - - - $return = array( - 'searchData' => $data // Where our events list will go - ); - - header('Content-type:application/json;charset=utf-8', true); - echo json_encode($return); - wp_die(); - } -} diff --git a/models/admin/ajax/mapSettingsAjax.php b/models/admin/ajax/mapSettingsAjax.php new file mode 100644 index 0000000..5aca237 --- /dev/null +++ b/models/admin/ajax/mapSettingsAjax.php @@ -0,0 +1,138 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ +require_once GLM_MEMBERS_COUNTY_MAP_PLUGIN_CLASS_PATH.'/data/dataMapSettings.php'; +/** + * + * This class exports the currently selected members list + * to a printable HTML file, to a CSV file, or otherwise. + */ +class GlmMembersAdmin_ajax_mapSettingsAjax extends GlmDataMapSettings +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /** + * Constructor + * + * This constructor sets up this model. At this time that only includes + * storing away the WordPress data object. + * + * @return object Class object + * + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + //parent::__construct(false, false); + + } + function write_log ( $log ) { + if ( true === WP_DEBUG ) { + if ( is_array( $log ) || is_object( $log ) ) { + error_log( print_r( $log, true ) ); + } else { + error_log( $log ); + } + } + } + /** + * Perform Model Action + * + * This modelAction takes an AJAX image upload and stores the image in the + * media/images directory of the plugin. + * + * This model action does not return, it simply does it's work then calls die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction ($actionData = false) + { + global $wpdb; + $option = filter_var($_REQUEST['option'], FILTER_SANITIZE_STRING); + $numbObits = 0; + $namesList = false; + $areas = false; + $test = "start"; + // Check if an ID is supplied + $id = 0; + if ( isset( $_REQUEST['id'] ) ) { + $id = $_REQUEST['id'] - 0; + } + // If there's an action option + if ( $option ) { + switch( $option ) { + + case 'add': + $return = $this->insertEntry(); + $id = $return['fieldData']['id']; + break; + + case 'update': + if ( $id > 0 ) { + $this->updateEntry( $id ); + } + break; + + case 'delete': + if ( $id > 0 ) { + $this->deleteEntry( $id, true ); + } + break; + + case 'list': + $areas = $this->getList(); + break; + + default: + $option2 = false; + break; + + } + } + $data['list'] = $areas; + $data['test'] = $this->wpdb->insert_id; + // Get number of obits + + + $return = array( + 'searchData' => $data // Where our events list will go + ); + + header('Content-type:application/json;charset=utf-8', true); + echo json_encode($return); + wp_die(); + } +} diff --git a/models/admin/settings/mapSettings.php b/models/admin/settings/mapSettings.php index e55ba6a..d2ca2f2 100644 --- a/models/admin/settings/mapSettings.php +++ b/models/admin/settings/mapSettings.php @@ -96,69 +96,32 @@ class GlmMembersAdmin_settings_mapSettings extends GlmDataMapSettings */ public function modelAction ($actionData = false) { - $success = true; - $areas = false; - + // Enqueue Materialize wp_register_script( 'materialize', GLM_MEMBERS_PLUGIN_URL . 'js/materialize/materialize.min.js', array( - 'jquery' + 'jquery' ), GLM_MEMBERS_PLUGIN_VERSION ); - + $args = array( + 'sort_order' => 'asc', + 'sort_column' => 'post_title', + 'hierarchical' => 0, + 'post_type' => 'page', + 'post_status' => 'publish' + ); + $pages = get_pages($args); 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'); wp_enqueue_style('css-icons', "https://fonts.googleapis.com/icon?family=Material+Icons"); - - // Model Logic - $number_of_areas = 0; - $areaList = false; - - // Check if an ID is supplied - $id = 0; - if ( isset( $_REQUEST['id'] ) ) { - $id = $_REQUEST['id'] - 0; - } - // If there's an action option - if ( isset( $_REQUEST['option'] ) ) { - switch( $_REQUEST['option'] ) { - - case 'addNew': - $return = $this->insertEntry(); - $id = $return['fieldData']['id']; - break; - - case 'update': - if ( $id > 0 ) { - $this->updateEntry( $id ); - } - echo "no id"; - break; - - case 'delete': - if ( $id > 0 ) { - $this->deleteEntry( $id, true ); - } - break; - - default: - $option2 = false; - break; - - } - } - - $areas = $this->getList(); - - // Compile template data $templateData = array( - + 'pages' => $pages ); // Return status, suggested view, and data to controller diff --git a/sass/admin/_settings.scss b/sass/admin/_settings.scss index e69de29..6dd5206 100644 --- a/sass/admin/_settings.scss +++ b/sass/admin/_settings.scss @@ -0,0 +1,24 @@ +#new-area-section{ + background-color: white; + .input-container{ + margin-bottom: 0; + padding: 0 10px 0 10px; + input.area-name{ + margin: 10px 10px 0 10px; + } + } + .map-page-selection{ + .select-wrapper{ + .dropdown-content.select-dropdown{ + li:not(:first-child){ + line-height: 1; + min-height: 20px; + span,a{ + line-height: 1; + padding: 2px 10px; + } + } + } + } + } +} \ No newline at end of file diff --git a/setup/validActions.php b/setup/validActions.php index 4a485b7..1f129fb 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -60,7 +60,7 @@ $glmMembersCountyMapAddOnValidActions = array( 'adminActions' => array( 'ajax' => array( - 'mapSettings' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG, + 'mapSettingsAjax' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG, ), 'settings' => array( 'mapSettings' => GLM_MEMBERS_COUNTY_MAP_PLUGIN_SLUG, diff --git a/views/admin/settings/mapSettings.html b/views/admin/settings/mapSettings.html index f540865..aa291d0 100644 --- a/views/admin/settings/mapSettings.html +++ b/views/admin/settings/mapSettings.html @@ -1,15 +1,27 @@ -
- +
+
+ +
+
+
+ +
+
-
+
-